diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 0ff819c..0d13166 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -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 diff --git a/app/views/my/_menu.slim b/app/views/my/_menu.slim index d199bb1..1f47fae 100644 --- a/app/views/my/_menu.slim +++ b/app/views/my/_menu.slim @@ -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' diff --git a/app/views/my/logs.slim b/app/views/my/logs.slim index dc2d293..bf6195b 100644 --- a/app/views/my/logs.slim +++ b/app/views/my/logs.slim @@ -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 diff --git a/app/views/my/moderate_list.slim b/app/views/my/moderate_list.slim index 247bff7..39fae91 100644 --- a/app/views/my/moderate_list.slim +++ b/app/views/my/moderate_list.slim @@ -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 diff --git a/app/views/my/profile.slim b/app/views/my/profile.slim index 47ff369..299071e 100644 --- a/app/views/my/profile.slim +++ b/app/views/my/profile.slim @@ -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 … \ No newline at end of file +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 diff --git a/app/views/my/screenshots.slim b/app/views/my/screenshots.slim new file mode 100644 index 0000000..3358ae1 --- /dev/null +++ b/app/views/my/screenshots.slim @@ -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. diff --git a/config/routes.rb b/config/routes.rb index 7db61cb..5271c93 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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: /[^\/]+/