Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop into master #84

Merged
merged 18 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ gem "decidim-budgets_paper_ballots", git: "https://github.com/digidemlab/decidim
gem "decidim-decidim_awesome"
gem "decidim-half_signup", git: "https://github.com/OpenSourcePolitics/decidim-module-half_sign_up", branch: DECIDIM_BRANCH
gem "decidim-homepage_interactive_map", git: "https://github.com/OpenSourcePolitics/decidim-module-homepage_interactive_map.git", branch: DECIDIM_BRANCH
gem "decidim-homepage_proposals", git: "https://github.com/OpenSourcePolitics/decidim-module_homepage_proposals.git", branch: DECIDIM_BRANCH
# gem "decidim-homepage_proposals", git: "https://github.com/OpenSourcePolitics/decidim-module_homepage_proposals.git", branch: DECIDIM_BRANCH
gem "decidim-homepage_proposals", git: "https://github.com/alecslupu-pfa/decidim-module_homepage_proposals", branch: "feature/reset-filters"
gem "decidim-phone_authorization_handler", git: "https://github.com/OpenSourcePolitics/decidim-module_phone_authorization_handler", branch: DECIDIM_BRANCH
gem "decidim-simple_proposal", git: "https://github.com/mainio/decidim-module-simple_proposal", branch: DECIDIM_BRANCH
gem "decidim-slider", git: "https://github.com/alecslupu-pfa/decidim-module-slider", branch: "main"
gem "decidim-spam_detection"
gem "decidim-term_customizer", git: "https://github.com/mainio/decidim-module-term_customizer.git", branch: DECIDIM_BRANCH
gem "decidim-term_customizer", git: "https://github.com/opensourcepolitics/decidim-module-term_customizer.git", branch: "fix/multi-threading-compliant-0.26"

gem "dotenv-rails"

Expand Down
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ GIT
rgeo (~> 2.4)
rgeo-proj4 (~> 3.1)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module_homepage_proposals.git
revision: 3e17f0fe9403ea222f6c3f279a2ed264cc6109a5
branch: release/0.26-stable
specs:
decidim-homepage_proposals (1.0.2)
decidim-core (~> 0.26)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module_phone_authorization_handler
revision: 488cc8827845ec1c5266aa499df2ebf9b20e02a3
Expand Down Expand Up @@ -58,6 +50,14 @@ GIT
decidim-slider (0.0.2)
decidim-core (~> 0.26.0)

GIT
remote: https://github.com/alecslupu-pfa/decidim-module_homepage_proposals
revision: 37ac5b73893ab532e06729bef6f5d3b4b6553f35
branch: feature/reset-filters
specs:
decidim-homepage_proposals (1.0.2)
decidim-core (~> 0.26)

GIT
remote: https://github.com/digidemlab/decidim-module-budgets_paper_ballots
revision: 3e5d2794f43b1c353e8a3116edf6daab9e3a26a7
Expand All @@ -77,9 +77,9 @@ GIT
decidim-proposals (~> 0.26.0)

GIT
remote: https://github.com/mainio/decidim-module-term_customizer.git
revision: f0d720710822f1231ea249dd71f978143d38a6c4
branch: release/0.26-stable
remote: https://github.com/opensourcepolitics/decidim-module-term_customizer.git
revision: f5208f3cad23cb68e502e77cb0d2d3d441d09e40
branch: fix/multi-threading-compliant-0.26
specs:
decidim-term_customizer (0.26.0)
decidim-admin (~> 0.26.0)
Expand Down
153 changes: 153 additions & 0 deletions app/cells/decidim/proposals/proposal_m_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# frozen_string_literal: true

require "cell/partial"

module Decidim
module Proposals
# This cell renders a proposal with its M-size card.
class ProposalMCell < Decidim::CardMCell
include ProposalCellsHelper

delegate :current_locale, to: :controller

def badge
render if has_badge?
end

private

def preview?
options[:preview]
end

def title
present(model).title(html_escape: true)
end

def body
decidim_sanitize_editor(present(model).body)
end

def has_state?
model.published?
end

def has_badge?
published_state? || withdrawn?
end

def has_link_to_resource?
model.published?
end

def has_footer?
return false if model.emendation?

true
end

def description
strip_tags(body).truncate(120, separator: /\s/)
end

def badge_classes
return super unless options[:full_badge]

state_classes.concat(["label", "proposal-status"]).join(" ")
end

def base_statuses
@base_statuses ||= begin
if endorsements_visible?
[:endorsements_count, :comments_count]
else
[:comments_count]
end
end
end

def statuses
return [] if preview?
return base_statuses if model.draft?
return [:creation_date] + base_statuses if !has_link_to_resource? || !can_be_followed?

[:creation_date, :follow] + base_statuses
end

def creation_date_status
explanation = tag.strong(t("activemodel.attributes.common.created_at"))
"#{explanation}<br>#{l(model.published_at.to_date, format: :decidim_short)}"
end

def endorsements_count_status
return endorsements_count unless has_link_to_resource?

link_to resource_path, "aria-label" => "#{t("decidim.endorsable.endorsements_count")}: #{model.endorsements_count}", title: t("decidim.endorsable.endorsements_count") do
endorsements_count
end
end

def endorsements_count
with_tooltip t("decidim.endorsable.endorsements") do
"#{icon("bullhorn", class: "icon--small")} #{model.endorsements_count}"
end
end

def progress_bar_progress
model.proposal_votes_count || 0
end

def progress_bar_total
model.maximum_votes || 0
end

def progress_bar_subtitle_text
if progress_bar_progress >= progress_bar_total
t("decidim.proposals.proposals.votes_count.most_popular_proposal")
else
t("decidim.proposals.proposals.votes_count.need_more_votes")
end
end

def can_be_followed?
!model.withdrawn?
end

def endorsements_visible?
model.component.current_settings.endorsements_enabled?
end

def has_image?
@has_image ||= model.attachments.map(&:image?).any?
end

def resource_image_path
@resource_image_path ||= has_image? ? model.attachments.find_by("content_type like '%image%'").thumbnail_url : nil
end

def cache_hash
hash = []
hash << I18n.locale.to_s
hash << model.cache_key_with_version
hash << model.proposal_votes_count
hash << model.endorsements_count
hash << model.comments_count
hash << Digest::MD5.hexdigest(model.component.cache_key_with_version)
hash << Digest::MD5.hexdigest(resource_image_path) if resource_image_path
hash << render_space? ? 1 : 0
if current_user
hash << current_user.cache_key_with_version
hash << current_user.follows?(model) ? 1 : 0
end
hash << model.follows_count
hash << Digest::MD5.hexdigest(model.authors.map(&:cache_key_with_version).to_s)
hash << (model.must_render_translation?(model.organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
hash << model.component.participatory_space.active_step.id if model.component.participatory_space.try(:active_step)
hash << has_footer?
hash << has_actions?

hash.join(Decidim.cache_key_separator)
end
end
end
end
Loading