Skip to content

Commit

Permalink
organization_type and focus area for providers. datacite/datacite#548
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 24, 2018
1 parent eab5857 commit 5df87e3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def set_provider
def safe_params
fail JSON::ParserError, "You need to provide a payload following the JSONAPI spec" unless params[:data].present?
ActiveModelSerializers::Deserialization.jsonapi_parse!(
params, only: [:name, :symbol, :description, :website, :joined, "institution-type", :phone, "contact-name", "contact-email", "is_active", "password-input", :country],
keys: { "institution-type" => :institution_type, "contact-name" => :contact_name, "contact-email" => :contact_email, :country => :country_code, "is-active" => :is_active, "password-input" => :password_input }
params, only: [:name, :symbol, :description, :website, :joined, "organization-type", "focus-area", :phone, "contact-name", "contact-email", "is_active", "password-input", :country],
keys: { "organization-type" => :organization_type, "focus-area" => :focus_area, "contact-name" => :contact_name, "contact-email" => :contact_email, :country => :country_code, "is-active" => :is_active, "password-input" => :password_input }
)
end
end
2 changes: 1 addition & 1 deletion app/serializers/member_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MemberSerializer
set_id :uid
# don't cache members, as they use the provider model

attributes :title, :description, :member_type, :institution_type, :region, :country, :year, :logo_url, :email, :website, :phone, :joined, :created, :updated
attributes :title, :description, :member_type, :organization_type, :focus_area, :region, :country, :year, :logo_url, :email, :website, :phone, :joined, :created, :updated

attribute :title do |object|
object.name
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/provider_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ProviderSerializer
set_type :providers
set_id :uid

attributes :name, :symbol, :website, :contact_name, :contact_email, :phone, :description, :region, :country, :logo_url, :institution_type, :is_active, :has_password, :joined, :created, :updated
attributes :name, :symbol, :website, :contact_name, :contact_email, :phone, :description, :region, :country, :logo_url, :organization_type, :focus_area, :is_active, :has_password, :joined, :created, :updated

has_many :prefixes, record_type: :prefixes

Expand Down
17 changes: 17 additions & 0 deletions db/migrate/20181023235649_add_focus_area.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class AddFocusArea < ActiveRecord::Migration[5.2]
def up
#remove_column :allocator, :institution_type, :string, limit: 191

add_column :allocator, :focus_area, :string, limit: 191
add_column :allocator, :organization_type, :string, limit: 191
add_index :allocator, [:organization_type], name: "index_allocator_organization_type"
end

def down
add_column :allocator, :institution_type, :string, limit: 191
add_index :allocator, [:institution_type], name: "index_member_institution_type"

remove_column :allocator, :focus_area, :string, limit: 191
remove_column :allocator, :organization_type, :string, limit: 191
end
end
5 changes: 4 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2018_10_19_133039) do
ActiveRecord::Schema.define(version: 2018_10_23_235649) do

create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
t.string "name", limit: 191, null: false
Expand Down Expand Up @@ -57,7 +57,10 @@
t.date "joined"
t.string "institution_type", limit: 191
t.string "logo"
t.string "focus_area", limit: 191
t.string "organization_type", limit: 191
t.index ["institution_type"], name: "index_member_institution_type"
t.index ["organization_type"], name: "index_allocator_organization_type"
t.index ["symbol"], name: "symbol", unique: true
end

Expand Down

0 comments on commit 5df87e3

Please sign in to comment.