diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 58dd170..67f8dd4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,12 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_filter :configure_permitted_parameters, if: :devise_controller? 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={}) if I18n.locale != I18n.default_locale @@ -21,6 +27,11 @@ class ApplicationController < ActionController::Base I18n.locale = params[:locale] || I18n.default_locale 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 def configure_permitted_parameters diff --git a/app/controllers/public/application_controller.rb b/app/controllers/public/application_controller.rb new file mode 100644 index 0000000..a1958df --- /dev/null +++ b/app/controllers/public/application_controller.rb @@ -0,0 +1,6 @@ +module Public + class ApplicationController < ::ApplicationController + include ::CurrentConferenceAssigning + before_filter :require_current_conference! + end +end diff --git a/app/controllers/public/events_controller.rb b/app/controllers/public/events_controller.rb new file mode 100644 index 0000000..0142e1e --- /dev/null +++ b/app/controllers/public/events_controller.rb @@ -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 diff --git a/app/controllers/public/personal_profiles_controller.rb b/app/controllers/public/personal_profiles_controller.rb new file mode 100644 index 0000000..2c0f544 --- /dev/null +++ b/app/controllers/public/personal_profiles_controller.rb @@ -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