app/commands/decidim/proposals/update_proposal.rb in decidim-proposals-0.26.10 vs app/commands/decidim/proposals/update_proposal.rb in decidim-proposals-0.27.0.rc1
- old
+ new
@@ -1,11 +1,11 @@
# frozen_string_literal: true
module Decidim
module Proposals
# A command with all the business logic when a user updates a proposal.
- class UpdateProposal < Rectify::Command
+ class UpdateProposal < Decidim::Command
include ::Decidim::MultipleAttachmentsMethods
include GalleryMethods
include HashtagsMethods
# Public: Initializes the command.
@@ -48,11 +48,11 @@
photo_cleanup!
document_cleanup!
create_gallery if process_gallery?
- create_attachments if process_attachments?
+ create_attachments(first_weight: first_attachment_weight) if process_attachments?
end
broadcast(:ok, proposal)
end
@@ -112,9 +112,15 @@
if user_group
user_group_proposals.count >= proposal_limit
else
current_user_proposals.count >= proposal_limit
end
+ end
+
+ def first_attachment_weight
+ return 1 if proposal.photos.count.zero?
+
+ proposal.photos.count
end
def user_group
@user_group ||= Decidim::UserGroup.find_by(organization: organization, id: form.user_group_id)
end