mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-23 07:18:22 -04:00
change from approved boolean to approval_status string
This commit is contained in:
1 parent
a8c203aea0
commit
c80b42d9bc
7 files changed
+29
-19
No files matched your search
@@ -108,7 +108,7 @@ class CropsController < ApplicationController
|
||||
@crop.creator = current_member
|
||||
else
|
||||
@crop.requester = current_member
|
||||
@crop.approved = false
|
||||
@crop.approval_status = "pending"
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
@@ -159,6 +159,6 @@ class CropsController < ApplicationController
|
||||
private
|
||||
|
||||
def crop_params
|
||||
params.require(:crop).permit(:en_wikipedia_url, :name, :parent_id, :creator_id, :scientific_names_attributes => [:scientific_name])
|
||||
params.require(:crop).permit(:en_wikipedia_url, :name, :parent_id, :creator_id, :approval_status, :scientific_names_attributes => [:scientific_name])
|
||||
end
|
||||
end
|
||||
+5
-5
@@ -22,11 +22,11 @@ class Crop < ActiveRecord::Base
|
||||
before_destroy {|crop| crop.posts.clear}
|
||||
|
||||
default_scope { order("lower(name) asc") }
|
||||
scope :recent, -> { where(:approved => true).reorder("created_at desc") }
|
||||
scope :toplevel, -> { where(approved => true, :parent_id => nil) }
|
||||
scope :popular, -> { where(:approved => true).reorder("plantings_count desc, lower(name) asc") }
|
||||
scope :randomized, -> { where(:approved => true).reorder('random()') } # ok on sqlite and psql, but not on mysql
|
||||
scope :pending_approval, -> { where(:approved => false) }
|
||||
scope :recent, -> { where(:approval_status => "approved").reorder("created_at desc") }
|
||||
scope :toplevel, -> { where(approval_status => "approved", :parent_id => nil) }
|
||||
scope :popular, -> { where(:approval_status => "approved").reorder("plantings_count desc, lower(name) asc") }
|
||||
scope :randomized, -> { where(:approval_status => "approved").reorder('random()') } # ok on sqlite and psql, but not on mysql
|
||||
scope :pending_approval, -> { where(:approval_status => "pending") }
|
||||
|
||||
validates :en_wikipedia_url,
|
||||
:format => {
|
||||
|
||||
@@ -40,6 +40,12 @@
|
||||
%label.checkbox
|
||||
= sn.check_box :_destroy
|
||||
= sn.label :_destroy, "Delete"
|
||||
|
||||
.form-group
|
||||
= f.label :approval_status, 'Approval Status', :class=> 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.select(:approval_status, ['rejected', 'pending', 'approved'], {}, {:class => 'form-control'})
|
||||
|
||||
.form-group
|
||||
.form-actions.col-md-offset-2.col-md-8
|
||||
= f.submit 'Save', :class => 'btn btn-primary'
|
||||
@@ -1,7 +0,0 @@
|
||||
class AddRequesterAndApprovedToCrops < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :crops, :requester_id, :integer
|
||||
add_column :crops, :approved, :boolean, default: true
|
||||
add_index :crops, :requester_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddRequesterToCrops < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :crops, :requester_id, :integer
|
||||
add_index :crops, :requester_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddApprovalStatusToCrops < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :crops, :approval_status, :string, default: "approved"
|
||||
end
|
||||
end
|
||||
+5
-5
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150130224814) do
|
||||
ActiveRecord::Schema.define(version: 20150201053200) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -62,16 +62,16 @@ ActiveRecord::Schema.define(version: 20150130224814) do
|
||||
end
|
||||
|
||||
create_table "crops", force: true do |t|
|
||||
t.string "name", null: false
|
||||
t.string "name", null: false
|
||||
t.string "en_wikipedia_url"
|
||||
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.string "slug"
|
||||
t.integer "parent_id"
|
||||
t.integer "plantings_count", default: 0
|
||||
t.integer "creator_id"
|
||||
t.integer "requester_id"
|
||||
t.boolean "approved", default: true
|
||||
t.string "approval_status", default: "approved"
|
||||
end
|
||||
|
||||
add_index "crops", ["name"], name: "index_crops_on_name", using: :btree
|
||||
|
||||
Reference in new issue
Block a user