Class: Decidim::Meetings::MeetingsController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Meetings::MeetingsController
- Includes:
- Filterable, FilterResource, Flaggable, FormFactory, Paginable, Withdrawable
- Defined in:
- app/controllers/decidim/meetings/meetings_controller.rb
Overview
Exposes the meeting resource so users can view them
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #withdraw ⇒ Object
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 25 def create :create, :meeting @form = meeting_form.from_params(params, current_component: current_component) CreateMeeting.call(@form) do on(:ok) do |meeting| flash[:notice] = I18n.t("meetings.create.success", scope: "decidim.meetings") redirect_to meeting_path(meeting) end on(:invalid) do flash.now[:alert] = I18n.t("meetings.create.invalid", scope: "decidim.meetings") render action: "new" end end end |
#edit ⇒ Object
65 66 67 68 69 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 65 def edit :update, :meeting, meeting: meeting @form = meeting_form.from_model(meeting) end |
#index ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 43 def index return unless search.results.blank? && params.dig("filter", "date") != %w(past) @past_meetings = search_klass.new(search_params.merge(date: %w(past))) if @past_meetings.results.present? params[:filter] ||= {} params[:filter][:date] = %w(past) @forced_past_meetings = true @search = @past_meetings end end |
#new ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 19 def new :create, :meeting @form = meeting_form.instance end |
#show ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 56 def show raise ActionController::RoutingError, "Not Found" unless meeting return if meeting.current_user_can_visit_meeting?(current_user) flash[:alert] = I18n.t("meeting.not_allowed", scope: "decidim.meetings") redirect_to(ResourceLocatorPresenter.new(meeting).index) end |
#update ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 71 def update :update, :meeting, meeting: meeting @form = meeting_form.from_params(params) UpdateMeeting.call(@form, current_user, meeting) do on(:ok) do |meeting| flash[:notice] = I18n.t("meetings.update.success", scope: "decidim.meetings") redirect_to Decidim::ResourceLocatorPresenter.new(meeting).path end on(:invalid) do flash.now[:alert] = I18n.t("meetings.update.invalid", scope: "decidim.meetings") render :edit end end end |
#withdraw ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 89 def withdraw :withdraw, :meeting, meeting: meeting WithdrawMeeting.call(@meeting, current_user) do on(:ok) do flash[:notice] = I18n.t("meetings.withdraw.success", scope: "decidim") redirect_to Decidim::ResourceLocatorPresenter.new(@meeting).path end on(:invalid) do flash[:alert] = I18n.t("meetings.withdraw.error", scope: "decidim") redirect_to Decidim::ResourceLocatorPresenter.new(@meeting).path end end end |