Module: ConferenceManager::Models::ConferenceManagerEvent::ClassMethods

Defined in:
lib/conference_manager/models/conference_manager_event.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_conference_manager_eventObject



19
20
21
# File 'lib/conference_manager/models/conference_manager_event.rb', line 19

def acts_as_conference_manager_event
  include ConferenceManager::Models::ConferenceManagerEvent::InstanceMethods
end

#included(base) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/conference_manager/models/conference_manager_event.rb', line 23

def included(base)
  base.class_eval do

    validate_on_create do |event|
      if event.uses_conference_manager?
        if event.recording_type == ::Event::RECORDING_TYPE.index(:manual)
        end_date_after_adjust = event.end_date + ::Event::EXTRA_TIME_FOR_EVENTS_WITH_MANUAL_REC
        else
        end_date_after_adjust = event.end_date
        end
        cm_e =
        ConferenceManager::Event.new(:name => event.name,
        :mode => event.cm_mode,
        :initDate => event.start_date,
        :endDate => end_date_after_adjust,
        :enable_web => "1",
        :enable_isabel => "1",
        :enable_sip => event.sip_interface?,
        :enable_httplivestreaming => "0",
        :isabel_bw => event.isabel_bw,
        :web_bw => WEB_BANDWIDTH[event.web_bw],
        :recording_bw => RECORDING_BANDWIDTH[event.recording_bw],
        :httplivestreaming_bw => WEB_BANDWIDTH[event.web_bw],
        :web_codec => WEB_CODEC[event.web_bw],
        :recording_codec => RECORDING_CODEC[event.recording_bw],
        :path => "attachments/conferences/#{event.permalink}")
        begin
          cm_e.save
          event.cm_event_id = cm_e.id
        rescue StandardError => e
        event.errors.add_to_base(e.to_s)
        end
      end
    end

    validate_on_update do |event|
      if !event.past? && event.uses_conference_manager? && (event.changed & CM_ATTRIBUTES).any?
        if event.recording_type == ::Event::RECORDING_TYPE.index(:manual)
        end_date_after_adjust = event.end_date + ::Event::EXTRA_TIME_FOR_EVENTS_WITH_MANUAL_REC
        else
        end_date_after_adjust = event.end_date
        end
        new_params = { :name => event.name,
          :mode => event.cm_mode,
          :initDate => event.start_date,
          :endDate => end_date_after_adjust,
          :enable_web => "1",
          :enable_isabel => "1",
          :enable_sip => event.sip_interface?,
          :enable_httplivestreaming => "0",
          :isabel_bw => event.isabel_bw,
          :web_bw => WEB_BANDWIDTH[event.web_bw],
          :recording_bw => RECORDING_BANDWIDTH[event.recording_bw],
          :httplivestreaming_bw => WEB_BANDWIDTH[event.web_bw],
          :web_codec => WEB_CODEC[event.web_bw],
          :recording_codec => RECORDING_CODEC[event.recording_bw],
          :path => "attachments/conferences/#{event.permalink}" }
        cm_event = event.cm_event
        cm_event.load(new_params)

        begin
          cm_event.save
        rescue  StandardError =>e
        event.errors.add_to_base(e.to_s)
        end
      end
    end

    before_destroy do |event|
      if event.uses_conference_manager?
        # Delete event in conference Manager
        begin
          cm_event = ConferenceManager::Event.find(event.cm_event_id)
          cm_event.destroy
        rescue ActiveResource::ResourceNotFound => e
          true
        else
        true
        end
      end
    end
  end
end