Class: Decidim::Meetings::MeetingsController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Meetings::MeetingsController
- Includes:
- AttachmentsHelper, ComponentFilterable, 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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 28 def create :create, :meeting @form = meeting_form.from_params(params, 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
68 69 70 71 72 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 68 def edit (:update, :meeting, meeting:) @form = meeting_form.from_model(meeting) end |
#index ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 46 def index return unless search.result.blank? && params.dig("filter", "date") != %w(past) @past_meetings ||= search_with(filter_params.merge(with_any_date: %w(past))) if @past_meetings.result.present? params[:filter] ||= {} params[:filter][:with_any_date] = %w(past) @forced_past_meetings = true @search = @past_meetings end end |
#new ⇒ Object
22 23 24 25 26 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 22 def new :create, :meeting @form = meeting_form.instance end |
#show ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 59 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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 74 def update (:update, :meeting, meeting:) @form = meeting_form.from_params(params) UpdateMeeting.call(@form, 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
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 92 def withdraw (:withdraw, :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 |