Showing number of users' uploaded screenshots at the top
This commit is contained in:
parent
82fb26efad
commit
bbccbfcc20
3 changed files with 23 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue