popolo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +65 -7
  3. data/app/assets/javascripts/popolo.js +1 -0
  4. data/app/assets/stylesheets/popolo/bootstrap.min.scss +7 -0
  5. data/app/assets/stylesheets/popolo/main.css.scss +14 -0
  6. data/app/assets/stylesheets/popolo.css +3 -0
  7. data/app/controllers/popolo/memberships_controller.rb +7 -0
  8. data/app/controllers/popolo/organizations_controller.rb +0 -39
  9. data/app/controllers/popolo/people_controller.rb +1 -6
  10. data/app/controllers/popolo/posts_controller.rb +1 -1
  11. data/app/helpers/popolo_helper.rb +0 -8
  12. data/app/models/popolo/area.rb +20 -12
  13. data/app/models/popolo/contact_detail.rb +22 -0
  14. data/app/models/popolo/count.rb +24 -0
  15. data/app/models/popolo/date_string.rb +23 -0
  16. data/app/models/popolo/group_result.rb +15 -0
  17. data/app/models/popolo/identifier.rb +1 -1
  18. data/app/models/popolo/link.rb +7 -3
  19. data/app/models/popolo/membership.rb +34 -9
  20. data/app/models/popolo/motion.rb +37 -0
  21. data/app/models/popolo/organization.rb +37 -16
  22. data/app/models/popolo/other_name.rb +5 -5
  23. data/app/models/popolo/person.rb +57 -27
  24. data/app/models/popolo/post.rb +27 -13
  25. data/app/models/popolo/vote.rb +28 -0
  26. data/app/models/popolo/vote_event.rb +35 -0
  27. data/app/views/popolo/contact_details/_contact_detail.html.erb +17 -0
  28. data/app/views/popolo/identifiers/_identifier.html.erb +2 -0
  29. data/app/views/popolo/links/_link.html.erb +1 -0
  30. data/app/views/popolo/memberships/show.html.erb +81 -0
  31. data/app/views/popolo/organizations/index.html.erb +16 -1
  32. data/app/views/popolo/organizations/show.html.erb +146 -1
  33. data/app/views/popolo/other_names/other_name.html.erb +9 -0
  34. data/app/views/popolo/people/show.html.erb +120 -0
  35. data/app/views/popolo/posts/show.html.erb +90 -0
  36. data/config/routes.rb +4 -12
  37. data/lib/generators/popolo_generator.rb +4 -0
  38. data/lib/popolo/initializers/pupa_compat.rb +11 -0
  39. data/lib/popolo/version.rb +1 -1
  40. data/lib/popolo.rb +17 -5
  41. data/spec/controllers/popolo/memberships_controller_spec.rb +16 -0
  42. data/spec/controllers/popolo/organizations_controller_spec.rb +1 -47
  43. data/spec/controllers/popolo/people_controller_spec.rb +0 -14
  44. data/spec/controllers/popolo/posts_controller_spec.rb +0 -8
  45. data/spec/dummy/app/assets/stylesheets/application.css +1 -0
  46. data/spec/dummy/app/models/cat.rb +0 -3
  47. data/spec/dummy/app/models/dog.rb +0 -7
  48. data/spec/dummy/app/views/layouts/application.html.erb +2 -0
  49. data/spec/dummy/config/locales/en.yml +30 -0
  50. data/spec/dummy/config/routes.rb +1 -1
  51. data/spec/dummy/log/test.log +8670 -48801
  52. data/spec/factories.rb +3 -8
  53. data/spec/models/popolo/{source_spec.rb → contact_detail_spec.rb} +2 -2
  54. data/spec/models/popolo/count_spec.rb +7 -0
  55. data/spec/models/popolo/date_string_spec.rb +121 -0
  56. data/spec/models/popolo/group_result_spec.rb +7 -0
  57. data/spec/models/popolo/membership_spec.rb +1 -17
  58. data/spec/models/popolo/motion_spec.rb +5 -0
  59. data/spec/models/popolo/organization_spec.rb +1 -19
  60. data/spec/models/popolo/other_name_spec.rb +1 -17
  61. data/spec/models/popolo/person_spec.rb +23 -19
  62. data/spec/models/popolo/post_spec.rb +1 -3
  63. data/spec/models/popolo/vote_event_spec.rb +4 -0
  64. data/spec/models/popolo/vote_spec.rb +4 -0
  65. data/spec/popolo_spec.rb +65 -0
  66. data/spec/routing/popolo/memberships_routing_spec.rb +11 -0
  67. data/spec/routing/popolo/organizations_routing_spec.rb +1 -19
  68. data/spec/routing/popolo/people_routing_spec.rb +1 -11
  69. data/spec/routing/popolo/posts_routing_spec.rb +1 -7
  70. data/spec/spec_helper.rb +6 -1
  71. data/spec/support/shared_examples.rb +19 -0
  72. metadata +99 -109
  73. data/app/assets/javascripts/popolo/application.js +0 -13
  74. data/app/assets/stylesheets/popolo/application.css +0 -13
  75. data/app/controllers/popolo/areas_controller.rb +0 -43
  76. data/app/models/popolo/address.rb +0 -27
  77. data/app/models/popolo/event.rb +0 -46
  78. data/app/models/popolo/source.rb +0 -29
  79. data/app/views/popolo/addresses/_address.html.erb +0 -16
  80. data/app/views/popolo/areas/index.html.erb +0 -1
  81. data/app/views/popolo/areas/show.html.erb +0 -1
  82. data/app/views/popolo/areas_or_organizations/_breadcrumb.html.erb +0 -13
  83. data/app/views/popolo/areas_or_organizations/_index.html.erb +0 -31
  84. data/app/views/popolo/areas_or_organizations/_show.html.erb +0 -18
  85. data/app/views/popolo/organizations/post.html.erb +0 -27
  86. data/app/views/popolo/organizations/posts.html.erb +0 -23
  87. data/app/views/popolo/people/index.html.erb +0 -0
  88. data/app/views/popolo/posts/index.html.erb +0 -0
  89. data/lib/popolo/mixins/eventable.rb +0 -15
  90. data/lib/popolo/mixins/sluggable.rb +0 -66
  91. data/spec/controllers/popolo/areas_controller_spec.rb +0 -53
  92. data/spec/dummy/log/development.log +0 -6
  93. data/spec/models/popolo/address_spec.rb +0 -4
  94. data/spec/models/popolo/event_spec.rb +0 -7
  95. data/spec/popolo/mixins/sluggable_spec.rb +0 -153
  96. data/spec/routing/popolo/areas_routing_spec.rb +0 -25
