My views improved. Own screenshots view added
This commit is contained in:
parent
15b58548cc
commit
0207d6b392
7 changed files with 93 additions and 39 deletions
|
|
@ -5,19 +5,24 @@ class MyController < ApplicationController
|
|||
# Show audit logs
|
||||
def logs
|
||||
@logs = Log.paginate(page: params[:page], per_page: 20)
|
||||
render :logs
|
||||
end
|
||||
|
||||
# Show the user's own uploaded screenshots
|
||||
def screenshots
|
||||
@screenshots = current_user.screenshots.paginate(page: params[:page], per_page: 10)
|
||||
end
|
||||
|
||||
|
||||
# def profile
|
||||
# end
|
||||
|
||||
def uploads
|
||||
# @current_users_screenshots gets filled in ApplicationController
|
||||
#
|
||||
# Get packages that the uploaded screenshots belong to.
|
||||
@packages = Package.joins(:screenshots).where(
|
||||
'screenshots.id' => @current_users_screenshots)
|
||||
end
|
||||
# def uploads
|
||||
# # @current_users_screenshots gets filled in ApplicationController
|
||||
# #
|
||||
# # Get packages that the uploaded screenshots belong to.
|
||||
# @packages = Package.joins(:screenshots).where(
|
||||
# 'screenshots.id' => @current_users_screenshots)
|
||||
# end
|
||||
|
||||
def moderate_list
|
||||
# First package with pending screenshots
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
li class=('active' if action_name=='profile')
|
||||
= link_to my_profile_path
|
||||
= fa_icon 'user-o 2x', text: 'Myself'
|
||||
li class=('active' if action_name=='screenshots')
|
||||
= link_to my_screenshots_path
|
||||
= fa_icon 'camera 2x', text: 'Screenshots'
|
||||
li class=('active' if action_name=='moderate_list')
|
||||
= link_to moderate_list_path
|
||||
= fa_icon 'check 2x', text: 'Moderate'
|
||||
|
|
|
|||
|
|
@ -6,16 +6,17 @@
|
|||
// Paginator
|
||||
= render(partial: 'packages/paginator', locals: {items: @logs})
|
||||
|
||||
.small-6.medium-4.large-3.cell
|
||||
// Search form
|
||||
= render 'packages/searchfield'
|
||||
/ .small-6.medium-4.large-3.cell
|
||||
/ // Search form
|
||||
/ = render 'packages/searchfield'
|
||||
|
||||
- if @logs
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th Time
|
||||
th Message
|
||||
th Level
|
||||
/ th Level
|
||||
th Section
|
||||
th Package
|
||||
th Screenshot
|
||||
|
|
@ -24,8 +25,9 @@
|
|||
tbody
|
||||
- @logs.each do |log|
|
||||
tr
|
||||
td #{log.created_at}
|
||||
td #{log.message}
|
||||
td #{log.level}
|
||||
/ td #{log.level}
|
||||
td #{log.section}
|
||||
td
|
||||
- if log.package
|
||||
|
|
|
|||
|
|
@ -2,9 +2,13 @@
|
|||
|
||||
= render partial: 'menu'
|
||||
|
||||
h1 These packages have new screenshots
|
||||
h1 Packages that require moderation
|
||||
|
||||
- if @packages.any?
|
||||
|
||||
p
|
||||
i Note the red bar at the top also listing packages that need moderation.
|
||||
|
||||
ul
|
||||
- @packages.each do |pkg|
|
||||
li
|
||||
|
|
|
|||
|
|
@ -1,34 +1,45 @@
|
|||
.grid-container
|
||||
|
||||
= render partial: 'menu'
|
||||
= render partial: 'menu'
|
||||
|
||||
h1 As far as we know…
|
||||
h1 Your data
|
||||
|
||||
- unless current_user.name.blank?
|
||||
h2 Your name
|
||||
= current_user.name
|
||||
|
||||
= text_field_tag 'name', current_user.name
|
||||
- unless current_user.email.blank?
|
||||
h2 Your email address
|
||||
p = current_user.email
|
||||
p.help-text
|
||||
' Your name will be shown to others along with the images you upload.
|
||||
' Feel free to change it.
|
||||
' This web site recognizes you by your email address.
|
||||
' Don't worry - it will not be shown or given to anyone.
|
||||
|
||||
/ TODO: submit - save
|
||||
- unless current_user.provider.blank?
|
||||
h2 Account provider
|
||||
p You logged in using #{current_user.pretty_provider}.
|
||||
|
||||
- unless current_user.email.blank?
|
||||
h2 Your email address
|
||||
p = current_user.email
|
||||
p.help-text
|
||||
' This web site recognizes you by your email address.
|
||||
' Don't worry - it will not be shown or given to anyone.
|
||||
h2 Number of screenshots you uploaded
|
||||
p = current_user.screenshots.count
|
||||
|
||||
- unless current_user.provider.blank?
|
||||
h2 Single-sign-on provider
|
||||
p You logged in using #{current_user.pretty_provider}.
|
||||
|
||||
h2 Number of screenshots you uploaded
|
||||
p = current_user.screenshots.count
|
||||
|
||||
/ - if current_user.is_admin?
|
||||
/ h2 Admin
|
||||
/ p Apparently you are an administrator. Be careful with that thing!
|
||||
/ - you can moderate
|
||||
/ - you can …
|
||||
h2 Your permissions
|
||||
ul
|
||||
- if can? :approve, Screenshot
|
||||
li
|
||||
=> fa_icon 'thumbs-up'
|
||||
'approve uploaded screenshots
|
||||
- if can? :destroy, Screenshot
|
||||
li
|
||||
=> fa_icon 'trash'
|
||||
'delete screenshots
|
||||
- if can? :hide, Screenshot
|
||||
li
|
||||
=> fa_icon 'eye-slash'
|
||||
'hide screenshots from the public
|
||||
- if can? :unhide, Screenshot
|
||||
li
|
||||
=> fa_icon 'eye'
|
||||
'restore (unhide) screenshots to the public
|
||||
- if can? :view, Log
|
||||
li
|
||||
=> fa_icon 'book'
|
||||
'view logs
|
||||
|
|
|
|||
28
app/views/my/screenshots.slim
Normal file
28
app/views/my/screenshots.slim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
= render partial: 'menu'
|
||||
|
||||
h1 Screenshots uploaded by you
|
||||
|
||||
= render(partial: 'packages/paginator', locals: {items: @screenshots})
|
||||
|
||||
- if @screenshots
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th Uploaded
|
||||
th Package
|
||||
th Screenshot
|
||||
tbody
|
||||
- @screenshots.each do |ss|
|
||||
tr
|
||||
td #{time_ago_in_words ss.created_at} ago
|
||||
td
|
||||
= link_to ss.package.name, ss.package
|
||||
td
|
||||
- if ss.package
|
||||
.image
|
||||
/ This leads to an N+1 SQL query for each image. Ideas for optimization welcome.
|
||||
img src=ss.simage_url(:thumb)
|
||||
/ = link_to ss.id, package_path(ss.package, highlight: ss.id)
|
||||
|
||||
- else
|
||||
p You haven't uploaded any screenshots yet.
|
||||
|
|
@ -23,6 +23,7 @@ Rails.application.routes.draw do
|
|||
get 'my/profile'
|
||||
get 'my/uploads'
|
||||
get 'my/welcome'
|
||||
get 'my/screenshots'
|
||||
get 'my/moderate_list', as: :moderate_list
|
||||
get 'my/logs', as: :logs
|
||||
get 'package/:name' => 'packages#details', as: :package, name: /[^\/]+/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue