Sha256: aeab846ebf26a6a47fdb5ade0be9477ec75a80f2555a948d0e76f40f2234617a

Contents?: true

Size: 1.22 KB

Versions: 18

Compression:

Stored size: 1.22 KB

Contents

class InvitationsController < ApplicationController
  before_filter :authorize_admin, :except => [:show, :update]
  skip_before_filter :authenticate, :only => [:show, :update]
  layout Saucy::Layouts.to_proc

  def new
    assign_projects
    @invitation = Invitation.new
    render
  end

  def create
    @invitation = Invitation.new(params[:invitation])
    @invitation.account = current_account
    if @invitation.save
      flash[:success] = "User invited."
      redirect_to account_memberships_url(current_account)
    else
      assign_projects
      render :action => 'new'
    end
  end

  def show
    with_invitation { render }
  end

  def update
    with_invitation do
      if @invitation.accept(params[:invitation])
        sign_in @invitation.user
        redirect_to root_url
      else
        render :action => 'show'
      end
    end
  end

  private

  def assign_projects
    @projects = current_account.projects_by_name
  end

  def with_invitation
    @invitation = Invitation.find_by_code!(params[:id])
    if @invitation.used?
      flash[:error] = t("invitations.show.used",
                        :default => "That invitation has already been used.")
      redirect_to root_url
    else
      yield
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
saucy-0.2.28.1 app/controllers/invitations_controller.rb
saucy-0.2.39 app/controllers/invitations_controller.rb
saucy-0.2.38 app/controllers/invitations_controller.rb
saucy-0.2.36 app/controllers/invitations_controller.rb
saucy-0.2.35 app/controllers/invitations_controller.rb
saucy-0.2.34 app/controllers/invitations_controller.rb
saucy-0.2.33 app/controllers/invitations_controller.rb
saucy-0.2.32 app/controllers/invitations_controller.rb
saucy-0.2.31 app/controllers/invitations_controller.rb
saucy-0.2.30 app/controllers/invitations_controller.rb
saucy-0.2.29 app/controllers/invitations_controller.rb
saucy-0.2.28 app/controllers/invitations_controller.rb
saucy-0.2.27 app/controllers/invitations_controller.rb
saucy-0.2.26 app/controllers/invitations_controller.rb
saucy-0.2.25 app/controllers/invitations_controller.rb
saucy-0.2.24 app/controllers/invitations_controller.rb
saucy-0.2.21 app/controllers/invitations_controller.rb
saucy-0.2.20 app/controllers/invitations_controller.rb