@@ -3,7 +3,7 @@ module Popolo
3
3
  class Identifier
4
4
  include Mongoid::Document
5
5
 
6
- embedded_in :organization, class_name: 'Popolo::Organization'
6
+ embedded_in :identifiable, polymorphic: true
7
7
 
8
8
  # An issued identifier, e.g. a DUNS number.
9
9
  field :identifier, type: String
@@ -1,16 +1,20 @@
1
1
  module Popolo
2
- # A URL for a document about a person.
2
+ # A URL.
3
3
  class Link
4
4
  include Mongoid::Document
5
5
 
6
- embedded_in :person, class_name: 'Popolo::Person'
6
+ embedded_in :linkable, polymorphic: true
7
7
 
8
- # A URL for a document about a person.
8
+ # A URL.
9
9
  field :url, type: String
10
10
  # A note, e.g. 'Wikipedia page'.
11
11
  field :note, type: String
12
12
 
13
13
  validates_presence_of :url
14
14
  # @note Add URL validation to match JSON Schema?
15
+
16
+ def to_s
17
+ note || url
18
+ end
15
19
  end
16
20
  end
@@ -2,24 +2,49 @@ module Popolo
2
2
  # A relationship between a person and an organization.
3
3
  class Membership
4
4
  include Mongoid::Document
