decidim-forms 0.32.0.rc3 → 0.32.0
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/commands/decidim/forms/response_questionnaire.rb +2 -2
- data/app/forms/decidim/forms/response_form.rb +7 -7
- data/app/views/decidim/forms/questionnaires/responses/_files.html.erb +1 -1
- data/db/data/20260616144141_rename_answers_to_responses.rb +31 -0
- data/decidim-forms.gemspec +1 -1
- data/lib/decidim/forms/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6bd2c37058ba73460d662340f286b2dec69806089caa1ee7923dade4622f6bc
|
|
4
|
+
data.tar.gz: 6e809eb44fc74c48d0d1e4744e6b4f72eb3146afca513ec7b8da6193b2915a61
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa7812ad1aa5f08075d55cbdd5566d25b98a3b7be6dabcad3fb5cfeb712d24aa7ccfb2e37136d31fd009dc0505bac5432e88e52897bcaeb483444166c8af31db
|
|
7
|
+
data.tar.gz: 2adb1b200d18ce7d57b1847fe394a9d97999e0b0034c4b5976db118b457211628700290756c110f2e6083f9bf479aa15ee4a347dd1a63aed390c24fadac652f8
|
|
@@ -59,7 +59,7 @@ module Decidim
|
|
|
59
59
|
# of this problem.
|
|
60
60
|
def reset_form_attachments
|
|
61
61
|
@form.responses.each do |response|
|
|
62
|
-
response.errors.add(:
|
|
62
|
+
response.errors.add(:add_attachments, :needs_to_be_reattached) if response.has_attachments? || response.has_error_in_attachments?
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -116,7 +116,7 @@ module Decidim
|
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
create_attachments if process_attachments?
|
|
119
|
-
|
|
119
|
+
attachment_cleanup!
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
@form = @main_form
|
|
@@ -12,7 +12,7 @@ module Decidim
|
|
|
12
12
|
attribute :choices, Array[ResponseChoiceForm]
|
|
13
13
|
attribute :matrix_choices, Array[ResponseChoiceForm]
|
|
14
14
|
|
|
15
|
-
attachments_attribute :
|
|
15
|
+
attachments_attribute :attachments
|
|
16
16
|
|
|
17
17
|
validates :body, presence: true, if: :mandatory_body?
|
|
18
18
|
validates :selected_choices, presence: true, if: :mandatory_choices?
|
|
@@ -20,7 +20,7 @@ module Decidim
|
|
|
20
20
|
validate :max_choices, if: -> { question.max_choices }
|
|
21
21
|
validate :all_choices, if: :sorting?
|
|
22
22
|
validate :min_choices, if: -> { question.matrix? && question.mandatory? }
|
|
23
|
-
validate :
|
|
23
|
+
validate :attachments_present, if: -> { question.question_type == "files" && question.mandatory? }
|
|
24
24
|
validate :max_characters, if: -> { question.max_characters.positive? }
|
|
25
25
|
|
|
26
26
|
delegate :mandatory_body?, :mandatory_choices?, :matrix?, to: :question
|
|
@@ -44,7 +44,7 @@ module Decidim
|
|
|
44
44
|
def map_model(model)
|
|
45
45
|
self.question_id = model.decidim_question_id
|
|
46
46
|
self.question = model.question
|
|
47
|
-
self.
|
|
47
|
+
self.attachments = model.attachments
|
|
48
48
|
|
|
49
49
|
self.choices = model.choices.map do |choice|
|
|
50
50
|
ResponseChoiceForm.from_model(choice)
|
|
@@ -82,11 +82,11 @@ module Decidim
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
def has_attachments?
|
|
85
|
-
question.has_attachments? && errors[:
|
|
85
|
+
question.has_attachments? && errors[:add_attachments].empty? && add_attachments.present?
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def has_error_in_attachments?
|
|
89
|
-
errors[:
|
|
89
|
+
errors[:add_attachments].present?
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def sorting?
|
|
@@ -141,8 +141,8 @@ module Decidim
|
|
|
141
141
|
I18n.t("questionnaires.question.max_choices", scope: "decidim.forms", n: question.max_choices)
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
def
|
|
145
|
-
errors.add(:
|
|
144
|
+
def attachments_present
|
|
145
|
+
errors.add(:add_attachments, :blank) if add_attachments.empty? && errors[:add_attachments].empty?
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= response_form.upload :
|
|
1
|
+
<%= response_form.upload :add_attachments, attachments: response.attachments, label: false, multiple: true, id: field_id, disabled:, button_class: "button button__lg button__transparent-secondary w-full" %>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RenameAnswersToResponses < ActiveRecord::Migration[7.2]
|
|
4
|
+
class Attachment < ApplicationRecord
|
|
5
|
+
self.table_name = "decidim_attachments"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class ActionLog < ApplicationRecord
|
|
9
|
+
self.table_name = "decidim_action_logs"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Version < ApplicationRecord
|
|
13
|
+
self.table_name = "versions"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def up
|
|
17
|
+
# rubocop:disable Rails/SkipsModelValidations
|
|
18
|
+
Attachment.where(attached_to_type: "Decidim::Forms::Answer").update_all(attached_to_type: "Decidim::Forms::Response")
|
|
19
|
+
ActionLog.where(resource_type: "Decidim::Forms::Answer").update_all(resource_type: "Decidim::Forms::Response")
|
|
20
|
+
Version.where(item_type: "Decidim::Forms::Answer").update_all(item_type: "Decidim::Forms::Response")
|
|
21
|
+
# rubocop:enable Rails/SkipsModelValidations
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def down
|
|
25
|
+
# rubocop:disable Rails/SkipsModelValidations
|
|
26
|
+
Attachment.where(attached_to_type: "Decidim::Forms::Response").update_all(attached_to_type: "Decidim::Forms::Answer")
|
|
27
|
+
ActionLog.where(resource_type: "Decidim::Forms::Response").update_all(resource_type: "Decidim::Forms::Answer")
|
|
28
|
+
Version.where(item_type: "Decidim::Forms::Response").update_all(item_type: "Decidim::Forms::Answer")
|
|
29
|
+
# rubocop:enable Rails/SkipsModelValidations
|
|
30
|
+
end
|
|
31
|
+
end
|
data/decidim-forms.gemspec
CHANGED
|
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path("lib", __dir__)
|
|
|
4
4
|
|
|
5
5
|
# Describe your gem and declare its dependencies:
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
|
-
version = "0.32.0
|
|
7
|
+
version = "0.32.0"
|
|
8
8
|
s.version = version
|
|
9
9
|
s.authors = ["Josep Jaume Rey Peroy", "Marc Riera Casals", "Oriol Gual Oliva", "Rubén González Valero"]
|
|
10
10
|
s.email = ["josepjaume@gmail.com", "mrc2407@gmail.com", "oriolgual@gmail.com", "rbngzlv@gmail.com"]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decidim-forms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.32.0
|
|
4
|
+
version: 0.32.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josep Jaume Rey Peroy
|
|
@@ -18,42 +18,42 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - '='
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 0.32.0
|
|
21
|
+
version: 0.32.0
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - '='
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 0.32.0
|
|
28
|
+
version: 0.32.0
|
|
29
29
|
- !ruby/object:Gem::Dependency
|
|
30
30
|
name: decidim-admin
|
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
|
32
32
|
requirements:
|
|
33
33
|
- - '='
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: 0.32.0
|
|
35
|
+
version: 0.32.0
|
|
36
36
|
type: :development
|
|
37
37
|
prerelease: false
|
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
39
39
|
requirements:
|
|
40
40
|
- - '='
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: 0.32.0
|
|
42
|
+
version: 0.32.0
|
|
43
43
|
- !ruby/object:Gem::Dependency
|
|
44
44
|
name: decidim-dev
|
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
|
46
46
|
requirements:
|
|
47
47
|
- - '='
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: 0.32.0
|
|
49
|
+
version: 0.32.0
|
|
50
50
|
type: :development
|
|
51
51
|
prerelease: false
|
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
|
54
54
|
- - '='
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: 0.32.0
|
|
56
|
+
version: 0.32.0
|
|
57
57
|
description: A forms gem for decidim.
|
|
58
58
|
email:
|
|
59
59
|
- josepjaume@gmail.com
|
|
@@ -243,6 +243,7 @@ files:
|
|
|
243
243
|
- config/locales/vi.yml
|
|
244
244
|
- config/locales/zh-CN.yml
|
|
245
245
|
- config/locales/zh-TW.yml
|
|
246
|
+
- db/data/20260616144141_rename_answers_to_responses.rb
|
|
246
247
|
- db/migrate/20170511092231_create_decidim_forms_questionnaires.rb
|
|
247
248
|
- db/migrate/20170515090916_create_decidim_forms_questions.rb
|
|
248
249
|
- db/migrate/20170515144119_create_decidim_forms_answers.rb
|