decidim-meetings/app/models/decidim/meetings/meeting.rb in decidim-0.0.2 vs decidim-meetings/app/models/decidim/meetings/meeting.rb in decidim-0.0.3
- old
+ new
@@ -1,29 +1,25 @@
# frozen_string_literal: true
+
module Decidim
module Meetings
# The data store for a Meeting in the Decidim::Meetings component. It stores a
# title, description and any other useful information to render a custom meeting.
class Meeting < Meetings::ApplicationRecord
- belongs_to :feature, foreign_key: "decidim_feature_id", class_name: Decidim::Feature
- belongs_to :scope, foreign_key: "decidim_scope_id", class_name: Decidim::Scope
- belongs_to :category, foreign_key: "decidim_category_id", class_name: Decidim::Category
- has_one :organization, through: :feature
- validates :title, presence: true
+ include Decidim::Resourceable
+ include Decidim::HasAttachments
+ include Decidim::HasFeature
+ include Decidim::HasScope
+ include Decidim::HasCategory
- validate :scope_belongs_to_organization
- validate :category_belongs_to_organization
+ feature_manifest_name "meetings"
- private
+ validates :title, presence: true
- def scope_belongs_to_organization
- return unless scope
- errors.add(:scope, :invalid) unless feature.scopes.where(id: scope.id).exists?
- end
+ geocoded_by :address
- def category_belongs_to_organization
- return unless category
- errors.add(:category, :invalid) unless feature.categories.where(id: category.id).exists?
+ def closed?
+ closed_at.present?
end
end
end
end