5
+ include Mongoid::Timestamps
5
6
 
6
- # An area related to the membership, e.g. an electoral riding.
7
+ store_in Popolo.storage_options_per_class.fetch(:Membership, Popolo.storage_options)
8
+
9
+ # The geographic area to which the membership is related.
7
10
  belongs_to :area, index: true, class_name: 'Popolo::Area'
8
11
  # The person who is a party to the relationship.
9
- belongs_to :organization, index: true, class_name: 'Popolo::Organization'
10
- # The organization that is a party to the relationship.
11
12
  belongs_to :person, index: true, class_name: 'Popolo::Person'
13
+ # The organization that is a party to the relationship.
14
+ belongs_to :organization, index: true, class_name: 'Popolo::Organization'
15
+ # The organization on whose behalf the person is a party to the relationship.
16
+ belongs_to :on_behalf_of, index: true, class_name: 'Popolo::Organization'
17
+ # The post held by the person in the organization through this membership.
18
+ belongs_to :post, index: true, class_name: 'Popolo::Post'
19
+ # Means of contacting the person who is a party to the relationship.
20
+ embeds_many :contact_details, as: :contactable, class_name: 'Popolo::ContactDetail'
21
+ # URLs to documents about the membership.
22
+ embeds_many :links, as: :linkable, class_name: 'Popolo::Link'
23
+ # URLs to documents from which the membership is derived.
24
+ embeds_many :sources, as: :linkable, class_name: 'Popolo::Link'
12
25
 
13
- # The role that the person fulfills in the organization. Roles should
14
- # preferably belong to a controlled vocabulary.
26
+ # A label describing the membership.
27
+ field :label, type: String
28
+ # The role that the person fulfills in the organization.
15
29
  field :role, type: String
16
30
  # The date on which the relationship began.
17
- field :start_date, type: String
31
+ field :start_date, type: DateString
18
32
  # The date on which the relationship ended.
19
- field :end_date, type: String
33
+ field :end_date, type: DateString
20
34
 
21
35
  validates_presence_of :organization_id, :person_id
22
- validates_format_of :start_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
23
- validates_format_of :end_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
36
+ validates_format_of :start_date, with: DATE_STRING_FORMAT, allow_blank: true
37
+ validates_format_of :end_date, with: DATE_STRING_FORMAT, allow_blank: true
38
+
39
+ def to_s(options = {})
40
+ label || case options[:format]
41
+ when :person
42
+ person.to_s
43
+ when :organization
44
+ organization.to_s
45
+ else
46
+ "#{organization.to_s} / #{person.to_s}"
47
+ end
48
+ end
24
49
  end
25
50
  end
@@ -0,0 +1,37 @@
1
+ module Popolo
2
+ # A formal step to introduce a matter for consideration by an organization.
3
+ class Motion
4
+ include Mongoid::Document
5
+ include Mongoid::Timestamps
6
+
7
+ store_in Popolo.storage_options_per_class.fetch(:Motion, Popolo.storage_options)
8
+
9
+ # The organization in which the motion is proposed.
10
+ belongs_to :organization, class_name: 'Popolo::Organization'
11
+ # The legislative session in which the motion is proposed.
12
+ # @todo belongs to :legislative_session, class_name: 'Popolo::Event'
13
+ # The person who proposed the motion.
14
+ belongs_to :creator, class_name: 'Popolo::Person'
15
+ # Events at which people vote on the motion.
16
+ has_many :vote_events, class_name: 'Popolo::VoteEvent', dependent: :destroy
17
+ # URLs to documents from which the motion is derived.
18
+ embeds_many :sources, as: :linkable, class_name: 'Popolo::Link'
19
+
20
+ # The transcript or text of the motion.
21
+ field :text, type: String
22
+ # A motion category, e.g. adjournment.
23
+ field :classification, type: String
24
+ # The date on which the motion was proposed.
25
+ field :date, type: DateString
26
+ # The requirement for the motion to be adopted.
27
+ field :requirement, type: String
28
+ # The result of the motion.
29
+ field :result, type: String
30
+
31
+ validates_format_of :date, with: DATE_STRING_FORMAT, allow_blank: true
32
+
33
+ def to_s
34
+ text.to_s[0...140]
35
+ end
36
+ end
37
+ end
@@ -1,32 +1,53 @@
1
1
  module Popolo
