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.28.4 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.9 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.28.3 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.8 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.28.2 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.7 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.28.1 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.6 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.10 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.9 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.28.0 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.5 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.28.0.rc5 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.28.0.rc4 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.8 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.4 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.3 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.7 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.26.5 app/models/decidim/votings/monitoring_committee_member.rb
decidim-elections-0.27.2 app/models/decidim/votings/monitoring_committee_member.rb