Sha256: bf8d568b7de68419b03f613732d3ade55fec3c74d10a5a1a222d58498e9587c2

Contents?: true

Size: 922 Bytes

Versions: 31

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    class MonitoringCommitteeMember < ApplicationRecord
      include Traceable
      include Loggable

      belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User", optional: true
      belongs_to :voting, foreign_key: "decidim_votings_voting_id", class_name: "Decidim::Votings::Voting", inverse_of: :monitoring_committee_members

      validate :user_and_voting_same_organization

      alias participatory_space voting

      def self.log_presenter_class_for(_log)
        Decidim::Votings::AdminLog::MonitoringCommitteeMemberPresenter
      end

      private

      # Private: check if the voting and the user have the same organization
      def user_and_voting_same_organization
        return if !voting || !user

        errors.add(:voting, :invalid) unless user.organization == voting.organization
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-elections-0.27.1 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.4 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.0 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.3 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.0.rc2 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.0.rc1 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.2 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.1 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.0 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.0.rc2 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.0.rc1 app/models/decidim/votings/monitoring_committee_member.rb