2
2
  # A group with a common purpose or reason for existence that goes beyond the
3
- # set of people belonging to it, e.g. a political structure.
3
+ # set of people belonging to it.
4
4
  class Organization
5
5
  include Mongoid::Document
6
+ include Mongoid::Timestamps
6
7
  include Mongoid::Tree
7
8
 
8
- include Popolo::Sluggable
9
- index({slug: 1, parent_id: 1}, unique: true)
9
+ store_in Popolo.storage_options_per_class.fetch(:Organization, Popolo.storage_options)
10
10
 
11
- # An area related to the organization, e.g. a region or country.
11
+ # The geographic area to which the organization is related.
12
12
  belongs_to :area, index: true, class_name: 'Popolo::Area'
13
13
  # The relationships to which the organization is a party.
14
- has_many :memberships, class_name: 'Popolo::Membership', dependent: :destroy
15
- # The posts within the organization.
14
+ has_many :memberships, class_name: 'Popolo::Membership', dependent: :destroy, inverse_of: :organization
15
+ # The organization in which the motion is proposed.
16
+ has_many :motions, class_name: 'Popolo::Motion', dependent: :destroy
17
+ # Posts within the organization.
16
18
  has_many :posts, class_name: 'Popolo::Post', dependent: :destroy
17
- # The organization's alternate or former names.
19
+ # The organization whose members are voting.
20
+ has_many :vote_events, class_name: 'Popolo::VoteEvent', dependent: :destroy
21
+ # The organization that is voting.
22
+ has_many :votes, as: :voter, class_name: 'Popolo::Vote'
23
+ # Alternate or former names.
18
24
  embeds_many :other_names, as: :nameable, class_name: 'Popolo::OtherName'
19
- # The organization's issued identifiers.
20
- embeds_many :identifiers, class_name: 'Popolo::Identifier'
25
+ # Issued identifiers.
26
+ embeds_many :identifiers, as: :identifiable, class_name: 'Popolo::Identifier'
27
+ # Means of contacting the organization.
28
+ embeds_many :contact_details, as: :contactable, class_name: 'Popolo::ContactDetail'
29
+ # URLs to documents about the organization.
30
+ embeds_many :links, as: :linkable, class_name: 'Popolo::Link'
31
+ # URLs to documents from which the organization is derived.
32
+ embeds_many :sources, as: :linkable, class_name: 'Popolo::Link'
21
33
 
22
- # The organization's category.
34
+ # A primary name, e.g. a legally recognized name.
35
+ field :name, type: String
36
+ # An organization category, e.g. committee.
23
37
  field :classification, type: String
24
- # The organization's date of founding in ISO 8601:2004 format.
25
- field :founding_date, type: String
26
- # The organization's date of dissolution in ISO 8601:2004 format.
27
- field :dissolution_date, type: String
38
+ # A date of founding.
39
+ field :founding_date, type: DateString
40
+ # A date of dissolution.
41
+ field :dissolution_date, type: DateString
42
+ # A URL of an image.
43
+ field :image, type: String
28
44
 
29
- validates_format_of :founding_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
30
- validates_format_of :dissolution_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
45
+ validates_format_of :founding_date, with: DATE_STRING_FORMAT, allow_blank: true
46
+ validates_format_of :dissolution_date, with: DATE_STRING_FORMAT, allow_blank: true
47
+ # @note Add URL validation to match JSON Schema?
48
+
49
+ def to_s
50
+ name
51
+ end
31
52
  end
32
53
  end
@@ -8,14 +8,14 @@ module Popolo
8
8
  # An alternate or former name.
9
9
  field :name, type: String
10
10
  # The date on which the name was adopted.
11
- field :start_date, type: String
11
+ field :start_date, type: DateString
12
12
  # The date on which the name was abandoned.
13
- field :end_date, type: String
14
- # A note, e.g. "Birth name".
13
+ field :end_date, type: DateString
14
+ # A note, e.g. 'Birth name'.
15
15
  field :note, type: String
16
16
 
17
17
  validates_presence_of :name
18
- validates_format_of :start_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
19
- validates_format_of :end_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
18
+ validates_format_of :start_date, with: DATE_STRING_FORMAT, allow_blank: true
19
+ validates_format_of :end_date, with: DATE_STRING_FORMAT, allow_blank: true
20
20
  end
21
21
  end
@@ -2,48 +2,78 @@ module Popolo
2
2
  # A real person, alive or dead.
3
3
  class Person
4
4
  include Mongoid::Document
5
+ include Mongoid::Timestamps
5
6
 
6
- include Popolo::Sluggable
7
- index({slug: 1}, unique: true)
7
+ store_in Popolo.storage_options_per_class.fetch(:Person, Popolo.storage_options)
8
8
 
9
9
  # The relationships to which the person is a party.
10
- has_many :memberships, class_name: 'Popolo::Membership'
11
- # The posts held by the person.
12
- has_many :posts, class_name: 'Popolo::Post'
13
- # The person's alternate or former names.
10
+ has_many :memberships, class_name: 'Popolo::Membership', dependent: :destroy
11
+ # The person who proposed the motion.
12
+ has_many :motions, class_name: 'Popolo::Motion'
13
+ # The person that is voting.
14
+ has_many :votes, as: :voter, class_name: 'Popolo::Vote'
15
+ # Alternate or former names.
14
16
  embeds_many :other_names, as: :nameable, class_name: 'Popolo::OtherName'
15
- # Links to pages about this person, e.g. Wikipedia, or to accounts this
16
- # person has on other websites, e.g. Twitter.
17
- embeds_many :links, class_name: 'Popolo::Link'
17
+ # Issued identifiers.
18
+ embeds_many :identifiers, as: :identifiable, class_name: 'Popolo::Identifier'
19
+ # Means of contacting the person.
20
+ embeds_many :contact_details, as: :contactable, class_name: 'Popolo::ContactDetail'
21
+ # URLs to documents about the person.
22
+ embeds_many :links, as: :linkable, class_name: 'Popolo::Link'
23
+ # URLs to documents from which the person is derived.
24
+ embeds_many :sources, as: :linkable, class_name: 'Popolo::Link'
18
25
 
19
- # The person's family name.
26
+ # A person's preferred full name.
27
+ field :name, type: String
28
+ # One or more family names.
20
29
  field :family_name, type: String
21
- # The person's given name.
30
+ # One or more primary given names.
22
31
  field :given_name, type: String
23
- # An additional name, e.g. a middle name.
32
+ # One or more secondary given names.
24
33
  field :additional_name, type: String
25
- # An honorific prefix before the person's name, e.g. "Dr.".
34
+ # One or more honorifics preceding a person's name.
26
35
  field :honorific_prefix, type: String
27
- # An honorific suffix after the person's name, e.g. "Jr.".
36
+ # One or more honorifics following a person's name.
28
37
  field :honorific_suffix, type: String
29
- # The person's email address.
38
+ # One or more patronymic names.
39
+ field :patronymic_name, type: String
40
+ # A name to use in an lexicographically ordered list.
41
+ field :sort_name, type: String
42
+ # A preferred email address.
30
43
  field :email, type: String
31
- # The person's gender, e.g. "male", "female" or another value.
44
+ # A gender.
32
45
  field :gender, type: String
