Class: Decidim::Meetings::MeetingsController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Meetings::MeetingsController
- Includes:
- AttachmentsHelper, ComponentFilterable, SanitizeHelper, 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
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 31 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", status: :unprocessable_entity end end end |
#edit ⇒ Object
72 73 74 75 76 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 72 def edit (:update, :meeting, meeting:) @form = meeting_form.from_model(meeting) end |
#index ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 49 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
25 26 27 28 29 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 25 def new :create, :meeting @form = meeting_form.instance end |
#show ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 62 def show raise ActionController::RoutingError, "Not Found" unless meeting (:read, :meeting, meeting:) maybe_show_redirect_notice! return if meeting.current_user_can_visit_meeting?(current_user) end |
#update ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 78 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, status: :unprocessable_entity end end end |
#withdraw ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/controllers/decidim/meetings/meetings_controller.rb', line 96 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 |