From ec43f47f92e7b46cb1230c3f195c24132bf7e047 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Wed, 24 Feb 2021 19:18:19 +0100 Subject: [PATCH] Show Moderate link in topbar. Add menu icons. --- app/controllers/my_controller.rb | 3 ++- app/models/package.rb | 6 ++++++ app/views/layouts/_topbar.slim | 23 +++++++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index d72fce2..63b7263 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -15,7 +15,8 @@ class MyController < ApplicationController def moderate_list # First package with pending screenshots - @packages = Package.joins(:screenshots).where('screenshots.approved=false or screenshots.markedfordelete=true').distinct(:name) + # @packages = Package.joins(:screenshots).where('screenshots.approved=false or screenshots.markedfordelete=true').distinct(:name) + @packages = Package.need_moderation # # # List of screenshots that were reported (to be removed) # # @reported_screenshots = Screenshot.where(markedfordelete: true) diff --git a/app/models/package.rb b/app/models/package.rb index f536f9e..2daafd3 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -51,6 +51,12 @@ class Package < ApplicationRecord where(id: subselect ) end + # Return a list of packages that have screenshots to be moderated + def self.need_moderation + Package.joins(:screenshots).where('screenshots.approved=false or screenshots.markedfordelete=true').distinct(:name) + end + + # Return a query of all packages that have screenshots def self.without_screenshots # Query for all packages who's ID does not appear in a screenshot's "package_id" field diff --git a/app/views/layouts/_topbar.slim b/app/views/layouts/_topbar.slim index 2a5b3b5..50b08b9 100644 --- a/app/views/layouts/_topbar.slim +++ b/app/views/layouts/_topbar.slim @@ -16,12 +16,18 @@ nav.top-bar / .top-bar-right / ul.menu li.menu-text class=('active' if controller_name=='welcome' and action_name=='home') - a href="/" Home + a href="/" + i.fa.fa-home + span< Home li.menu-text class=('active' if controller_name=='packages' and request.fullpath != packages_without_path) - a href="/packages" Browse + a href="/packages" + i.fa.fa-camera + span< Browse / TODO: highlights the "Browse" tab (even) when you click on Upload li.menu-text class=('active' if request.fullpath == packages_without_path) - =link_to 'Upload', :packages_without + =link_to :packages_without + i.fa.fa-upload + span< Upload //li.has-dropdown //a href="#" Distributions //ul.dropdown @@ -31,11 +37,16 @@ nav.top-bar //li //a href="#" Ubuntu li.menu-text class=('active' if controller_name=='welcome' and action_name=='about') - a href="/about" About/Privacy + a href="/about" + i.fa.fa-info-circle + span< About/Privacy // TODO: Check correct classes in Zurb/Foundation for top bar! - /- if user_signed_in? and current_user.is_admin? + - if user_signed_in? and current_user.is_admin? and Package.need_moderation.any? li.menu-text - ul.menu.dropdown data-dropdown-menu=true + =link_to url_for(Package.need_moderation.first) + i.fa.fa-thumbs-up + span< Moderate + /ul.menu.dropdown data-dropdown-menu=true li a href='#' Admin ul.menu