Skip to content

Commit

Permalink
Merge branch 'develop' into feature/redesign-admin
Browse files Browse the repository at this point in the history
* develop:
  Remove duplication for add questions specs examples (#11559)
  Remove duplication from invites queries (#11552)
  Fix typos and copy-paste errors from comments and examples (#11536)
  Fix conference venues meetings visibility (#11542)
  • Loading branch information
entantoencuanto committed Sep 5, 2023
2 parents 9fcb25e + 5db45c0 commit f0e1628
Show file tree
Hide file tree
Showing 84 changed files with 264 additions and 280 deletions.
58 changes: 58 additions & 0 deletions decidim-admin/app/queries/decidim/admin/invites.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

module Decidim
module Admin
# A class used to find the Invites by their status status.
class Invites < Decidim::Query
# Syntactic sugar to initialize the class and return the queried objects.
#
# invites - the initial Invites relation that needs to be filtered.
# query - query to filter invites
# status - invite status to be used as a filter
def self.for(invites, query = nil, status = nil)
new(invites, query, status).query
end

# Initializes the class.
#
# invites - the initial Invites relation that need to be filtered
# query - query to filter invites
# status - invite status to be used as a filter
def initialize(invites, query = nil, status = nil)
@invites = invites
@query = query
@status = status
end

# List the invites by the different filters.
def query
@invites = filter_by_search(@invites)
@invites = filter_by_status(@invites)
@invites
end

private

def filter_by_search(invites)
return invites if @query.blank?

invites.joins(:user).where(
User.arel_table[:name].lower.matches("%#{@query}%").or(User.arel_table[:email].lower.matches("%#{@query}%"))
)
end

def filter_by_status(invites)
case @status
when "accepted"
invites.where.not(accepted_at: nil)
when "rejected"
invites.where.not(rejected_at: nil)
when "sent"
invites.where.not(sent_at: nil).where(accepted_at: nil, rejected_at: nil)
else
invites
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

require "spec_helper"
require "decidim/meetings/test/factories"

module Decidim::Meetings::Admin
module Decidim::Admin
describe Invites do
subject { described_class.for(Decidim::Meetings::Invite.all, search, filter) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Assemblies
# This cell renders the Grid (:g) assembly card
# for an given instance of an Assembly
# for a given instance of an Assembly
class AssemblyGCell < Decidim::CardGCell
private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Assemblies
# This cell renders the Search (:s) process card
# for an given instance of a Assembly
# for a given instance of an Assembly
class AssemblySCell < Decidim::CardSCell
private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def public_list_members_action?
allow!
end

# All users with a relation to a assembly and organization admins can enter
# All users with a relation to an assembly and organization admins can enter
# the space area. The sapce area is considered to be the assemblies zone,
# not the assembly groups one.
def user_can_enter_space_area?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(organization, user)
# - title: The +title+ for the new Assembly
# - slug: The +slug+ for the new Assembly
#
# Returns a Assembly.
# Returns an Assembly instance.
def import(attributes, _user, opts)
title = opts[:title]
slug = opts[:slug]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AssemblySerializer < Decidim::Exporters::Serializer
include Decidim::ResourceHelper
include Decidim::TranslationsHelper

# Public: Initializes the serializer with a assembly.
# Public: Initializes the serializer with an Assembly instance.
def initialize(assembly)
@assembly = assembly
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-assemblies/lib/decidim/api/assemblies_type_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Decidim
module Assemblies
# This type represents an AssembliesType.
# This type represents an AssemblyType instance
class AssembliesTypeType < Decidim::Api::Types::BaseObject
description "An assemblies type"

Expand Down
2 changes: 1 addition & 1 deletion decidim-assemblies/lib/decidim/api/assembly_member_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Decidim
module Assemblies
# This type represents a assembly.
# This type represents an AssemblyMember instance.
class AssemblyMemberType < Decidim::Api::Types::BaseObject
description "An assembly member"

Expand Down
2 changes: 1 addition & 1 deletion decidim-assemblies/lib/decidim/api/assembly_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Decidim
module Assemblies
# This type represents a assembly.
# This type represents an Assembly.
class AssemblyType < Decidim::Api::Types::BaseObject
implements Decidim::Core::ParticipatorySpaceInterface
implements Decidim::Core::AttachableInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.included(type)
type.field :assembly,
Decidim::Assemblies::AssemblyType,
null: true,
description: "Finds a assembly" do
description: "Finds an assembly" do
argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false
end
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-assemblies/spec/commands/copy_assembly_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module Decidim::Assemblies
context "when copy_categories exists" do
let(:copy_categories) { true }

it "duplicates a assembly and the categories" do
it "duplicates an assembly and the categories" do
expect { subject.call }.to change(Decidim::Category, :count).by(1)
expect(Decidim::Category.unscoped.distinct.pluck(:decidim_participatory_space_id).count).to eq 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def stub_calls_to_external_files
let(:import_attachments) { true }

context "when attachment collections exists" do
it "imports a assembly and the collections" do
it "imports an assembly and the collections" do
stub_calls_to_external_files

expect { subject.call }.to change(Decidim::AttachmentCollection, :count).by(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
)
end

context "when reading a assembly" do
context "when reading an assembly" do
let(:action) do
{ scope: :public, action: :read, subject: :assembly }
end
Expand Down Expand Up @@ -281,7 +281,7 @@
)
end

context "when creating a assembly" do
context "when creating an assembly" do
let(:action) do
{ scope: :admin, action: :create, subject: :assembly }
end
Expand Down Expand Up @@ -326,7 +326,7 @@
)
end

context "when reading a assemblies settings" do
context "when reading an assemblies settings" do
let(:action) do
{ scope: :admin, action: :read, subject: :assemblies_setting }
end
Expand All @@ -341,7 +341,7 @@
)
end

context "with a assembly" do
context "with an assembly" do
let(:context) { { assembly: } }

context "when moderating a resource" do
Expand All @@ -359,7 +359,7 @@
)
end

context "when publishing a assembly" do
context "when publishing an assembly" do
let(:action) do
{ scope: :admin, action: :publish, subject: :assembly }
end
Expand Down Expand Up @@ -402,10 +402,10 @@
end
end

context "when user is a assembly admin" do
context "when user is an assembly admin" do
let(:user) { assembly_admin }

context "when creating a assembly" do
context "when creating an assembly" do
let(:action) do
{ scope: :admin, action: :create, subject: :assembly }
end
Expand Down Expand Up @@ -435,7 +435,7 @@
end

context "when user is an org admin" do
context "when creating a assembly" do
context "when creating an assembly" do
let(:action) do
{ scope: :admin, action: :create, subject: :assembly }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
visit current_path
end

it "updates a assembly admin" do
it "updates an assembly admin" do
within "#assembly_admins" do
within find("#assembly_admins tr", text: other_user.email) do
click_link "Edit"
Expand All @@ -69,7 +69,7 @@
end
end

it "deletes a assembly_user_role" do
it "deletes an assembly_user_role" do
within find("#assembly_admins tr", text: other_user.email) do
accept_confirm { click_link "Delete" }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
visit current_path
end

it "deletes a assembly_private_user" do
it "deletes an assembly_private_user" do
within find("#private_users tr", text: other_user.email) do
accept_confirm { click_link "Delete" }
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-blogs/app/cells/decidim/blogs/post_g_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Blogs
# This cell renders the Grid (:g) post card
# for an given instance of a Post
# for a given instance of a Post
class PostGCell < Decidim::CardGCell
delegate :photo, to: :model

Expand Down
2 changes: 1 addition & 1 deletion decidim-blogs/app/cells/decidim/blogs/post_l_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Blogs
# This cell renders the List (:l) post card
# for an given instance of a Post
# for a given instance of a Post
class PostLCell < Decidim::CardLCell
delegate :photo, to: :model

Expand Down
2 changes: 1 addition & 1 deletion decidim-blogs/app/cells/decidim/blogs/post_s_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Blogs
# This cell renders the Search (:s) post card
# for an given instance of a Post
# for a given instance of a Post
class PostSCell < Decidim::CardSCell
private

Expand Down
2 changes: 1 addition & 1 deletion decidim-budgets/app/cells/decidim/budgets/budget_m_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Budgets
# This cell renders the Medium (:m) budget card
# for an given instance of a Decidim::Budgets::Budget
# for a given instance of a Budget
class BudgetMCell < Decidim::CardMCell
include ActiveSupport::NumberHelper
include Decidim::Budgets::ProjectsHelper
Expand Down
2 changes: 1 addition & 1 deletion decidim-budgets/app/cells/decidim/budgets/budget_s_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Budgets
# This cell renders the Search (:s) budget card
# for an given instance of a Decidim::Budgets::Budget
# for a given instance of a Budget
class BudgetSCell < Decidim::CardSCell
private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Budgets
# This cell renders the Medium (:m) project card
# for an given instance of a Project
# for a given instance of a Project
class ProjectMCell < Decidim::CardMCell
include ActiveSupport::NumberHelper
include Decidim::Budgets::ProjectsHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Comments
# This cell renders the Search (:s) comment card
# for an given instance of a Comment
# for a given instance of a Comment
class CommentSCell < Decidim::CardSCell
include CommentCellsHelper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Decidim
module Conferences
# This cell renders the conference card for an instance of an Conference
# This cell renders the conference card for an instance of a Conference
# the default size is the Grid Card (:g)
class ConferenceCell < Decidim::ViewModel
def show
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Conferences
# This cell renders the Grid (:g) conference card
# for an given instance of an Assembly
# for a given instance of a Conference
class ConferenceGCell < Decidim::CardGCell
private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Conferences
# This cell renders the List (:l) conference card
# for an given instance of a Conference
# for a given instance of a Conference
class ConferenceLCell < Decidim::CardLCell
def metadata_cell
"decidim/conferences/conference_metadata"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Conferences
# This cell renders the Search (:s) conference card
# for an given instance of a Conference
# for a given instance of a Conference
class ConferenceSCell < Decidim::CardSCell
def metadata_cell
"decidim/conferences/conference_metadata"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Decidim
module Conferences
# This cell renders the card for an instance of an Conference Speaker
# This cell renders the card for an instance of a Conference Speaker
class ConferenceSpeakerCell < Decidim::AuthorCell
include Decidim::Meetings::MeetingCellsHelper
include Cell::ViewModel::Partial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Conferences
module Admin
# A command with all the business logic when destroying an conference
# A command with all the business logic when destroying a conference
# speaker in the system.
class DestroyConferenceSpeaker < Decidim::Command
# Public: Initializes the command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module Decidim
module Conferences
module Admin
# A command with all the business logic when destroying an conference
# partner in the system.
# A command with all the business logic when destroying a conference
# Partner in the system.
class DestroyPartner < Decidim::Command
# Public: Initializes the command.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module Conferences
module Admin
# A command that sets an conference as published.
# A command that sets a Conference as published.
class PublishConference < Decidim::Command
# Public: Initializes the command.
#
Expand Down
Loading

0 comments on commit f0e1628

Please sign in to comment.