2009-08-02 19:41:09 +02:00
|
|
|
class InvitesController < ApplicationController
|
|
|
|
|
|
|
|
before_filter :authenticate_membership_or_admin, :only => [:new]
|
2013-02-04 13:00:34 +01:00
|
|
|
#TODO: authorize also for create action.
|
2009-08-02 19:41:09 +02:00
|
|
|
|
|
|
|
def new
|
|
|
|
@invite = Invite.new(:user => @current_user, :group => @group)
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@invite = Invite.new(params[:invite])
|
2012-08-06 12:00:40 +02:00
|
|
|
if @invite.save
|
2012-12-30 16:11:35 +01:00
|
|
|
Mailer.invite(@invite).deliver
|
2012-10-15 21:19:17 +02:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2013-02-04 13:00:34 +01:00
|
|
|
redirect_to back_or_default_path, notice: I18n.t('invites.success')
|
2012-10-15 21:19:17 +02:00
|
|
|
end
|
|
|
|
format.js { render layout: false }
|
|
|
|
end
|
|
|
|
|
2012-08-06 12:00:40 +02:00
|
|
|
else
|
|
|
|
render action: :new
|
2009-08-02 19:41:09 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|