Sha256: df7ba16b240e7347e3a868b2acbe72a3ffff7fa4dec1e457a0ea1c3cd6b658c7
Contents?: true
Size: 1.05 KB
Versions: 28
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module Decidim module Proposals # A form object common to accept and reject actions requesters of Collaborative Drafts. class AccessToCollaborativeDraftForm < Decidim::Form mimic :collaborative_draft attribute :id, String attribute :requester_user_id, String attribute :state, String validates :id, :requester_user_id, presence: true validates :state, presence: true, inclusion: { in: %w(open) } validate :existence_of_requester_in_requesters def collaborative_draft @collaborative_draft ||= Decidim::Proposals::CollaborativeDraft.find id if id end def requester_user @requester_user ||= Decidim::User.find_by(id: requester_user_id, organization: current_organization) if requester_user_id end private def existence_of_requester_in_requesters if collaborative_draft errors.add(:requester_user_id, :invalid) unless collaborative_draft.requesters.exists? requester_user_id end end end end end
Version data entries
28 entries across 28 versions & 1 rubygems