16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb', line 16
def create
enforce_permission_to :create, UserProcessor
@userlist = params[:userlist]
processor = UserProcessor.new(current_organization, current_user)
processor.emails = @userlist
processor.authorization_handler = params[:authorization_handler] if params[:authorization_handler]
if params[:register]
processor.register_users
flash[:warning] = t(".registered", count: processor.emails.count,
registered: processor.processed[:registered].count,
errors: processor.errors[:registered].count)
end
if params[:authorize] == "in"
processor.authorize_users
flash[:notice] = t(".authorized", handler: t("#{processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
count: processor.emails.count,
authorized: processor.processed[:authorized].count,
errors: processor.errors[:authorized].count)
elsif params[:authorize] == "out"
processor.revoke_users
flash[:notice] = t(".revoked", handler: t("#{processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
count: processor.emails.count,
revoked: processor.processed[:revoked].count,
errors: processor.errors[:revoked].count)
else
flash[:info] = t(".info", handler: t("#{processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
count: processor.emails.count,
authorized: processor.total(:authorized),
unconfirmed: processor.total(:unconfirmed),
registered: processor.total(:registered))
render(action: :index) && return
end
redirect_to direct_verifications_path
end
|