Class: Decidim::Kids::UserMinorsController

Inherits:
ApplicationController show all
Includes:
NeedsTutorAuthorization, UserProfile
Defined in:
app/controllers/decidim/kids/user_minors_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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
  enforce_permission_to :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.new_user_minor_authorization_path(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

#destroyObject



65
66
67
68
69
70
71
72
73
74
75
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 65

def destroy
  enforce_permission_to :delete, :minor_accounts, minor_user: minor_user

  DestroyMinorAccount.call(minor_user, ) do
    on(:ok) do
      flash[:notice] = I18n.t("user_minors.destroy.success", scope: "decidim.kids")
    end
  end

  redirect_to user_minors_path
end

#editObject



41
42
43
44
45
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 41

def edit
  enforce_permission_to :edit, :minor_accounts, minor_user: minor_user

  @form = 
end

#indexObject



11
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 11

def index; end

#newObject



17
18
19
20
21
# File 'app/controllers/decidim/kids/user_minors_controller.rb', line 17

def new
  enforce_permission_to :create, :minor_accounts

  @form = form(Decidim::Kids::MinorAccountForm).instance
end

#resend_invitation_to_minorObject



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

#unverifiedObject



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

#updateObject



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
  enforce_permission_to :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