Skip to content

Commit be09128

Browse files
authored
Revert "Archive Debates (decidim#6940)" (decidim#7214)
1 parent 8cda163 commit be09128

File tree

17 files changed

+66
-339
lines changed

17 files changed

+66
-339
lines changed

decidim-debates/app/commands/decidim/debates/admin/archive_debate.rb

Lines changed: 0 additions & 50 deletions
This file was deleted.

decidim-debates/app/commands/decidim/debates/admin/close_debate.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def close_debate
3737
) do
3838
form.debate.update!(
3939
conclusions: form.conclusions,
40-
closed_at: form.closed_at,
41-
archived_at: (Time.zone.now if form.archive)
40+
closed_at: form.closed_at
4241
)
4342
end
4443

decidim-debates/app/controllers/decidim/debates/admin/debates_controller.rb

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,6 @@ def update
6161
end
6262
end
6363

64-
def archive
65-
enforce_permission_to :archive, :debate, debate: debate
66-
67-
archive = params[:archive] == "true"
68-
69-
ArchiveDebate.call(archive, debate, current_user) do
70-
on(:ok) do
71-
flash[:notice] = I18n.t("debates.#{archive ? "archive" : "unarchive"}.success", scope: "decidim.debates.admin")
72-
redirect_to debates_path(archive ? {} : { filter: "archive" })
73-
end
74-
75-
on(:invalid) do
76-
flash.now[:alert] = I18n.t("debates.#{archive ? "archive" : "unarchive"}.invalid", scope: "decidim.debates.admin")
77-
redirect_to debates_path(archive ? {} : { filter: "archive" })
78-
end
79-
end
80-
end
81-
8264
def destroy
8365
enforce_permission_to :delete, :debate, debate: debate
8466

@@ -92,19 +74,11 @@ def destroy
9274
private
9375

9476
def debates
95-
@debates ||= archive? ? all_debates.archived : all_debates.not_archived
77+
@debates ||= Debate.where(component: current_component)
9678
end
9779

9880
def debate
99-
@debate ||= all_debates.find(params[:id])
100-
end
101-
102-
def all_debates
103-
Debate.where(component: current_component)
104-
end
105-
106-
def archive?
107-
params[:filter] == "archive"
81+
@debate ||= debates.find(params[:id])
10882
end
10983
end
11084
end

decidim-debates/app/forms/decidim/debates/admin/close_debate_form.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class CloseDebateForm < Decidim::Form
1515
end
1616

1717
attribute :debate, Debate
18-
attribute :archive, Boolean
1918

2019
validates :debate, presence: true
2120
validate :user_can_close_debate
@@ -24,10 +23,6 @@ def closed_at
2423
debate&.closed_at || Time.current
2524
end
2625

27-
def map_model(model)
28-
self.archive = model.archived_at.present?
29-
end
30-
3126
private
3227

3328
def user_can_close_debate

decidim-debates/app/helpers/decidim/debates/admin/application_helper.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ module Admin
77
#
88
module ApplicationHelper
99
include Decidim::Admin::ResourceScopeHelper
10-
11-
def link_to_filtered_debates
12-
unfiltered = params[:filter].blank?
13-
link_to(
14-
t("actions.#{unfiltered ? "archived" : "active"}", scope: "decidim.debates", name: t("models.debate.name", scope: "decidim.debates.admin")),
15-
debates_path(unfiltered ? { filter: "archive" } : {}),
16-
class: "button tiny button--simple"
17-
)
18-
end
1910
end
2011
end
2112
end

decidim-debates/app/models/decidim/debates/debate.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ class Debate < Debates::ApplicationRecord
4242

