diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e9b8357..47230f2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,4 +5,16 @@ class ApplicationController < ActionController::Base # Do not mention passwords in the log file # filter_parameter_logging :password + + before_filter :get_current_users_screenshots + + # Query for packages that were uploaded by the current user. + # As AAA is not yet implemented it means looking for uploads + # that correspond to the user's cookie token. + def get_current_users_screenshots + if session[:token] + @current_users_screenshots = Screenshot.uploaded_by(session[:token]) + end + end + end diff --git a/app/models/screenshot.rb b/app/models/screenshot.rb index 9f48606..a98c29f 100644 --- a/app/models/screenshot.rb +++ b/app/models/screenshot.rb @@ -108,4 +108,9 @@ class Screenshot < ApplicationRecord def self.approved self.find_by(approved: true) end + + # Query for screenshots being uploaded by a certain user (by their token) + def self.uploaded_by(token) + self.where(approved: false, uploaderhash: token) + end end diff --git a/app/views/layouts/_topbar.slim b/app/views/layouts/_topbar.slim index 7320dc2..5562a19 100644 --- a/app/views/layouts/_topbar.slim +++ b/app/views/layouts/_topbar.slim @@ -25,6 +25,12 @@ nav.top-bar //a href="#" Ubuntu li class=('active' if controller_name=='welcome' and action_name=='about') a href="/about" About + - if @current_users_screenshots + li class=('active' if controller_name=='packages' and action_name=='my_uploads') + a href="/my_uploads" + | My uploads + span.badge + = @current_users_screenshots // TODO: Check correct classes in Zurb/Foundation for top bar! - if user_signed_in? li