Introduce Public controllers
This commit is contained in:
parent
d490a4e9f3
commit
6dfcac3131
|
@ -6,6 +6,12 @@ class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
before_filter :configure_permitted_parameters, if: :devise_controller?
|
before_filter :configure_permitted_parameters, if: :devise_controller?
|
||||||
before_action :set_locale
|
before_action :set_locale
|
||||||
|
before_action :set_view_paths
|
||||||
|
|
||||||
|
# TODO: make this get the domain from the database
|
||||||
|
#layout Proc.new { |controller| controller.request.host }
|
||||||
|
layout 'public/application'
|
||||||
|
|
||||||
|
|
||||||
def self.default_url_options(options={})
|
def self.default_url_options(options={})
|
||||||
if I18n.locale != I18n.default_locale
|
if I18n.locale != I18n.default_locale
|
||||||
|
@ -21,6 +27,11 @@ class ApplicationController < ActionController::Base
|
||||||
I18n.locale = params[:locale] || I18n.default_locale
|
I18n.locale = params[:locale] || I18n.default_locale
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_view_paths
|
||||||
|
# TODO: make this get the domain from the database
|
||||||
|
prepend_view_path 'lib/initfest/views' if request.host =~ /openfest/
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def configure_permitted_parameters
|
def configure_permitted_parameters
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
module Public
|
||||||
|
class ApplicationController < ::ApplicationController
|
||||||
|
include ::CurrentConferenceAssigning
|
||||||
|
before_filter :require_current_conference!
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,36 @@
|
||||||
|
module Public
|
||||||
|
class EventsController < Public::ApplicationController
|
||||||
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
event_type = current_conference.event_types.find(params[:type])
|
||||||
|
@event = Event.new event_type: event_type
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@event = Event.new event_params
|
||||||
|
@event.conference = current_conference
|
||||||
|
@event.build_proposition proposer: current_user
|
||||||
|
@event.participations.build participant: current_user, approved: true
|
||||||
|
|
||||||
|
if @event.save
|
||||||
|
redirect_to action: :index
|
||||||
|
else
|
||||||
|
render action: :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def event_params
|
||||||
|
params.require(:event).permit(
|
||||||
|
:title, :subtitle, :track_id, :length, :language,
|
||||||
|
:abstract, :description, :notes, :agreement,
|
||||||
|
:event_type_id
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,44 @@
|
||||||
|
module Public
|
||||||
|
class PersonalProfilesController < Public::ApplicationController
|
||||||
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
|
def new
|
||||||
|
@profile = current_user.build_personal_profile(current_conference)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@profile = current_user.build_personal_profile(current_conference, profile_params)
|
||||||
|
|
||||||
|
if @profile.save
|
||||||
|
flash[:notice] = t('profile.successfully_created')
|
||||||
|
redirect_to root_path
|
||||||
|
else
|
||||||
|
render action: :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@profile = current_user.personal_profile(current_conference)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@profile = current_user.personal_profile(current_conference)
|
||||||
|
|
||||||
|
if @profile.update_attributes(profile_params)
|
||||||
|
flash[:notice] = t('profile.successfully_updated')
|
||||||
|
redirect_to root_path
|
||||||
|
else
|
||||||
|
render action: 'edit'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def profile_params
|
||||||
|
params.require(:personal_profile).permit(
|
||||||
|
:picture, :picture_cache, :first_name, :last_name, :public_email,
|
||||||
|
:organisation, :github, :twitter, :mobile_phone, :biography
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue