Class: Decidim::System::OrganizationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Decidim::System::OrganizationsController
- Defined in:
- decidim-system/app/controllers/decidim/system/organizations_controller.rb
Overview
Controller to manage Organizations (tenants).
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #resend_invitation ⇒ Object
- #update ⇒ Object
Methods included from Headers::HttpCachingDisabler
Methods included from TranslatableAttributes
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 16 def create @form = form(RegisterOrganizationForm).from_params(params) CreateOrganization.call(@form) do on(:ok) do flash[:notice] = t("organizations.create.success_html", scope: "decidim.system", host: @form.host, email: @form.organization_admin_email) redirect_to organizations_path end on(:invalid_invitation) do flash.now[:alert] = t("organizations.create.error_invitation", scope: "decidim.system") render :new end on(:invalid) do flash.now[:alert] = t("organizations.create.error", scope: "decidim.system") render :new end end end |
#edit ⇒ Object
41 42 43 44 |
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 41 def edit @organization = Organization.find(params[:id]) @form = form(UpdateOrganizationForm).from_model(@organization) end |
#index ⇒ Object
37 38 39 |
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 37 def index @organizations = Organization.all end |
#new ⇒ Object
11 12 13 14 |
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 11 def new @form = form(RegisterOrganizationForm).from_params(default_params) @form.file_upload_settings = form(FileUploadSettingsForm).from_model({}) end |
#resend_invitation ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 63 def resend_invitation organization = Organization.find(params[:id]) InviteUserAgain.call(organization.users.first, "invite_admin") do on(:ok) do flash[:notice] = t("organizations.resend_invitation.success", scope: "decidim.system") end on(:invalid) do flash[:alert] = I18n.t("organizations.resend_invitation.error", scope: "decidim.system") end end redirect_to organizations_path end |
#update ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 46 def update @organization = Organization.find(params[:id]) @form = form(UpdateOrganizationForm).from_params(params) UpdateOrganization.call(params[:id], @form) do on(:ok) do flash[:notice] = t("organizations.update.success", scope: "decidim.system") redirect_to organizations_path end on(:invalid) do flash.now[:alert] = I18n.t("organizations.update.error", scope: "decidim.system") render :edit end end end |