33
- # The person's date of birth in ISO 8601:2004 format.
34
- field :birth_date, type: String
35
- # The person's date of death in ISO 8601:2004 format.
36
- field :death_date, type: String
37
- # The URL of the person's head shot.
46
+ # A date of birth.
47
+ field :birth_date, type: DateString
48
+ # A date of death.
49
+ field :death_date, type: DateString
50
+ # A URL of a head shot.
38
51
  field :image, type: String
39
- # The person's one-line biography.
52
+ # A one-line account of a person's life.
40
53
  field :summary, type: String
41
- # The person's extended biography.
54
+ # An extended account of a person's life.
42
55
  field :biography, type: String
56
+ # A national identity.
57
+ field :national_identity, type: String
43
58
 
44
- # @note Add email address validation to match JSON Schema?
45
- # @note Add URL validation to match JSON Schema?
46
- validates_format_of :birth_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
47
- validates_format_of :death_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
59
+ validates_format_of :birth_date, with: DATE_STRING_FORMAT, allow_blank: true
60
+ validates_format_of :death_date, with: DATE_STRING_FORMAT, allow_blank: true
61
+ # @note Add email address validation and URL validation to match JSON Schema?
62
+
63
+ def to_s
64
+ if name.blank?
65
+ if given_name.present? && family_name.present?
66
+ "#{given_name} #{family_name}"
67
+ elsif given_name.present?
68
+ given_name
69
+ elsif family_name.present?
70
+ family_name
71
+ else
72
+ name
73
+ end
74
+ else
75
+ name
76
+ end
77
+ end
48
78
  end
49
79
  end
@@ -1,25 +1,39 @@
1
1
  module Popolo
2
- # A position in an organization that exists independently of the person
3
- # holding it.
2
+ # A position that exists independent of the person holding it.
4
3
  class Post
5
4
  include Mongoid::Document
5
+ include Mongoid::Timestamps
6
6
 
7
- include Popolo::Sluggable
8
- index({slug: 1, organization_id: 1}, unique: true)
7
+ store_in Popolo.storage_options_per_class.fetch(:Post, Popolo.storage_options)
9
8
 
10
- # An area related to the post, e.g. an electoral riding.
9
+ # The geographic area to which the post is related.
11
10
  belongs_to :area, index: true, class_name: 'Popolo::Area'
12
- # The organization in which the post exists.
11
+ # The organization in which the post is held.
13
12
  belongs_to :organization, index: true, class_name: 'Popolo::Organization'
14
- # The person holding the post.
15
- belongs_to :person, index: true, class_name: 'Popolo::Person'
16
- # The address at which the post is based.
17
- embeds_many :addresses, as: :addressable, class_name: 'Popolo::Address'
13
+ # The memberships through which people hold the post in the organization.
14
+ has_many :memberships, class_name: 'Popolo::Membership'
15
+ # Means of contacting the holder of the post.
16
+ embeds_many :contact_details, as: :contactable, class_name: 'Popolo::ContactDetail'
17
+ # URLs to documents about the post.
18
+ embeds_many :links, as: :linkable, class_name: 'Popolo::Link'
19
+ # URLs to documents from which the post is derived.
20
+ embeds_many :sources, as: :linkable, class_name: 'Popolo::Link'
18
21
 
19
- # The role that the holder of the post fulfills. Roles should preferably
20
- # belong to a controlled vocabulary.
22
+ # A label describing the post.
23
+ field :label, type: String
24
+ # The function that the holder of the post fulfills.
21
25
  field :role, type: String
26
+ # The date on which the post was created.
27
+ field :start_date, type: DateString
28
+ # The date on which the post was eliminated.
29
+ field :end_date, type: DateString
22
30
 
23
- validates_presence_of :role, :organization_id
31
+ validates_presence_of :organization_id
32
+ validates_format_of :start_date, with: DATE_STRING_FORMAT, allow_blank: true
33
+ validates_format_of :end_date, with: DATE_STRING_FORMAT, allow_blank: true
34
+
35
+ def to_s
36
+ label
37
+ end
24
38
  end
