tramway-event 1.5.4 → 1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/decorators/tramway/event/participant_decorator.rb +33 -1
- data/app/decorators/tramway/event/participant_form_field_decorator.rb +8 -0
- data/app/forms/tramway/event/participant_extended_form_creator.rb +6 -2
- data/app/forms/tramway/event/participant_form.rb +7 -1
- data/app/models/tramway/event/participant.rb +36 -0
- data/config/locales/models.yml +11 -0
- data/config/locales/state_machines.yml +22 -0
- data/lib/tramway/event/generators/install_generator.rb +2 -1
- data/lib/tramway/event/generators/templates/add_more_fields_to_tramway_event_participants.rb +6 -0
- data/lib/tramway/event/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 356196b9484317b81ca8f71c892e190739f6090c286615bf8307abec599e78a3
|
|
4
|
+
data.tar.gz: 2db8e0ac6a5c1245d2e741cfef9ed402b4564c5766fb48cac6d3ac663010110d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c86f930b2320a99ed8b71e4d83e0cfcd0845541147821156106d0e94178c361312e748cdc92ad2fc1c27e8007ba3af9bfffdc906d5e034f5e58ff9b6d4666dd2
|
|
7
|
+
data.tar.gz: 600f8c199396e7d7edbfafe059283db44483da6f5b5bdb939c31b29515178db4ed92d0ff413ca52d9bf5b6be22baf08e152eb8dae79115608286e688f97cf4f3
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorator
|
|
2
2
|
class << self
|
|
3
3
|
def collections
|
|
4
|
-
[ :all ]
|
|
4
|
+
[ :requested, :waiting, :prev_approved, :without_answer, :approved, :rejected, :all ]
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def list_attributes
|
|
8
|
+
[:list_fields]
|
|
5
9
|
end
|
|
6
10
|
end
|
|
7
11
|
|
|
@@ -16,6 +20,23 @@ class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorat
|
|
|
16
20
|
end
|
|
17
21
|
end
|
|
18
22
|
|
|
23
|
+
def list_fields
|
|
24
|
+
content_tag :table, class: :table do
|
|
25
|
+
object.event.participant_form_fields.map do |field|
|
|
26
|
+
if field.options['list_field'] == 'true'
|
|
27
|
+
concat(content_tag(:tr) do
|
|
28
|
+
concat(content_tag(:td) do
|
|
29
|
+
field.title
|
|
30
|
+
end)
|
|
31
|
+
concat(content_tag(:td) do
|
|
32
|
+
object.values[field.title]
|
|
33
|
+
end)
|
|
34
|
+
end)
|
|
35
|
+
end
|
|
36
|
+
end.compact
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
19
40
|
def values
|
|
20
41
|
content_tag :table, class: :table do
|
|
21
42
|
object.values&.each do |key, value|
|
|
@@ -30,4 +51,15 @@ class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorat
|
|
|
30
51
|
end
|
|
31
52
|
end
|
|
32
53
|
end
|
|
54
|
+
|
|
55
|
+
def participation_state_button_color(event)
|
|
56
|
+
case event
|
|
57
|
+
when :previous_approve, :approve
|
|
58
|
+
:success
|
|
59
|
+
when :wait_for_decision, :not_got_answer
|
|
60
|
+
:warning
|
|
61
|
+
when :reject
|
|
62
|
+
:danger
|
|
63
|
+
end
|
|
64
|
+
end
|
|
33
65
|
end
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
class Tramway::Event::ParticipantExtendedFormCreator < Tramway::Core::FormCreator
|
|
2
|
-
def self.create_form_class(uuid, event)
|
|
2
|
+
def self.create_form_class(uuid, event, **simple_properties)
|
|
3
3
|
class_name = "ParticipantExtendedForm#{uuid.gsub('-', '')}"
|
|
4
4
|
properties = event.participant_form_fields.inputs_list.reduce({}) do |hash, field|
|
|
5
5
|
hash.merge! field.title.to_sym => field
|
|
6
6
|
end
|
|
7
|
-
|
|
7
|
+
if simple_properties.keys.any?
|
|
8
|
+
::Tramway::Core::ExtendableForm.new(class_name, simple_properties: simple_properties, **properties)
|
|
9
|
+
else
|
|
10
|
+
::Tramway::Core::ExtendableForm.new(class_name, **properties)
|
|
11
|
+
end
|
|
8
12
|
end
|
|
9
13
|
end
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
require 'securerandom'
|
|
2
2
|
|
|
3
3
|
class Tramway::Event::ParticipantForm < ::Tramway::Core::ApplicationForm
|
|
4
|
+
properties :participation_state, :comment
|
|
4
5
|
association :event
|
|
5
6
|
|
|
6
7
|
def self.new(object)
|
|
7
8
|
if object.event_id.present?
|
|
8
|
-
::Tramway::Event::ParticipantExtendedFormCreator.create_form_class(
|
|
9
|
+
::Tramway::Event::ParticipantExtendedFormCreator.create_form_class(
|
|
10
|
+
SecureRandom.hex,
|
|
11
|
+
object.event,
|
|
12
|
+
comment: :string,
|
|
13
|
+
participation_state: :string
|
|
14
|
+
).new object
|
|
9
15
|
else
|
|
10
16
|
super(object).tap do |obj|
|
|
11
17
|
obj.form_properties event: :association
|
|
@@ -1,3 +1,39 @@
|
|
|
1
1
|
class Tramway::Event::Participant < ::Tramway::Event::ApplicationRecord
|
|
2
2
|
belongs_to :event, class_name: 'Tramway::Event::Event'
|
|
3
|
+
|
|
4
|
+
state_machine :participation_state, initial: :requested do
|
|
5
|
+
state :requested
|
|
6
|
+
state :prev_approved
|
|
7
|
+
state :waiting
|
|
8
|
+
state :rejected
|
|
9
|
+
state :approved
|
|
10
|
+
state :without_answer
|
|
11
|
+
|
|
12
|
+
event :previous_approve do
|
|
13
|
+
transition [ :requested, :without_answer, :waiting ] => :prev_approved
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
event :wait_for_decision do
|
|
17
|
+
transition [ :requested, :without_answer ] => :waiting
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
event :reject do
|
|
21
|
+
transition [ :requested, :without_answer, :waiting ] => :rejected
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
event :approve do
|
|
25
|
+
transition prev_approved: :approved
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
event :not_got_answer do
|
|
29
|
+
transition requested: :without_answer
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
scope :requested, -> { where participation_state: :requested }
|
|
34
|
+
scope :waiting, -> { where participation_state: :waiting }
|
|
35
|
+
scope :prev_approved, -> { where participation_state: :prev_approved }
|
|
36
|
+
scope :rejected, -> { where participation_state: :rejected }
|
|
37
|
+
scope :approved, -> { where participation_state: :approved }
|
|
38
|
+
scope :without_answer, -> { where participation_state: :without_answer }
|
|
3
39
|
end
|
data/config/locales/models.yml
CHANGED
|
@@ -13,6 +13,8 @@ ru:
|
|
|
13
13
|
description: Описание
|
|
14
14
|
begin_date: Дата начала
|
|
15
15
|
end_date: Дата конца
|
|
16
|
+
tramway/event/participant:
|
|
17
|
+
comment: Примечание
|
|
16
18
|
cases:
|
|
17
19
|
tramway/event/event:
|
|
18
20
|
plural: мероприятия
|
|
@@ -32,3 +34,12 @@ ru:
|
|
|
32
34
|
tramway/event/partaking:
|
|
33
35
|
genitive: должность
|
|
34
36
|
plural: должности
|
|
37
|
+
collections:
|
|
38
|
+
tramway/event/participant:
|
|
39
|
+
requested: Необработанные
|
|
40
|
+
prev_approved: Предварительно подтверждены
|
|
41
|
+
waiting: Ожидаем ответа
|
|
42
|
+
rejected: Отклонены
|
|
43
|
+
approved: Окончательно подтверждены
|
|
44
|
+
without_answer: Не ответили
|
|
45
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
ru:
|
|
2
|
+
collections:
|
|
3
|
+
tramway/event/participant:
|
|
4
|
+
published: Опубликованные
|
|
5
|
+
hidden: Скрытые
|
|
6
|
+
activerecord:
|
|
7
|
+
state_machines:
|
|
8
|
+
tramway/event/participant:
|
|
9
|
+
participation_state:
|
|
10
|
+
states:
|
|
11
|
+
requested: Заявка отправлена
|
|
12
|
+
prev_approved: Получено предварительное подтверждение
|
|
13
|
+
waiting: Ожидание решения
|
|
14
|
+
rejected: Заявка отклонена
|
|
15
|
+
approved: Окончательное подтверждение
|
|
16
|
+
without_answer: Без ответа
|
|
17
|
+
events:
|
|
18
|
+
previous_approve: Предварительно подтвердить
|
|
19
|
+
wait_for_decision: Ожидать ответа
|
|
20
|
+
reject: Отклонить
|
|
21
|
+
approve: Окончательно подтвердить
|
|
22
|
+
not_got_answer: Связаться не удалось
|
|
@@ -33,7 +33,8 @@ module Tramway::Event::Generators
|
|
|
33
33
|
:rename_tramway_event_people_sections_to_tramway_event_partakings,
|
|
34
34
|
|
|
35
35
|
:add_position_to_tramway_event_partakings,
|
|
36
|
-
:add_state_to_tramway_event_partakings
|
|
36
|
+
:add_state_to_tramway_event_partakings,
|
|
37
|
+
:add_more_fields_to_tramway_event_participants
|
|
37
38
|
]
|
|
38
39
|
migrations.each do |migration|
|
|
39
40
|
migration_template "#{migration}.rb", "db/migrate/#{migration}.rb"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tramway-event
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: '1.6'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pavel Kalashnikov
|
|
@@ -61,12 +61,14 @@ files:
|
|
|
61
61
|
- config/initializers/tramway.rb
|
|
62
62
|
- config/locales/models.yml
|
|
63
63
|
- config/locales/ru.yml
|
|
64
|
+
- config/locales/state_machines.yml
|
|
64
65
|
- config/routes.rb
|
|
65
66
|
- lib/tasks/tramway/event_tasks.rake
|
|
66
67
|
- lib/tramway/event.rb
|
|
67
68
|
- lib/tramway/event/engine.rb
|
|
68
69
|
- lib/tramway/event/generators/install_generator.rb
|
|
69
70
|
- lib/tramway/event/generators/templates/add_icon_to_tramway_event_sections.rb
|
|
71
|
+
- lib/tramway/event/generators/templates/add_more_fields_to_tramway_event_participants.rb
|
|
70
72
|
- lib/tramway/event/generators/templates/add_options_to_tramway_event_participant_form_fields.rb
|
|
71
73
|
- lib/tramway/event/generators/templates/add_photo_to_tramway_event_events.rb
|
|
72
74
|
- lib/tramway/event/generators/templates/add_position_to_tramway_event_partakings.rb
|