Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:decidim/decidim into chore/remov…
Browse files Browse the repository at this point in the history
…e-secrets
  • Loading branch information
alecslupu committed Sep 17, 2024
2 parents 60641cf + e5dd8a3 commit 8ea739d
Show file tree
Hide file tree
Showing 155 changed files with 3,349 additions and 712 deletions.
2 changes: 2 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ boundingbox
Brakus
breadcrumb
browserstack
builder
bugfixing
byebug
bytesize
Expand Down Expand Up @@ -407,6 +408,7 @@ iframes
iife
Ijkl
ilike
illgotten
impersonatable
inbox
includeurl
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,9 @@ GEM
rspec-cells (0.3.9)
cells (>= 4.0.0, < 6.0.0)
rspec-rails (>= 3.0.0, < 6.2.0)
rspec-core (3.13.0)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.1)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-html-matchers (0.10.0)
Expand Down
14 changes: 14 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ bin/rails decidim:upgrade:clean:action_logs

You can read more about this change on PR [#13237](https://github.com/decidim/decidim/pull/13237).

### 2.3. Refactor of `decidim:upgrade:fix_orphan_categorizations` task

As of [#13380](https://github.com/decidim/decidim/pull/13380), the task named `decidim:upgrade:fix_orphan_categorizations` has been renamed to `decidim:upgrade:clean:categories` and has been included in the main `decidim:upgrade:clean:invalid_records` task.

You can read more about this change on PR [#13380](https://github.com/decidim/decidim/pull/13380).

### 2.4

Now the cache expiration time is configurable via initializers/ENV variables.

Decidim uses cache in some HTML views (usually under the `cells/` folder). In the past the cache had no expiration time, now it is configurable using the ENV var `DECIDIM_CACHE_EXPIRATION_TIME` (this var expects an integer specifying the number of minutes for which the cache is valid).

Also note, that now it comes with a default value of 24 hours (1440 minutes).

## 3. One time actions

These are one time actions that need to be done after the code is updated in the production database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,16 @@ def show
render template
end

private

def template
@template ||= options[:template] || :show
end

def title
decidim_escape_translated result.title
end

def description
decidim_sanitize_admin translated_attribute(result.description)
end

def scope
current_scope.presence
end

def tab_panel_items
[
{
enabled: ResultHistoryCell.new(result).render?,
id: "included_history",
text: t("decidim.history", scope: "activerecord.models", count: 2),
icon: resource_type_icon_key("history"),
method: :cell,
args: ["decidim/accountability/result_history", result]
},
{
enabled: timeline_entries.any?,
id: "timeline_entries",
Expand All @@ -50,33 +40,27 @@ def tab_panel_items
icon: "briefcase-2-line",
method: :cell,
args: ["decidim/accountability/results", result.children]
},
{
enabled: result.linked_resources(:proposals, "included_proposals").present?,
id: "included_proposals",
text: t("activemodel.attributes.result.proposals"),
icon: "chat-new-line",
method: :cell,
args: ["decidim/linked_resources_for", result, { type: :proposals, link_name: "included_proposals" }]
},
{
enabled: result.linked_resources(:projects, "included_projects").present?,
id: "included_projects",
text: t("activemodel.attributes.result.project_ids"),
icon: "git-pull-request-line",
method: :cell,
args: ["decidim/linked_resources_for", result, { type: :projects, link_name: "included_projects" }]
},
{
enabled: result.linked_resources(:meetings, "meetings_through_proposals").present?,
id: "included_meetings",
text: t("activemodel.attributes.result.meetings_ids"),
icon: "treasure-map-line",
method: :cell,
args: ["decidim/linked_resources_for", result, { type: :meetings, link_name: "meetings_through_proposals" }]
}
] + attachments_tab_panel_items(result)
end

private

def template
@template ||= options[:template] || :show
end

def title
decidim_escape_translated result.title
end

def description
decidim_sanitize_admin translated_attribute(result.description)
end

def scope
current_scope.presence
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# frozen_string_literal: true

module Decidim
module Accountability
# This cell is used to render a result history panel of a resource
# inside a tab of a show view
#
# The `model` must be an accountability result resource to get the history from.
#
# Example:
#
# cell(
# "decidim/result_history",
# result
# )
class ResultHistoryCell < Decidim::ResourceHistoryCell
include Decidim::Accountability::ApplicationHelper

def linked_resources_items
[
{
resources: @model.linked_resources(:proposals, "included_proposals"),

link_name: "included_proposals",
text_key: "decidim.accountability.result.proposal_ids",
icon_key: "Decidim::Proposals::Proposal"
},
{
resources: @model.linked_resources(:projects, "included_projects"),
link_name: "included_projects",
text_key: "decidim.accountability.result.project_ids",
icon_key: "Decidim::Budgets::Project"
},
{
resources: @model.linked_resources(:meetings, "meetings_through_proposals"),
link_name: "meetings_through_proposals",
text_key: "decidim.accountability.result.meetings_ids",
icon_key: "Decidim::Meetings::Meeting"
}
]
end

def creation_item
{
id: "result_creation",
date: @model.created_at,
text: t("decidim.accountability.creation.text"),
icon: resource_type_icon_key("Decidim::Accountability::Result")
}
end

def history_cell_id
"result"
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<%= render layout: "layouts/decidim/shared/layout_item" do %>
<%= cell("decidim/accountability/project", result) %>
<%= cell("decidim/tags", result) %>

<section class="layout-main__section layout-main__buttons" data-buttons>
<%= cell "decidim/comments_button", nil %>
<div class="ml-auto">
<%= cell "decidim/tags", result %>
</div>
</section>

<% content_for :aside do %>
Expand Down
13 changes: 10 additions & 3 deletions decidim-accountability/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ en:
decidim_scope_id: Scope
description: Description
end_date: End date
meetings_ids: Included meetings
progress: Progress
project_ids: Included projects
proposals: Included proposals
start_date: Start date
subresults: Subresults
title: Title
Expand All @@ -30,6 +27,14 @@ en:
decidim/accountability/result_progress_updated_event: Result progress updated
activerecord:
models:
decidim:
accountability:
result:
budget_text: This result %{link} was included
meetings_ids: 'It was discussed in this meeting: %{link}'
project_ids: 'It was included in this project: %{link}'
proposal_ids: 'It was included in this proposal: %{link}'
text: 'It was added to this result: %{link}'
decidim/accountability/result:
one: Result
other: Results
Expand Down Expand Up @@ -178,6 +183,8 @@ en:
content_blocks:
highlighted_results:
results: Results
creation:
text: This result was created
import_mailer:
import:
errors: Errors
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: true

require "spec_helper"

module Decidim::Accountability
describe ResultHistoryCell, type: :cell do
controller Decidim::Accountability::ResultsController

let!(:result) { create(:result) }
let(:participatory_space) { result.participatory_space }
let(:component) { create(:accountability_component) }
let(:organization) { result.organization }
let(:user) { create(:user, organization: result.participatory_space.organization) }

before do
allow(controller).to receive(:current_user).and_return(user)
end

context "when the result has linked resources" do
context "when result has been linked in a proposal" do
let(:proposal_component) do
create(:component, manifest_name: :proposals, participatory_space: result.component.participatory_space)
end
let(:proposal) { create(:proposal, component: proposal_component) }

before do
proposal.link_resources([result], "included_proposals")
end

it "shows related proposals" do
html = cell("decidim/accountability/result_history", result).call
expect(html).to have_content("It was included in this proposal:")
end
end

context "when a result has been linked in a project" do
let(:budget_component) do
create(:component, manifest_name: :budgets, participatory_space: result.component.participatory_space)
end
let(:project) { create(:project, component: budget_component) }

before do
project.link_resources([result], "included_projects")
end

it "shows related projects" do
html = cell("decidim/accountability/result_history", result).call
expect(html).to have_content("It was included in this project:")
end
end

context "when a result has been linked in a meeting" do
let(:meeting_component) do
create(:component, manifest_name: :meetings, participatory_space: result.component.participatory_space)
end
let(:meeting) { create(:meeting, :published, component: meeting_component) }

before do
meeting.link_resources([result], "meetings_through_proposals")
end

it "shows related meetings" do
html = cell("decidim/accountability/result_history", result).call
expect(html).to have_content("It was discussed in this meeting:")
end
end
end
end
end
8 changes: 8 additions & 0 deletions decidim-accountability/spec/shared/manage_results_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
visit decidim_admin.root_path
expect(page).to have_content("created result")
expect(page).to have_content(attributes[:title]["en"])

visit decidim.last_activities_path
expect(page).to have_content("New result: #{translated(attributes[:title])}")

within "#filters" do
find("a", class: "filter", text: "Result", match: :first).click
end
expect(page).to have_content("New result: #{translated(attributes[:title])}")
end
end

Expand Down
Loading

0 comments on commit 8ea739d

Please sign in to comment.