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

update Decidim v0.24.3 #312

Merged
merged 29 commits into from
Mar 31, 2022
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f001ddb
Update Gemfile
takahashim Nov 21, 2021
90dd528
Exec `bundle update decidim`
takahashim Nov 21, 2021
7fa4cfc
Exec `bin/rails decidim:upgrade`
takahashim Nov 21, 2021
60f6bed
Exec `bin/rails db:migrate`
takahashim Nov 21, 2021
75aa0bb
Add locale file(JA) for v0.24.3
takahashim Nov 21, 2021
bad78ae
Update translations (in a locale file)
takahashim Nov 21, 2021
8933394
Update Gemfile and Gemfile.lock
takahashim Nov 21, 2021
4eebf87
Remove old code for Faker 1.x; now we use 2.x
takahashim Nov 21, 2021
977fc03
Fix `Faker::Lorem.words` for Faker 2.x
takahashim Nov 21, 2021
ca218f2
Apply rules of rubocop from Decidim 0.24.3
takahashim Nov 21, 2021
83f1ed5
Update decidim-comments to v0.24.3
takahashim Dec 26, 2021
4644ae0
Support comments limit again
takahashim Dec 26, 2021
c43c08d
Update `Decidim::ApplicationUploader`; Fix #322
takahashim Jan 13, 2022
e005db9
remove PaginateHelper; ref. #219
takahashim Jan 13, 2022
aa227bb
Feedback from decidim/decidim v0.24.3
takahashim Jan 13, 2022
93f690b
remove fix of #18 and #101
takahashim Jan 15, 2022
8dfba37
Merge pull request #324 from codeforjapan/fix-323
ayuki-joto Jan 17, 2022
45fcd51
Merge branch 'develop' of https://github.com/codeforjapan/decidim-cfj…
ayuki-joto Jan 17, 2022
0e9f17b
Feedback from decidim/decidim v0.24.3
takahashim Jan 24, 2022
da73e8c
Merge pull request #329 from codeforjapan/v0243-proposal-form2
ayuki-joto Jan 26, 2022
e2b9918
Merge branch 'develop' of https://github.com/codeforjapan/decidim-cfj…
ayuki-joto Jan 26, 2022
ba4533f
Merge branch 'develop' of https://github.com/codeforjapan/decidim-cfj…
ayuki-joto Feb 21, 2022
f737130
Merge branch 'develop' of https://github.com/codeforjapan/decidim-cfj…
ayuki-joto Feb 26, 2022
ad20139
Add ja locale file for file_validators gem
takahashim Mar 7, 2022
b43095f
copy from v0.24.3
takahashim Mar 28, 2022
78d206b
Backport 8406
takahashim Mar 28, 2022
a3783d0
Fix spec
takahashim Mar 28, 2022
2cbb542
Merge branch 'v0243-backport' into v0243
takahashim Mar 28, 2022
1872caa
[ci skip] Update UPGRADE.md
takahashim Mar 28, 2022
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
Prev Previous commit
Next Next commit
copy from v0.24.3
  • Loading branch information
takahashim committed Mar 28, 2022
commit b43095f3fb2d1c2e24469ce70737f9afda3b600c
9 changes: 9 additions & 0 deletions app/cells/decidim/following/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="empty-notifications callout secondary <%= "hide" if followings.any? %>">
<p><%= t("decidim.following.no_followings") %></p>
</div>
<div class="row small-up-1 medium-up-2 card-grid">
<% followings.each do |following| %>
<%= card_for following, context: { label: true, show_space: true } %>
<% end %>
</div>
<%= decidim_paginate followings %>
18 changes: 18 additions & 0 deletions app/cells/decidim/following_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Decidim
class FollowingCell < Decidim::ViewModel
include Decidim::CellsPaginateHelper
include Decidim::ApplicationHelper
include Decidim::Core::Engine.routes.url_helpers
include Decidim::CardHelper

def show
render :show
end

def followings
@followings ||= Kaminari.paginate_array(model.following).page(params[:page]).per(20)
end
end
end
50 changes: 50 additions & 0 deletions app/models/decidim/user_base_entity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

module Decidim
# This class serves as a base class for `Decidim::User` and `Decidim::UserGroup`
# so that we can set some shared logic.
# This class is not supposed to be used directly.
class UserBaseEntity < ApplicationRecord
self.table_name = "decidim_users"

include Nicknamizable
include Resourceable
include Decidim::Followable
include Decidim::Loggable
include Decidim::HasUploadValidations

belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
has_many :notifications, foreign_key: "decidim_user_id", class_name: "Decidim::Notification", dependent: :destroy
has_many :following_follows, foreign_key: "decidim_user_id", class_name: "Decidim::Follow", dependent: :destroy

# Regex for name & nickname format validations
REGEXP_NAME = /\A(?!.*[<>?%&\^*#@()\[\]=+:;"{}\\|])/.freeze

validates_avatar
mount_uploader :avatar, Decidim::AvatarUploader

validates :name, format: { with: REGEXP_NAME }

# Public: Returns a collection with all the entities this user is following.
#
# This can't be done as with a `has_many :following, through: :following_follows`
# since it's a polymorphic relation and Rails doesn't know how to load it. With
# this implementation we only query the database once for each kind of following.
#
# Returns an Array of Decidim::Followable
def following
@following ||= begin
followings = following_follows.pluck(:decidim_followable_type, :decidim_followable_id)
grouped_followings = followings.each_with_object({}) do |(type, following_id), all|
all[type] ||= []
all[type] << following_id
all
end

grouped_followings.flat_map do |type, ids|
type.constantize.where(id: ids)
end
end
end
end
end
25 changes: 25 additions & 0 deletions lib/decidim/has_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require "active_support/concern"
require "decidim/component_validator"

module Decidim
# A concern with the components needed when you want a model to have a component.
module HasComponent
extend ActiveSupport::Concern

included do
belongs_to :component, foreign_key: "decidim_component_id", class_name: "Decidim::Component", touch: true
delegate :organization, to: :component, allow_nil: true
delegate :participatory_space, :can_participate_in_space?, to: :component, allow_nil: true

alias_method :can_participate?, :can_participate_in_space?
end

class_methods do
def component_manifest_name(manifest_name)
validates :component, component: { manifest: manifest_name || name.demodulize.pluralize.downcase }
end
end
end
end
138 changes: 138 additions & 0 deletions lib/decidim/participable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# frozen_string_literal: true

module Decidim
#
# Utilities for models that can act as participatory spaces
#
module Participable
extend ActiveSupport::Concern

included do
def demodulized_name
@demodulized_name ||= self.class.name.demodulize
end

delegate :foreign_key, to: :demodulized_name

def module_name
"Decidim::#{demodulized_name.pluralize}"
end

def admin_module_name
"#{module_name}::Admin"
end

def underscored_name
demodulized_name.underscore
end

def mounted_engine
"decidim_#{underscored_name.pluralize}"
end

def mounted_admin_engine
"decidim_admin_#{underscored_name.pluralize}"
end

def mounted_params
{
host: organization.host,
"#{underscored_name}_slug".to_sym => slug
}
end

def admin_extension_module
"#{admin_module_name}::#{demodulized_name}Context".constantize
end

def admins_query
"#{admin_module_name}::AdminUsers".constantize
end

def admins
admins_query.for(self)
end

# Public: Returns an ActiveRecord::Relation of all the users that can
# moderate the space. This is used when notifying of flagged/hidden
# content.
def moderators
admins
end

def allows_steps?
respond_to?(:steps)
end

def has_steps?
allows_steps? && steps.any?
end

def manifest
self.class.participatory_space_manifest
end

def can_participate?(_user)
true
end

def empty_published_component?
components.published.empty?
end

def cta_button_text_key
return :more_info if empty_published_component?

:take_part
end

def cta_button_text_key_accessible
return :more_info_about if empty_published_component?

:take_part_in
end
end

class_methods do
def slug_format
/\A[a-zA-Z]+[a-zA-Z0-9\-]+\z/
end

def participatory_space_manifest
Decidim.find_participatory_space_manifest(name.demodulize.underscore.pluralize)
end

# Public: Adds a sane default way to retrieve public spaces. Please, overwrite
# this from your model class in case this is not correct for your model.
#
# Returns an `ActiveRecord::Association`.
def public_spaces
published
end

# Public: Adds a sane default way to retrieve active spaces. Please, overwrite
# this from your model class in case this is not correct for your model.
#
# Returns an `ActiveRecord::Association`.
def active_spaces
public_spaces
end

# Public: Adds a sane default way to retrieve future spaces. Please, overwrite
# this from your model class in case this is not correct for your model.
#
# Returns an `ActiveRecord::Association`.
def future_spaces
none
end

# Public: Adds a sane default way to retrieve past spaces. Please, overwrite
# this from your model class in case this is not correct for your model.
#
# Returns an `ActiveRecord::Association`.
def past_spaces
none
end
end
end
end
Loading