app/permissions/decidim/initiatives/admin/permissions.rb in decidim-initiatives-0.16.1 vs app/permissions/decidim/initiatives/admin/permissions.rb in decidim-initiatives-0.17.0
- old
+ new
@@ -33,10 +33,11 @@
initiative_type_action?
initiative_type_scope_action?
initiative_committee_action?
initiative_admin_user_action?
+ moderator_action?
allow! if permission_action.subject == :attachment
permission_action
end
@@ -80,11 +81,11 @@
disallow!
end
end
def initiative_type_action?
- return unless permission_action.subject == :initiative_type
+ return unless [:initiative_type, :initiatives_type].include? permission_action.subject
initiative_type = context.fetch(:initiative_type, nil)
case permission_action.action
when :destroy
@@ -134,10 +135,12 @@
toggle_allow(initiative.validating?)
when :unpublish
toggle_allow(initiative.published?)
when :discard
toggle_allow(initiative.validating?)
+ when :export_pdf_signatures
+ toggle_allow(initiative.published? || initiative.accepted? || initiative.rejected?)
when :export_votes
toggle_allow(initiative.offline? || initiative.any?)
when :accept
allowed = initiative.published? &&
initiative.signature_end_date < Date.current &&
@@ -151,10 +154,16 @@
else
allow!
end
end
+ def moderator_action?
+ return unless permission_action.subject == :moderation
+
+ allow!
+ end
+
def read_initiative_list_action?
return unless permission_action.subject == :initiative &&
permission_action.action == :list
allow!
end
@@ -169,11 +178,11 @@
allow!
when :update
toggle_allow(initiative.created?)
when :send_to_technical_validation
allowed = initiative.created? && (
- !initiative.decidim_user_group_id.nil? ||
- initiative.committee_members.approved.count >= Decidim::Initiatives.minimum_committee_members
+ !initiative.created_by_individual? ||
+ initiative.enough_committee_members?
)
toggle_allow(allowed)
when :manage_membership
allow!