Skip to content
Snippets Groups Projects
Select Git revision
  • 24389d21a94910fef6b12fc2cdb1ad7a024b9e03
  • master default protected
  • ldap_user_conn_test
3 results

ldap_server_entries_add.ldif

Blame
  • Forked from uffd / uffd
    Source project has a limited visibility.
    session.rb 1.13 KiB
    class Session < ApplicationRecord
      belongs_to :conference
      belongs_to :stage
      has_many :assignments
      has_many :users, through: :assignments
      has_many :session_speakers, dependent: :destroy
      has_many :speakers, through: :session_speakers
    
      scope :scheduled, -> { where(status: 'scheduled') }
      scope :future, -> { where(starts_at: Time.now..) }
    
      validates :ref_id, uniqueness: { scope: :conference_id }
    
      after_update :notify_if_changed
    
      self.implicit_order_column = :starts_at
    
      def to_param
        ref_id
      end
    
      def starts_at
        super.in_time_zone(conference.time_zone)
      end
    
      def ends_at
        super.in_time_zone(conference.time_zone)
      end
    
      def is_interpreted?
        is_relevant?
      end
    
      def is_relevant?
        RelevantStage.exists?(stage:)
      end
    
      def translators_needed?
        is_interpreted? && assignments.length < 2
      end
    
      def backup_needed?
        return false
      end
    
      def assignees?
        assignments.length.positive?
      end
    
      private
    
      def notify_if_changed
        return if new_record?
        if saved_changes.present?
          ActiveSupport::Notifications.instrument("session.updated", record: self, changes: saved_changes)
        end
      end
    end