class Decidim::Meetings::Admin::MeetingsController
This controller allows an admin to manage meetings from a Participatory Process
def blank_service
def blank_service @blank_service ||= Admin::MeetingServiceForm.new end
def create
def create enforce_permission_to :create, :meeting @form = meeting_form.from_params(params, current_component: current_component) Decidim::Meetings::Admin::CreateMeeting.call(@form) do on(:ok) do flash[:notice] = I18n.t("meetings.create.success", scope: "decidim.meetings.admin") redirect_to meetings_path end on(:invalid) do flash.now[:alert] = I18n.t("meetings.create.invalid", scope: "decidim.meetings.admin") render action: "new" end end end
def destroy
def destroy enforce_permission_to :destroy, :meeting, meeting: meeting Decidim::Meetings::Admin::DestroyMeeting.call(meeting, current_user) do on(:ok) do flash[:notice] = I18n.t("meetings.destroy.success", scope: "decidim.meetings.admin") redirect_to meetings_path end on(:invalid) do |proposals_count| flash.now[:alert] = I18n.t( "meetings.destroy.invalid.proposals_count", count: proposals_count, scope: "decidim.meetings.admin" ) render action: "index" end end end
def edit
def edit enforce_permission_to :update, :meeting, meeting: meeting @form = meeting_form.from_model(meeting) end
def meeting_form
def meeting_form form(Decidim::Meetings::Admin::MeetingForm) end
def new
def new enforce_permission_to :create, :meeting @form = meeting_form.instance end
def update
def update enforce_permission_to :update, :meeting, meeting: meeting @form = meeting_form.from_params(params, current_component: current_component) Decidim::Meetings::Admin::UpdateMeeting.call(@form, meeting) do on(:ok) do flash[:notice] = I18n.t("meetings.update.success", scope: "decidim.meetings.admin") redirect_to meetings_path end on(:invalid) do flash.now[:alert] = I18n.t("meetings.update.invalid", scope: "decidim.meetings.admin") render action: "edit" end end end