aboutsummaryrefslogtreecommitdiff
blob: e76ebf5fd87708a5eaf7c5b94b46f15c3f7c7d1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
class Participation < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    irc_nick :string
    timestamps
  end

  belongs_to :participant, :class_name => 'User'
  belongs_to :agenda

  # --- Permissions --- #

  def create_permitted?
    false
  end

  def update_permitted?
    false
  end

  def destroy_permitted?
    false
  end

  def view_permitted?(field)
    true
  end

  def name
    participant.name
  end

  def self.mark_participations(results)
    participant_nicks = results.values.*.keys.flatten.uniq
    agenda = Agenda.current
    for nick in participant_nicks
      user = ::User.find_by_irc_nick(nick)
      unless user.council_member?
        user = Proxy.proxy_is(user).agenda_is(agenda)._?.first.council_member
      end
      next if user.nil?
      Participation.create! :irc_nick => user.irc_nick,
                            :participant => user,
                            :agenda => agenda
    end
  end
end