forked from OpenNeo/impress
Emi Matchu
2667ed49ba
Now that DTI 2020 has been deployed without references to the translations tables, we can stop keeping them in sync! Next step is to drop the tables and be done with them altogether! (I have a backup of the public data for this too, as does this repo!)
23 lines
660 B
Ruby
23 lines
660 B
Ruby
class Zone < ActiveRecord::Base
|
|
# When selecting zones that an asset occupies, we allow the zone to set
|
|
# whether or not the zone is "sometimes" occupied. This is false by default.
|
|
attr_writer :sometimes
|
|
|
|
scope :alphabetical, -> { order(:label) }
|
|
scope :matching_label, ->(label) {
|
|
where(plain_label: Zone.plainify_label(label))
|
|
}
|
|
scope :for_items, -> { where(arel_table[:type_id].gt(1)) }
|
|
|
|
def as_json(options={})
|
|
super({only: [:id, :depth, :label]}.merge(options))
|
|
end
|
|
|
|
def uncertain_label
|
|
@sometimes ? "#{label} sometimes" : label
|
|
end
|
|
|
|
def self.plainify_label(label)
|
|
label.delete('\- /').parameterize
|
|
end
|
|
end
|