From 41db12d8d79fdd8d220241d021aa7066e9bdd547 Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Sat, 31 Jan 2015 10:36:02 +1100 Subject: [PATCH] pending approval crops appear on crops wrangle page --- app/controllers/crops_controller.rb | 3 ++- app/models/crop.rb | 1 + app/views/crops/wrangle.html.haml | 34 ++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 89c0c0ede..aae0cc928 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -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 diff --git a/app/models/crop.rb b/app/models/crop.rb index 4c8f2dd06..5a63b31d2 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -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 => { diff --git a/app/views/crops/wrangle.html.haml b/app/views/crops/wrangle.html.haml index b26f29fc9..07091c595 100644 --- a/app/views/crops/wrangle.html.haml +++ b/app/views/crops/wrangle.html.haml @@ -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