Skip to content

Commit

Permalink
Only display default categories on organization#new
Browse files Browse the repository at this point in the history
  • Loading branch information
taitus committed Dec 10, 2017
1 parent cc544ad commit 204fcb3
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/views/admin/organizations/_data.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
<div class="small-12 columns">
<%= f.label :category_id, t('backend.identifying_data.category_id') %>
<%= f.select :category_id, options_for_select(Category.all.map{|c| [c.name, c.id]}), prompt: t('backend.none') %>
<%= f.select :category_id, options_for_select(Category.where(display: true).map{|c| [c.name, c.id]}), prompt: t('backend.none') %>
<%= form_field_errors(f, :category_id) %>
</div>
<div class="small-12 columns">
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20171210174630_add_display_field_to_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDisplayFieldToCategories < ActiveRecord::Migration
def change
add_column :categories, :display, :boolean
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20171205234013) do
ActiveRecord::Schema.define(version: 20171210174630) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -91,6 +91,7 @@
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "display"
end

create_table "event_agents", force: :cascade do |t|
Expand Down
2 changes: 1 addition & 1 deletion db/test_seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
'Iglesia y otras confesiones', 'Otro tipo de sujetos']

names.each do |name|
Category.create(name: name)
Category.create(name: name, display: true)
end

#Category
Expand Down
2 changes: 1 addition & 1 deletion lib/public_organization_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def self.get_file(url)
end

def self.get_category(data)
Category.find_or_create_by(name: data["Categoría"])
Category.find_or_create_by(name: data["Categoría"], display: false)
end

def self.associations_mapping
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/organizations.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace :organizations do
'Iglesia y otras confesiones', 'Otro tipo de sujetos']

names.each do |name|
Category.find_or_create_by(name: name)
Category.find_or_create_by(name: name, display: true)
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/factories/categories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

factory :category do
sequence(:name) { |n| "Category #{n}" }
display true
end

end

0 comments on commit 204fcb3

Please sign in to comment.