diff --git a/app/assets/stylesheets/petitions/admin/_list.scss b/app/assets/stylesheets/petitions/admin/_list.scss
index ab89c23e8..7a2fbd7e2 100644
--- a/app/assets/stylesheets/petitions/admin/_list.scss
+++ b/app/assets/stylesheets/petitions/admin/_list.scss
@@ -31,11 +31,11 @@
padding-right: $gutter;
}
- .creator {
+ .creator, .rejection {
text-align: left;
}
- .petition-id, .state, .tags {
+ .petition-id, .state, .notes, .tags {
text-align: center;
}
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
index 340991418..308632a09 100644
--- a/app/helpers/admin_helper.rb
+++ b/app/helpers/admin_helper.rb
@@ -147,6 +147,18 @@ def back_link
end
end
+ def show_closing_column?(scope)
+ scope.in?(%i[open closed])
+ end
+
+ def show_rejection_column?(scope)
+ scope.in?(%i[rejected hidden])
+ end
+
+ def short_rejection_reason(rejection)
+ t(rejection.code, scope: :"rejection.reasons.short", default: rejection.code.titleize)
+ end
+
private
def admin_petition_facets
diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb
index 34ccc7e68..6d26a347f 100644
--- a/app/helpers/tags_helper.rb
+++ b/app/helpers/tags_helper.rb
@@ -1,20 +1,4 @@
module TagsHelper
- SHOW_TAGS_COLUMN = %i[
- collecting_sponsors
- flagged
- dormant
- in_moderation
- recently_in_moderation
- nearly_overdue_in_moderation
- overdue_in_moderation
- tagged_in_moderation
- untagged_in_moderation
- ]
-
- def show_tags_column?(scope)
- scope.in?(SHOW_TAGS_COLUMN)
- end
-
def tag_names(tags)
tags.each_with_object([]) do |tag, names|
if name = tag_mapping[tag]
diff --git a/app/views/admin/petitions/index.html.erb b/app/views/admin/petitions/index.html.erb
index ba2d6f3de..28a6eabc4 100644
--- a/app/views/admin/petitions/index.html.erb
+++ b/app/views/admin/petitions/index.html.erb
@@ -82,11 +82,14 @@
Creator |
ID |
State |
- <% if show_tags_column?(@petitions.scope) %>
- Tags |
- <% else %>
+ Notes |
+ Tags |
+ <% if show_closing_column?(@petitions.scope) %>
Closing |
<% end %>
+ <% if show_rejection_column?(@petitions.scope) %>
+ Reason |
+ <% end %>
Signatures |
@@ -103,11 +106,14 @@
<%= petition.id %> |
<%= petition.state.humanize %> |
- <% if show_tags_column?(@petitions.scope) %>
- <%= tag_names(petition.tags) %> |
- <% else %>
+ <%= petition.notes? ? "Yes" : " " %> |
+ <%= tag_names(petition.tags) %> |
+ <% if show_closing_column?(@petitions.scope) %>
<%= date_format(petition.closing) || "–" %> |
<% end %>
+ <% if show_rejection_column?(@petitions.scope) %>
+ <%= short_rejection_reason(petition.rejection) %> |
+ <% end %>
<%= number_with_delimiter(petition.signature_count) %> |
<% end -%>
diff --git a/config/locales/rejections.en-GB.yml b/config/locales/rejections.en-GB.yml
new file mode 100644
index 000000000..c5d603731
--- /dev/null
+++ b/config/locales/rejections.en-GB.yml
@@ -0,0 +1,22 @@
+en-GB:
+ rejection:
+ reasons:
+ short:
+ duplicate: "Duplicate"
+ irrelevant: "Irrelevant"
+ no-action: "No Action"
+ honours: "Honours"
+ fake-name: "Fake Name"
+ foi: "FOI"
+ libellous: "Libellous"
+ offensive: "Offensive"
+ advert: "Advert"
+ removed: "Removed"
+ already-happening: "Already Happening"
+ no-reply: "No Reply"
+ individual: "Individual"
+ personal: "Personal"
+ fraudulent: "Fraudulent"
+ operational: "Operational"
+ local: "Local"
+ joke: "Joke"
diff --git a/spec/factories.rb b/spec/factories.rb
index 73e56b37e..4627ccd40 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -502,6 +502,18 @@
factory :hidden_petition, :parent => :petition do
state { Petition::HIDDEN_STATE }
+
+ transient do
+ rejection_code { "libellous" }
+ rejection_details { nil }
+ end
+
+ after(:create) do |petition, evaluator|
+ petition.create_rejection! do |r|
+ r.code = evaluator.rejection_code
+ r.details = evaluator.rejection_details
+ end
+ end
end
factory :awaiting_petition, :parent => :open_petition do