From fd43d4de11d74f1e96bd31f7a818b7494a87df22 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 25 Jul 2014 01:17:47 +0300 Subject: [PATCH 1/3] add links for events/conferences/submitters --- app/models/user.rb | 11 +++++ .../_recent_registrations.html.haml | 4 +- .../conference/_recent_submissions.html.haml | 9 +++-- .../admin/conference/_recent_users.html.haml | 2 +- .../admin/conference/_top_submitter.html.haml | 4 +- app/views/admin/users/_submissions.html.haml | 40 +++++++++++++++++++ app/views/admin/users/show.html.haml | 40 ++++++++++++------- 7 files changed, 88 insertions(+), 22 deletions(-) create mode 100644 app/views/admin/users/_submissions.html.haml diff --git a/app/models/user.rb b/app/models/user.rb index 9ebea407..3c7bbe74 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -114,6 +114,17 @@ class User < ActiveRecord::Base proposals(conference).count end + # Returns user submissions (in any conference) + def submissions + submissions = Array.new + Conference.all.each do |c| + unless self.proposals(c).blank? + submissions << self.proposals(c) + end + end + submissions + end + def biography_word_count if biography.nil? 0 diff --git a/app/views/admin/conference/_recent_registrations.html.haml b/app/views/admin/conference/_recent_registrations.html.haml index 2a6b449d..3bad7424 100644 --- a/app/views/admin/conference/_recent_registrations.html.haml +++ b/app/views/admin/conference/_recent_registrations.html.haml @@ -11,8 +11,8 @@ %tbody %tr %td #{index + 1} - %td #{registration.name} - %td #{registration.conference.title} + %td= link_to "#{registration.name}", admin_user_path(registration.user.id) + %td= link_to "#{registration.conference.title}", admin_conference_path(registration.conference.short_title) %td #{registration.created_at.strftime('%m/%d/%Y')} - else %h5.text-warning.text-center diff --git a/app/views/admin/conference/_recent_submissions.html.haml b/app/views/admin/conference/_recent_submissions.html.haml index 24e26fff..214552c9 100644 --- a/app/views/admin/conference/_recent_submissions.html.haml +++ b/app/views/admin/conference/_recent_submissions.html.haml @@ -12,9 +12,12 @@ %tbody %tr %td #{index + 1} - %td #{event.submitter.name} - %td #{event.title} - %td #{event.conference.title} + - if event.submitter + %td= link_to "#{event.submitter.name}", admin_user_path(event.submitter.id) + - else + %td Unknown Submitter + %td= link_to "#{event.title}", admin_conference_event_path(event.conference.short_title, event) + %td= link_to "#{event.conference.title}", admin_conference_path(event.conference.short_title) %td .span{'class'=>label_for(event.state)} #{event.state.humanize} - else diff --git a/app/views/admin/conference/_recent_users.html.haml b/app/views/admin/conference/_recent_users.html.haml index e65b6fed..8fd78451 100644 --- a/app/views/admin/conference/_recent_users.html.haml +++ b/app/views/admin/conference/_recent_users.html.haml @@ -11,7 +11,7 @@ %tbody %tr %td #{index} - %td #{user.email} + %td= link_to "#{user.email}", admin_user_path(user.id) %td #{user.created_at.strftime('%m/%d/%Y')} %td - if user.confirmed? diff --git a/app/views/admin/conference/_top_submitter.html.haml b/app/views/admin/conference/_top_submitter.html.haml index 36bf2302..1c67cfdb 100644 --- a/app/views/admin/conference/_top_submitter.html.haml +++ b/app/views/admin/conference/_top_submitter.html.haml @@ -9,10 +9,10 @@ = image_tag(key.gravatar_url(size: '25'), title: "Yo #{key.name}!", :alt => '', 'class'=>'img-circle img-responsive text-center') .col-md-10 %h4 - #{key.name} + = link_to "#{key.name}", admin_user_path(key) %div %small - #{pluralize(value, 'submission')} + = link_to "#{pluralize(value, 'submission')}", admin_user_path(key) - else %h4.text-warning No submissions! diff --git a/app/views/admin/users/_submissions.html.haml b/app/views/admin/users/_submissions.html.haml new file mode 100644 index 00000000..ffbbe81c --- /dev/null +++ b/app/views/admin/users/_submissions.html.haml @@ -0,0 +1,40 @@ +.row + .col-md-12.page-header + %h2 + Submissions (#{@user.submissions.length}) for #{@user.name} + .col-md-12 + .well + %table.table.table-bordered.table-striped.table-hover#submissions + %thead + %th ID + %th Conference + %th Title + %th State + %th Type + %th Rating + %th Created At + %tbody + - @user.submissions.each do |submission| + - event = submission[0] + %tr + %td= event.id + %td= link_to event.conference.short_title, admin_conference_path(event.conference.short_title) + %td= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %td= event.state + %td= "#{event.event_type.title} (#{show_time(event.event_type.length)})" + %td + - if event.conference.call_for_papers && event.conference.call_for_papers.rating && event.conference.call_for_papers.rating > 0 + - event.conference.call_for_papers.rating.times do |counter| + - if event.average_rating.to_f.round == counter+1 + = label_tag "label_rating", "", :class => "avgrating", :avgrate => true + = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" + - else + = label_tag "label_rating", "", :class => "avgrating" + %td= event.created_at + +:javascript + $(document).ready(function() { + $('#submissions').dataTable( { + "bPaginate": false + } ); + } ); diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index 161d8708..77846f89 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -1,14 +1,26 @@ -- if can? :edit, @user - .pull-right - = link_to "Edit", edit_admin_user_path(@user), class: 'btn btn-primary' -%table.table - - @show_attributes.each do |attr| - %tr - %td{class: 'table20'} - %b - = attr.capitalize.gsub('_', ' ') - - if attr == 'roles' - %td - = show_roles(@user.get_roles) - - else - %td= @user.send(attr) +.row + .col-md-12 + .tabbable + %ul.nav.nav-tabs + %li.active + = link_to 'User Info', '#user-info-content', 'data-toggle'=>'tab' + - unless @user.submissions.blank? + %li= link_to 'Submissions', '#submissions-content', 'data-toggle'=>'tab' + .tab-content + #user-info-content.tab-pane.active + - if can? :edit, @user + .pull-right + = link_to "Edit", edit_admin_user_path(@user), class: 'btn btn-primary' + %table.table + - @show_attributes.each do |attr| + %tr + %td{class: 'table20'} + %b + = attr.capitalize.gsub('_', ' ') + - if attr == 'roles' + %td + = show_roles(@user.get_roles) + - else + %td= @user.send(attr) + #submissions-content.tab-pane + = render 'submissions' From d7c7d878f2dc1c6242fe2b78fef4d70f114e4d12 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Mon, 28 Jul 2014 21:57:46 +0300 Subject: [PATCH 2/3] fix [] --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 3c7bbe74..2eb130c2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -116,7 +116,7 @@ class User < ActiveRecord::Base # Returns user submissions (in any conference) def submissions - submissions = Array.new + submissions = [] Conference.all.each do |c| unless self.proposals(c).blank? submissions << self.proposals(c) From 5a1dae866a74a6865ac9c11e372dfd9fbf420605 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Wed, 6 Aug 2014 22:23:10 +0300 Subject: [PATCH 3/3] fixes from comments --- app/models/user.rb | 11 ----------- .../admin/conference/_recent_registrations.html.haml | 8 ++++---- .../admin/conference/_recent_submissions.html.haml | 8 ++++---- app/views/admin/conference/_recent_users.html.haml | 6 +++--- app/views/admin/conference/_top_submitter.html.haml | 4 ++-- app/views/admin/users/_submissions.html.haml | 9 ++++----- app/views/admin/users/show.html.haml | 11 ++++++----- 7 files changed, 23 insertions(+), 34 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2eb130c2..9ebea407 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -114,17 +114,6 @@ class User < ActiveRecord::Base proposals(conference).count end - # Returns user submissions (in any conference) - def submissions - submissions = [] - Conference.all.each do |c| - unless self.proposals(c).blank? - submissions << self.proposals(c) - end - end - submissions - end - def biography_word_count if biography.nil? 0 diff --git a/app/views/admin/conference/_recent_registrations.html.haml b/app/views/admin/conference/_recent_registrations.html.haml index 3bad7424..9b750c83 100644 --- a/app/views/admin/conference/_recent_registrations.html.haml +++ b/app/views/admin/conference/_recent_registrations.html.haml @@ -10,10 +10,10 @@ - recent_registrations.each_with_index do |registration, index| %tbody %tr - %td #{index + 1} - %td= link_to "#{registration.name}", admin_user_path(registration.user.id) - %td= link_to "#{registration.conference.title}", admin_conference_path(registration.conference.short_title) - %td #{registration.created_at.strftime('%m/%d/%Y')} + %td= index + 1 + %td= link_to registration.name, admin_user_path(registration.user.id) + %td= link_to registration.conference.title, admin_conference_path(registration.conference.short_title) + %td= registration.created_at.strftime('%m/%d/%Y') - else %h5.text-warning.text-center No registrations! diff --git a/app/views/admin/conference/_recent_submissions.html.haml b/app/views/admin/conference/_recent_submissions.html.haml index 214552c9..08823ff8 100644 --- a/app/views/admin/conference/_recent_submissions.html.haml +++ b/app/views/admin/conference/_recent_submissions.html.haml @@ -11,13 +11,13 @@ - recent_events.each_with_index do |event, index| %tbody %tr - %td #{index + 1} + %td= index + 1 - if event.submitter - %td= link_to "#{event.submitter.name}", admin_user_path(event.submitter.id) + %td= link_to event.submitter.name, admin_user_path(event.submitter.id) - else %td Unknown Submitter - %td= link_to "#{event.title}", admin_conference_event_path(event.conference.short_title, event) - %td= link_to "#{event.conference.title}", admin_conference_path(event.conference.short_title) + %td= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %td= link_to event.conference.title, admin_conference_path(event.conference.short_title) %td .span{'class'=>label_for(event.state)} #{event.state.humanize} - else diff --git a/app/views/admin/conference/_recent_users.html.haml b/app/views/admin/conference/_recent_users.html.haml index 8fd78451..5bdd0218 100644 --- a/app/views/admin/conference/_recent_users.html.haml +++ b/app/views/admin/conference/_recent_users.html.haml @@ -10,9 +10,9 @@ - recent_users.each_with_index do |user, index| %tbody %tr - %td #{index} - %td= link_to "#{user.email}", admin_user_path(user.id) - %td #{user.created_at.strftime('%m/%d/%Y')} + %td= index + 1 + %td= link_to user.email, admin_user_path(user.id) + %td= user.created_at.strftime('%m/%d/%Y') %td - if user.confirmed? %span.label.label-success Confirmed diff --git a/app/views/admin/conference/_top_submitter.html.haml b/app/views/admin/conference/_top_submitter.html.haml index 1c67cfdb..1589785f 100644 --- a/app/views/admin/conference/_top_submitter.html.haml +++ b/app/views/admin/conference/_top_submitter.html.haml @@ -9,10 +9,10 @@ = image_tag(key.gravatar_url(size: '25'), title: "Yo #{key.name}!", :alt => '', 'class'=>'img-circle img-responsive text-center') .col-md-10 %h4 - = link_to "#{key.name}", admin_user_path(key) + = link_to key.name, admin_user_path(key) %div %small - = link_to "#{pluralize(value, 'submission')}", admin_user_path(key) + = link_to pluralize(value, 'submission'), admin_user_path(key, tab: 'submissions-content') - else %h4.text-warning No submissions! diff --git a/app/views/admin/users/_submissions.html.haml b/app/views/admin/users/_submissions.html.haml index ffbbe81c..1a0a0857 100644 --- a/app/views/admin/users/_submissions.html.haml +++ b/app/views/admin/users/_submissions.html.haml @@ -1,7 +1,7 @@ .row .col-md-12.page-header %h2 - Submissions (#{@user.submissions.length}) for #{@user.name} + Submissions (#{@user.events.length}) for #{@user.name} .col-md-12 .well %table.table.table-bordered.table-striped.table-hover#submissions @@ -14,8 +14,7 @@ %th Rating %th Created At %tbody - - @user.submissions.each do |submission| - - event = submission[0] + - @user.events.each do |event| %tr %td= event.id %td= link_to event.conference.short_title, admin_conference_path(event.conference.short_title) @@ -26,10 +25,10 @@ - if event.conference.call_for_papers && event.conference.call_for_papers.rating && event.conference.call_for_papers.rating > 0 - event.conference.call_for_papers.rating.times do |counter| - if event.average_rating.to_f.round == counter+1 - = label_tag "label_rating", "", :class => "avgrating", :avgrate => true + = label_tag 'label_rating', '', class: 'avgrating', avgrate: true = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" - else - = label_tag "label_rating", "", :class => "avgrating" + = label_tag 'label_rating', '', class: 'avgrating' %td= event.created_at :javascript diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index 77846f89..98196a37 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -2,12 +2,13 @@ .col-md-12 .tabbable %ul.nav.nav-tabs - %li.active + %li{class: "#{'active' unless params[:tab] == 'submissions-content'}"} = link_to 'User Info', '#user-info-content', 'data-toggle'=>'tab' - - unless @user.submissions.blank? - %li= link_to 'Submissions', '#submissions-content', 'data-toggle'=>'tab' + - unless @user.events.blank? + %li{class: "#{'active' if params[:tab] == 'submissions-content'}"} + = link_to 'Submissions', '#submissions-content', 'data-toggle'=>'tab' .tab-content - #user-info-content.tab-pane.active + #user-info-content.tab-pane{class: "#{'active' unless params[:tab] == 'submissions-content'}"} - if can? :edit, @user .pull-right = link_to "Edit", edit_admin_user_path(@user), class: 'btn btn-primary' @@ -22,5 +23,5 @@ = show_roles(@user.get_roles) - else %td= @user.send(attr) - #submissions-content.tab-pane + #submissions-content.tab-pane{class: "#{'active' if params[:tab] == 'submissions-content'}"} = render 'submissions'