4343
scope :open, -> { where(closed_at: nil) }
4444
scope :closed, -> { where.not(closed_at: nil) }
45-
scope :archived, -> { where.not(archived_at: nil) }
46-
scope :not_archived, -> { where(archived_at: nil) }
4745
scope :authored_by, ->(author) { where(author: author) }
4846
scope :commented_by, lambda { |author|
4947
joins(:comments).where(
@@ -98,13 +96,6 @@ def open?
9896
(ama? && open_ama?) || !ama?
9997
end
10098

101-
# Public: Checks if the debate is archived or not.
102-
#
103-
# Returns a boolean.
104-
def archived?
105-
archived_at.present?
106-
end
107-
10899
# Public: Overrides the `commentable?` Commentable concern method.
109100
def commentable?
110101
component.settings.comments_enabled?
@@ -179,13 +170,6 @@ def closeable_by?(user)
179170
authored_by?(user)
180171
end
181172

182-
# Checks whether the user can archive the debate.
183-
#
184-
# user - the user to check for authorship
185-
def archivable_by?(user)
186-
authored_by?(user)
187-
end
188-
189173
# Public: Updates the comments counter cache. We have to do it these
190174
# way in order to properly calculate the counter with hidden
191175
# comments.

decidim-debates/app/permissions/decidim/debates/admin/permissions.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ def permissions
1515
case permission_action.action
1616
when :create, :read, :export
1717
allow!
18-
when :archive
19-
toggle_allow(debate.present?)
2018
when :update
2119
toggle_allow(debate && !debate.closed? && debate.official?)
2220
when :delete, :close

decidim-debates/app/views/decidim/debates/admin/debate_closes/edit.html.erb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
<%= f.translated :editor, :conclusions, autofocus: true, rows: 15 %>
1010
</div>
1111
</div>
12-
<div class="card-section">
13-
<div class="row column space-top-10">
14-
<%= f.check_box :archive, label: t(".archive") %>
15-
<p class="help-text"><%= t(".archive_help") %></p>
16-
</div>
17-
</div>
1812
</div>
1913

2014
<div class="button--double form-general-submit">

decidim-debates/app/views/decidim/debates/admin/debates/index.html.erb

Lines changed: 50 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,63 @@
44
<%= t(".title") %>
55
<div class="button--title">
66
<%= export_dropdown if allowed_to? :export, :comments %>
7-
<%= link_to_filtered_debates if allowed_to? :read, :debate %>
87
<%= link_to t("actions.new", scope: "decidim.debates", name: t("models.debate.name", scope: "decidim.debates.admin")), new_debate_path, class: "button tiny button--simple" if allowed_to? :create, :debate %>
98
</div>
109
</h2>
1110
</div>
1211

1312
<div class="card-section">
14-
<% if debates.any? %>
15-
<div class="table-scroll">
16-
<table class="table-list">
17-
<thead>
18-
<tr>
19-
<th><%= t("models.debate.fields.title", scope: "decidim.debates") %></th>
20-
<th><%= t("models.debate.fields.start_time", scope: "decidim.debates") %></th>
21-
<th><%= t("models.debate.fields.end_time", scope: "decidim.debates") %></th>
22-
<%= th_resource_scope_label %>
23-
<th class="actions"><%= t("actions.title", scope: "decidim.debates") %></th>
24-
</tr>
25-
</thead>
26-
<tbody>
27-
<% debates.each do |debate| %>
28-
<tr data-id="<%= debate.id %>">
29-
<td>
30-
<%= link_to present(debate).title, resource_locator(debate).path, target: :blank %><br>
31-
</td>
32-
<td>
33-
<% if debate.start_time %>
34-
<%= l debate.start_time, format: :long %>
35-
<% end %>
36-
</td>
37-
<td>
38-
<% if debate.end_time %>
39-
<%= l debate.end_time, format: :long %>
40-
<% end %>
41-
</td>
42-
<%= td_resource_scope_for(debate.scope) %>
43-
<td class="table-list__actions">
44-
<% if allowed_to? :update, :debate, debate: debate %>
45-
<%= icon_link_to "pencil", edit_debate_path(debate), t("actions.edit", scope: "decidim.debates"), class: "action-icon--edit" %>
46-
<% else %>
47-
<span class="action-space icon"></span>
48-
<% end %>
49-
50-
<% if allowed_to? :close, :debate, debate: debate %>
51-
<%= icon_link_to "lock-locked", edit_debate_debate_close_path(debate_id: debate.id, id: debate.id), t("actions.close", scope: "decidim.debates"), class: "action-icon--close #{"action-icon--highlighted" if debate.closed?}" %>
52-
<% else %>
53-
<span class="action-space icon"></span>
54-
<% end %>
13+
<div class="table-scroll">
14+
<table class="table-list">
15+
<thead>
16+
<tr>
17+
<th><%= t("models.debate.fields.title", scope: "decidim.debates") %></th>
18+
<th><%= t("models.debate.fields.start_time", scope: "decidim.debates") %></th>
19+
<th><%= t("models.debate.fields.end_time", scope: "decidim.debates") %></th>
20+
<%= th_resource_scope_label %>
21+
<th class="actions"><%= t("actions.title", scope: "decidim.debates") %></th>
22+
</tr>
23+
</thead>
24+
<tbody>
25+
<% debates.each do |debate| %>
26+
<tr data-id="<%= debate.id %>">
27+
<td>
28+
<%= link_to present(debate).title, resource_locator(debate).path, target: :blank %><br>
29+
</td>
30+
<td>
31+
<% if debate.start_time %>
32+
<%= l debate.start_time, format: :long %>
33+
<% end %>
34+
</td>
35+
<td>
36+
<% if debate.end_time %>
37+
<%= l debate.end_time, format: :long %>
38+
<% end %>
39+
</td>
40+
<%= td_resource_scope_for(debate.scope) %>
41+
<td class="table-list__actions">
42+
<% if allowed_to? :update, :debate, debate: debate %>
43+
<%= icon_link_to "pencil", edit_debate_path(debate), t("actions.edit", scope: "decidim.debates"), class: "action-icon--edit" %>
44+
<% else %>
45+
<span class="action-space icon"></span>
46+
<% end %>
5547

56-
<% if allowed_to? :archive, :debate, debate: debate %>
57-
<%= icon_link_to "folder", archive_debate_path(id: debate.id, archive: !debate.archived?), t("actions.#{ debate.archived? ? "unarchive" : "archive" }", scope: "decidim.debates"), class: "action-icon--archive #{"action-icon--highlighted" if debate.archived?}", method: :post %>
58-
<% else %>
59-
<span class="action-space icon"></span>
60-
<% end %>
48+
<% if allowed_to? :close, :debate, debate: debate %>
49+
<%= icon_link_to "lock-locked", edit_debate_debate_close_path(debate_id: debate.id, id: debate.id), t("actions.close", scope: "decidim.debates"), class: "action-icon--close" %>
50+
<% else %>
51+
<span class="action-space icon"></span>
52+
<% end %>
6153

62-
<% if allowed_to? :delete, :debate, debate: debate %>
63-
<%= icon_link_to "circle-x", debate_path(debate), t("actions.destroy", scope: "decidim.debates"), method: :delete, class: "action-icon--remove", data: { confirm: t("actions.confirm_destroy", scope: "decidim.debates") } %>
64-
<% else %>
65-
<span class="action-space icon"></span>
66-
<% end %>
67-
</td>
68-
</tr>
69-
<% end %>
70-
</tbody>
71-
</table>
72-
</div>
73-
<% else %>
74-
<%= t("debates.empty", scope: "decidim.debates.admin") %>
75-
<% end %>
54+
<% if allowed_to? :delete, :debate, debate: debate %>
55+
<%= icon_link_to "circle-x", debate_path(debate), t("actions.destroy", scope: "decidim.debates"), method: :delete, class: "action-icon--remove", data: { confirm: t("actions.confirm_destroy", scope: "decidim.debates") } %>
56+
<% else %>
57+
<span class="action-space icon"></span>
58+
<% end %>
59+
</td>
60+
</tr>
61+
<% end %>
62+
</tbody>
63+
</table>
64+
</div>
7665
</div>
7766
</div>

decidim-debates/config/locales/en.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,18 @@ en:
4646
endorsements_enabled: Endorsements enabled
4747
debates:
4848
actions:
49-
active: Active debates
50-
archive: Archive
51-
archived: Archived debates
5249
close: Close
5350
confirm_destroy: Are you sure?
5451
destroy: Delete
5552
edit: Edit
5653
new: New %{name}
5754
title: Actions
58-
unarchive: Unarchive
5955
admin:
6056
debate_closes:
6157
edit:
62-
archive: Archive this debate
63-
archive_help: Archiving this debate will hide it from the public debates section
6458
close: Close
6559
title: Close debate
6660
debates:
67-
archive:
68-
invalid: There was a problem archiving the debate.
69-
success: Debate successfully archived.
7061
create:
7162
invalid: There was a problem creating the debate.
7263
success: Debate successfully created.
@@ -75,7 +66,6 @@ en:
7566
edit:
7667
title: Edit debate
7768
update: Update debate
78-
empty: There are no debates matching these criteria.
7969
form:
8070
debate_type: Debate type
8171
finite: Finite (With start and end times)
@@ -85,9 +75,6 @@ en:
8575
new:
8676
create: Create debate
8777
title: New debate
88-
unarchive:
89-
invalid: There was a problem unarchiving the debate.
90-
success: Debate successfully unarchived.
9178
update:
9279
invalid: There was a problem updating this debate.
9380
success: Debate successfully updated.

0 commit comments

Comments
 (0)