pending approval crops appear on crops wrangle page

This commit is contained in:
Taylor Griffin
2015-01-31 10:36:02 +11:00
parent 28d29291a7
commit 41db12d8d7
3 changed files with 32 additions and 6 deletions

View File

@@ -32,7 +32,8 @@ class CropsController < ApplicationController
# GET /crops/wrangle
def wrangle
@crops = Crop.recent.paginate(:page => params[:page])
@recent_crops = Crop.recent.paginate(:page => params[:page])
@pending_approval = Crop.pending_approval
@crop_wranglers = Role.crop_wranglers
respond_to do |format|
format.html

View File

@@ -26,6 +26,7 @@ class Crop < ActiveRecord::Base
scope :toplevel, -> { where(:parent_id => nil) }
scope :popular, -> { reorder("plantings_count desc, lower(name) asc") }
scope :randomized, -> { reorder('random()') } # ok on sqlite and psql, but not on mysql
scope :pending_approval, -> { where(:approved => false) }
validates :en_wikipedia_url,
:format => {

View File

@@ -15,11 +15,35 @@
%li.crop_wrangler
= link_to crop_wrangler.login_name, crop_wrangler
%h2 Requested crops
%table.table.table-striped
%thead
%tr
%th System name
%th English Wikipedia URL
%th Scientific names
%th Requested by
%th When requested
%tbody
- @pending_approval.each do |c|
%tr
%td= link_to c.name, c
%td= link_to c.en_wikipedia_url, c.en_wikipedia_url
%td
- c.scientific_names.each do |s|
= link_to s.scientific_name, s
%br/
%td= link_to c.requester, c.requester
%td
= distance_of_time_in_words(c.created_at, Time.zone.now)
ago.
%h2 Recently added crops
%div.pagination
= page_entries_info @crops, :model => "crops"
= will_paginate @crops
= page_entries_info @recent_crops, :model => "crops"
= will_paginate @recent_crops
%table.table.table-striped
%tr
@@ -28,7 +52,7 @@
%th Scientific names
%th Added by
%th When
- @crops.each do |c|
- @recent_crops.each do |c|
%tr
%td= link_to c.name, c
%td= link_to c.en_wikipedia_url, c.en_wikipedia_url
@@ -42,5 +66,5 @@
ago.
%div.pagination
= page_entries_info @crops, :model => "crops"
= will_paginate @crops
= page_entries_info @recent_crops, :model => "crops"
= will_paginate @recent_crops