25
39
  end
@@ -0,0 +1,28 @@
1
+ module Popolo
2
+ # A voter's vote in a vote event.
3
+ class Vote
4
+ include Mongoid::Document
5
+
6
+ store_in Popolo.storage_options_per_class.fetch(:Vote, Popolo.storage_options)
7
+
8
+ # A vote event.
9
+ belongs_to :vote_event, class_name: 'Popolo::VoteEvent'
10
+ # The person or organization that is voting.
11
+ belongs_to :voter, polymorphic: true
12
+ # The voter's primary political group.
13
+ belongs_to :group, class_name: 'Popolo::Organization'
14
+ # The person with whom the voter is paired.
15
+ belongs_to :pair, class_name: 'Popolo::Person'
16
+
17
+ # The option chosen by the voter, whether actively or passively.
18
+ field :option, type: String
19
+ # The voter's role in the event.
20
+ field :role, type: String
21
+ # The weight of the voter's vote.
22
+ field :weight, type: Float, default: 1.0
23
+
24
+ def to_s
25
+ "#{voter.name}: #{option}"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,35 @@
1
+ module Popolo
2
+ # An event at which people's votes are recorded.
3
+ class VoteEvent
4
+ include Mongoid::Document
5
+ include Mongoid::Timestamps
6
+
7
+ store_in Popolo.storage_options_per_class.fetch(:VoteEvent, Popolo.storage_options)
8
+
9
+ # The organization whose members are voting.
10
+ belongs_to :organization, class_name: 'Popolo::Organization'
11
+ # The legislative session in which the vote occurs.
12
+ # @todo belongs to :legislative_session, class_name: 'Popolo::Event'
13
+ # The motion being decided.
14
+ belongs_to :motion, class_name: 'Popolo::Motion'
15
+ # The result of the vote event within groups of voters.
16
+ embeds_many :group_results, class_name: 'Popolo::GroupResult'
17
+ # The number of votes for options.
18
+ has_many :counts, class_name: 'Popolo::Count', dependent: :destroy
19
+ # Voters' votes.
20
+ has_many :votes, class_name: 'Popolo::Vote', dependent: :destroy
21
+
22
+ # An issued identifier.
23
+ field :identifier, type: String
24
+ # The date on which the relationship began.
25
+ field :start_date, type: DateTime
26
+ # The date on which the relationship ended.
27
+ field :end_date, type: DateTime
28
+ # The result of the vote event.
29
+ field :result, type: String
30
+
31
+ def to_s
32
+ identifier
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ <dt>
2
+ <% if contact_detail.label? %>
3
+ <%= contact_detail.label %>
4
+ <% else %>
5
+ <%=t contact_detail.type, scope: [:popolo, :contact_details, :types], default: contact_detail.type %>
6
+ <% end %>
7
+ </dt>
8
+ <dd>
9
+ <% if contact_detail.type == 'email' %>
10
+ <%= mail_to contact_detail.value %>
11
+ <% else %>
12
+ <%= contact_detail.value %>
13
+ <% end %>
14
+ <% if contact_detail.note? %>
15
+ <span class="label label-info"><%= contact_detail.note %></span>
16
+ <% end %>
17
+ </dd>
@@ -0,0 +1,2 @@
1
+ <dt><%= identifier.scheme %></dt>
2
+ <dd><%= identifier.identifier %></dd>
@@ -0,0 +1 @@
1
+ <li><%= link_to link, link.url %></li>
@@ -0,0 +1,81 @@
1
+ <nav>
2
+ <ol class="breadcrumb">
3
+ <li><%= link_to Popolo::Organization.model_name.human(count: Float::INFINITY), organizations_path %></li>
4
+ <% @membership.organization.ancestors_and_self.each do |ancestor| %>
5
+ <li><%= link_to ancestor, ancestor %></li>
6
+ <% end %>
7
+ <li class="active"><%= @membership %></li>
8
+ </ol>
9
+ </nav>
10
+
11
+ <section>
12
+ <header class="page-header">
13
+ <div class="media">
14
+ <div class="media-body">
15
+ <h1 class="media-heading">
16
+ <%= @membership %>
17
+ </h1>
18
+ </div>
19
+ </div>
20
+ </header>
21
+
22
+ <dl>
23
+ <dt><%= Popolo::Membership.human_attribute_name(:organization) %></dt>
24
+ <dd><%= link_to @membership.organization, @membership.organization %></dd>
25
+ <dt><%= Popolo::Membership.human_attribute_name(:person) %></dt>
26
+ <dd><%= link_to @membership.person, @membership.person %></dd>
27
+ <% if @membership.on_behalf_of? %>
28
+ <dt><%= Popolo::Membership.human_attribute_name(:on_behalf_of) %></dt>
29
+ <dd><%= link_to @membership.on_behalf_of, @membership.on_behalf_of %></dd>
30
+ <% end %>
31
+ <% if @membership.post? %>
32
+ <dt><%= Popolo::Membership.human_attribute_name(:post) %></dt>
33
+ <dd><%= link_to @membership.post, @membership.post %></dd>
34
+ <% end %>
35
+ <% if @membership.role? %>
36
+ <dt><%= Popolo::Membership.human_attribute_name(:role) %></dt>
37
+ <dd><%= @membership.role %></dd>
38
+ <% end %>
39
+ <% if @membership.start_date? %>
40
+ <dt><%= Popolo::Membership.human_attribute_name(:start_date) %></dt>
41
+ <dd><%=l @membership.start_date %></dd>
42
+ <% end %>
43
+ <% if @membership.end_date? %>
44
+ <dt><%= Popolo::Membership.human_attribute_name(:end_date) %></dt>
45
+ <dd><%=l @membership.end_date %></dd>
46
+ <% end %>
47
+ </dl>
48
+
49
+ <aside>
50
+ <% unless @membership.contact_details.empty? %>
51
+ <section>
52
+ <header>
53
+ <h2><%= Popolo::ContactDetail.model_name.human(count: @membership.contact_details.size) %></h2>
54
+ </header>
55
+ <dl class="dl-horizontal">
56
+ <%= render @membership.contact_details %>
57
+ </dl>
58
+ </section>
59
+ <% end %>
60
+ <% unless @membership.links.empty? %>
61
+ <section>
62
+ <header>
63
+ <h2><%= Popolo::Link.model_name.human(count: @membership.links.size) %></h2>
64
+ </header>
65
+ <ul>
66
+ <%= render @membership.links %>
67
+ </ul>
68
+ </section>
69
+ <% end %>
70
+ <% unless @membership.sources.empty? %>
71
+ <section>
72
+ <header>
73
+ <h2><%=t 'popolo/source', count: @membership.sources.size, scope: [:popolo] %></h2>
74
+ </header>
75
+ <ul>
76
+ <%= render @membership.sources %>
77
+ </ul>
78
+ </section>
79
+ <% end %>
80
+ </aside>
81
+ </section>
@@ -1 +1,16 @@
1
- <%= render partial: 'popolo/areas_or_organizations/index', locals: {collection: @organizations, object: @organization} %>
1
+ <% @organizations.group_by(&:classification).each do |classification,organizations| %>
2
+ <section>
3
+ <header>
4
+ <h1>
5
+ <%=t classification, count: organizations.size, scope: [:popolo, :organizations, :classifications], default: classification %>
6
+ </h1>
7
+ </header>
8
+ <ol>
9
+ <% organizations.each do |organization| %>
10
+ <li>
11
+ <%= link_to organization, organization %>
12
+ </li>
13
+ <% end %>
14
+ </ol>
15
+ </section>
16
+ <% end %>