-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/commands/decidim/anonymous_codes/admin/create_code_group.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module AnonymousCodes | ||
module Admin | ||
class CreateCodeGroup < Decidim::Command | ||
def initialize(form, organization) | ||
@form = form | ||
@organization = organization | ||
end | ||
|
||
def call | ||
return broadcast(:invalid) if @form.invalid? | ||
|
||
transaction do | ||
create_code_group | ||
end | ||
|
||
broadcast(:ok) | ||
end | ||
|
||
private | ||
|
||
attr_reader :code_group, :form | ||
|
||
def create_code_group | ||
@code_group = Decidim.traceability.create!( | ||
Group, | ||
@form.current_user, | ||
title: form.title, | ||
expires_at: form.expires_at, | ||
active: form.active, | ||
max_reuses: form.max_reuses, | ||
organization: @organization | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters