From 22b87cc23692426d2fa7deda1fa60d18a156b3e3 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 25 Apr 2014 16:08:22 +1000 Subject: [PATCH] Adding active flag to enterprises --- app/views/admin/enterprises/_form.html.haml | 3 +++ app/views/admin/enterprises/index.html.erb | 5 ++++- .../20140425055718_add_active_flag_to_enterprises.rb | 5 +++++ db/schema.rb | 7 ++++--- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20140425055718_add_active_flag_to_enterprises.rb diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index 1cb9707ecf..c38eb9b2a5 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -31,6 +31,9 @@   = f.check_box :is_distributor = f.label :is_distributor, 'Hub' +   + = f.check_box :active + = f.label :active, 'Active?' .with-tip{'data-powertip' => "Select 'Producer' if you are a primary producer of food. Select 'Hub' if you want a shop-front. You can choose either or both."} %a What's this? diff --git a/app/views/admin/enterprises/index.html.erb b/app/views/admin/enterprises/index.html.erb index 3fd36a6496..2cc480bce2 100644 --- a/app/views/admin/enterprises/index.html.erb +++ b/app/views/admin/enterprises/index.html.erb @@ -14,7 +14,8 @@ - + + @@ -23,6 +24,7 @@ Name Role + Active? Next Collection Date/Time Description @@ -34,6 +36,7 @@ <%= link_to enterprise.name, main_app.admin_enterprise_path(enterprise) %> <%= 'PP ' if enterprise.is_primary_producer %><%= 'D' if enterprise.is_distributor %> + <%= enterprise.active ? 'Active' : 'Inactive' %> <%= enterprise_form.text_field :next_collection_at %> <%= enterprise.description %> diff --git a/db/migrate/20140425055718_add_active_flag_to_enterprises.rb b/db/migrate/20140425055718_add_active_flag_to_enterprises.rb new file mode 100644 index 0000000000..b0bcc2f3ed --- /dev/null +++ b/db/migrate/20140425055718_add_active_flag_to_enterprises.rb @@ -0,0 +1,5 @@ +class AddActiveFlagToEnterprises < ActiveRecord::Migration + def change + add_column :enterprises, :active, :boolean, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 83688ff525..e7147d24b5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140402032034) do +ActiveRecord::Schema.define(:version => 20140425055718) do create_table "adjustment_metadata", :force => true do |t| t.integer "adjustment_id" @@ -219,8 +219,8 @@ ActiveRecord::Schema.define(:version => 20140402032034) do t.integer "address_id" t.string "pickup_times" t.string "next_collection_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "distributor_info" t.string "logo_file_name" t.string "logo_content_type" @@ -230,6 +230,7 @@ ActiveRecord::Schema.define(:version => 20140402032034) do t.string "promo_image_content_type" t.integer "promo_image_file_size" t.datetime "promo_image_updated_at" + t.boolean "active", :default => true end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id"