Class: Decidim::Kids::UserMinorsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Decidim::Kids::UserMinorsController
- Includes:
- NeedsTutorAuthorization, UserProfile
- Defined in:
- app/controllers/decidim/kids/user_minors_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #resend_invitation_to_minor ⇒ Object
- #unverified ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 23 def create :create, :minor_accounts @form = form(Decidim::Kids::MinorAccountForm).from_params(params) CreateMinorAccount.call(@form, current_user) do on(:ok) do |minor_user| flash[:notice] = I18n.t("user_minors.create.success", scope: "decidim.kids") redirect_to decidim_kids.(user_minor_id: minor_user.id) end on(:invalid) do flash.now[:alert] = I18n.t("user_minors.create.error", scope: "decidim.kids") render :new end end end |
#destroy ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 65 def destroy :delete, :minor_accounts, minor_user: minor_user DestroyMinorAccount.call(minor_user, minor_account) do on(:ok) do flash[:notice] = I18n.t("user_minors.destroy.success", scope: "decidim.kids") end end redirect_to user_minors_path end |
#edit ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 41 def edit :edit, :minor_accounts, minor_user: minor_user @form = minor_account_form end |
#index ⇒ Object
11 |
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 11 def index; end |
#new ⇒ Object
17 18 19 20 21 |
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 17 def new :create, :minor_accounts @form = form(Decidim::Kids::MinorAccountForm).instance end |
#resend_invitation_to_minor ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 77 def resend_invitation_to_minor Decidim::InviteUserAgain.call(minor_user, "invite_minor") do on(:ok) do flash[:notice] = I18n.t("user_minors.resend.success", scope: "decidim.kids") end end redirect_to user_minors_path end |
#unverified ⇒ Object
13 14 15 |
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 13 def unverified redirect_to user_minors_path if tutor_verified? end |
#update ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 47 def update :edit, :minor_accounts, minor_user: minor_user @form = form(Decidim::Kids::MinorAccountForm).from_params(params) UpdateMinorAccount.call(@form, minor_user) do on(:ok) do flash[:notice] = I18n.t("user_minors.update.success", scope: "decidim.kids") redirect_to user_minors_path end on(:invalid) do flash.now[:alert] = I18n.t("user_minors.update.error", scope: "decidim.kids") render :edit end end end |