Sha256: 2e85e711b22766b8190c05cf1c80f4b14375a4628e08ba0c57e581f1fca8909e
Contents?: true
Size: 957 Bytes
Versions: 7
Compression:
Stored size: 957 Bytes
Contents
# frozen_string_literal: true module Decidim # This class gives a given User access to a given private ParticipatorySpacePrivateUser class ParticipatorySpacePrivateUser < ApplicationRecord include Decidim::DataPortability belongs_to :user, class_name: "Decidim::User", foreign_key: :decidim_user_id belongs_to :privatable_to, polymorphic: true validate :user_and_participatory_space_same_organization def self.user_collection(user) where(decidim_user_id: user.id) end def self.export_serializer Decidim::DataPortabilitySerializers::DataPortabilityParticipatorySpacePrivateUserSerializer end private # Private: check if the participatory space and the user have the same organization def user_and_participatory_space_same_organization return if !privatable_to || !user errors.add(:privatable_to, :invalid) unless user.organization == privatable_to.organization end end end
Version data entries
7 entries across 7 versions & 1 rubygems