Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Location urls field to singular website. #268

Merged
merged 1 commit into from
Nov 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/concerns/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ module Search
Location.where(locations[:admin_emails].matches("%#{email}%").
or(locations[:emails].matches("%#{email}%")))
else
# where('urls ilike :q or emails ilike :q or admin_emails @@ :p', q: "%#{domain}%", p: email)
# where('website ilike :q or emails ilike :q or admin_emails @@ :p', q: "%#{domain}%", p: email)
Location.where(locations[:admin_emails].matches("%#{email}%").
or(locations[:urls].matches("%#{domain}%")).
or(locations[:website].matches("%#{domain}%")).
or(locations[:emails].matches("%#{domain}%")))
end
end)
Expand Down
16 changes: 5 additions & 11 deletions app/models/location.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Location < ActiveRecord::Base
attr_accessible :accessibility, :active, :admin_emails, :alternate_name,
:description, :emails, :languages, :latitude,
:longitude, :name, :short_desc, :transportation, :urls,
:longitude, :name, :short_desc, :transportation, :website,
:virtual, :address_attributes, :contacts_attributes,
:mail_address_attributes, :phones_attributes,
:services_attributes, :regular_schedules_attributes,
Expand Down Expand Up @@ -58,11 +58,7 @@ class Location < ActiveRecord::Base
## displayed in the ohana-web-search client to suit your needs.
# validates :short_desc, length: { maximum: 200 }

# Custom validation for values within arrays.
# For example, the urls field is an array that can contain multiple URLs.
# To be able to validate each URL in the array, we have to use a
# custom array validator. See app/validators/array_validator.rb
validates :urls, array: { url: true }
validates :website, url: true

validates :languages, pg_array: true

Expand All @@ -88,12 +84,10 @@ class Location < ActiveRecord::Base

serialize :emails, Array

serialize :urls, Array
auto_strip_attributes :description, :name, :short_desc, :transportation,
:website

auto_strip_attributes :description, :name, :short_desc,
:transportation

auto_strip_attributes :admin_emails, :emails, :urls,
auto_strip_attributes :admin_emails, :emails,
reject_blank: true, nullify: false

extend FriendlyId
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/location_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class LocationSerializer < ActiveModel::Serializer
attributes :id, :active, :accessibility, :admin_emails, :alternate_name,
:coordinates, :description, :emails, :languages,
:latitude, :longitude, :name, :short_desc, :slug, :transportation,
:updated_at, :urls, :url
:website, :updated_at, :url

has_one :address
has_many :contacts
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/locations_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class LocationsSerializer < ActiveModel::Serializer
attributes :id, :active, :admin_emails, :alternate_name, :coordinates,
:description, :latitude, :longitude, :name, :short_desc, :slug,
:updated_at, :urls, :contacts_url, :services_url, :url
:website, :updated_at, :contacts_url, :services_url, :url

has_one :address
has_one :organization, serializer: LocationsOrganizationSerializer
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/locations/forms/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
= render 'admin/shared/forms/hours', f: f
= render 'admin/shared/forms/holiday_hours', f: f
= render 'admin/locations/forms/transportation', f: f
= render 'admin/locations/forms/urls', f: f
= render 'admin/shared/forms/website', f: f
= render 'admin/locations/forms/accessibility', f: f
4 changes: 0 additions & 4 deletions app/views/admin/locations/forms/_url_fields.html.haml

This file was deleted.

17 changes: 0 additions & 17 deletions app/views/admin/locations/forms/_urls.html.haml

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/admin/organizations/forms/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
= render 'admin/organizations/forms/licenses', f: f
= render 'admin/organizations/forms/tax_id', f: f
= render 'admin/organizations/forms/tax_status', f: f
= render 'admin/organizations/forms/website', f: f
= render 'admin/shared/forms/website', f: f
= render 'admin/locations/forms/phones', f: f
2 changes: 1 addition & 1 deletion app/views/admin/services/forms/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
= render 'admin/services/forms/required_documents', f: f
= render 'admin/services/forms/service_areas', f: f
= render 'admin/services/forms/status', f: f
= render 'admin/services/forms/website', f: f
= render 'admin/shared/forms/website', f: f
= render 'admin/services/forms/wait', f: f
= render 'admin/services/forms/categories', f: f
= render 'admin/services/forms/keywords', f: f
7 changes: 0 additions & 7 deletions app/views/admin/services/forms/_website.html.haml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.inst-box
%header
= f.label :website, 'Organization Website'
= f.label :website, "#{f.object.class} Website"
= field_set_tag do
.row
.col-sm-6
Expand Down
Binary file modified data/ohana_api_development.dump
Binary file not shown.
Loading