Implements recent items tabs and top submitter for dashboard

This commit is contained in:
Chrisbr
2014-06-04 16:11:33 +02:00
parent 25a1c116fd
commit 28293cb4c4
11 changed files with 186 additions and 1 deletions

View File

@@ -79,3 +79,7 @@ body {
.todolist-ok span {
color: #02A10F;
}
.top-submitter img {
margin: 0 auto;
}

View File

@@ -14,6 +14,12 @@ class Admin::ConferenceController < ApplicationController
@conferences = Conference.select('id, short_title, color, start_date,
registration_end_date, registration_start_date')
@recent_users = User.limit(5).order(created_at: :desc)
@recent_events = Event.limit(5).order(created_at: :desc)
@recent_registrations = Registration.limit(5).order(created_at: :desc)
@top_submitter = Conference.get_top_submitter
@submissions = {}
@cfp_weeks = [0]
@@ -78,6 +84,7 @@ class Admin::ConferenceController < ApplicationController
def show
@conference = Conference.find_by(short_title: params[:id])
@conference_progress = @conference.get_status
@top_submitter = @conference.get_top_submitter
respond_to do |format|
format.html
format.json { render json: @conference.to_json }

View File

@@ -15,6 +15,27 @@ module ApplicationHelper
end
end
def label_for(event_state)
result = ''
case event_state
when 'Withdrawn'
result = 'label label-danger'
when 'Review Pending'
result = 'label label-primary'
when 'Accepted (confirmation pending)'
result = 'label label-success'
when 'Confirmed'
result = 'label label-success'
when 'Rejected'
result = 'label label-warning'
when 'Cancelled'
result = 'label label-danger'
when 'Submitted'
result = 'label label-primary'
end
result
end
def icon_for_todo(bool)
if bool
return 'glyphicon glyphicon-ok'

View File

@@ -239,8 +239,46 @@ class Conference < ActiveRecord::Base
result
end
##
# Returns a hash with person => submissions ordered by submissions for all conferences
#
# ====Returns
# * +hash+ -> person: submissions
def self.get_top_submitter(limit = 5)
submitter = EventPerson.where('event_role = ?', 'submitter').limit(limit).group(:person_id)
counter = submitter.count
calculate_person_submission_hash(submitter, counter)
end
##
# Returns a hash with person => submissions ordered by submissions
#
# ====Returns
# * +hash+ -> person: submissions
def get_top_submitter(limit = 5)
submitter = EventPerson.joins(:event).
where('event_role = ? and conference_id = ?', 'submitter', id).
limit(limit).group(:person_id)
counter = submitter.count
Conference.calculate_person_submission_hash(submitter, counter)
end
private
##
# Returns a hash with person => submissions ordered by submissions for all conferences
#
# ====Returns
# * +hash+ -> person: submissions
def self.calculate_person_submission_hash(submitter, counter)
result = {}
submitter.each do |s|
result[s.person] = counter[s.person_id]
end
result
end
##
# Creates a venue and sets self.venue_id to it's id. Used as before_create.
#

View File

@@ -48,6 +48,10 @@ class User < ActiveRecord::Base
details += "#{self.created_at}<br>"
end
def confirmed?
!confirmed_at.nil?
end
private
def create_person
# TODO Search people for existing email address, add to their account

View File

@@ -0,0 +1,18 @@
- if recent_registrations && !recent_registrations.empty?
%table.table
%thead
%tr
%th #
%th Public Name
%th Conference
%th Date
- recent_registrations.each_with_index do |registration, index|
%tbody
%tr
%td #{index + 1}
%td #{registration.public_name}
%td #{registration.conference.title}
%td #{registration.created_at.strftime('%m/%d/%Y')}
- else
%h5.text-warning.text-center
No registrations!

View File

@@ -0,0 +1,21 @@
- if recent_events && !recent_events.empty?
%table.table
%thead
%tr
%th #
%th Submitter
%th Title
%th Conference
%th Status
- recent_events.each_with_index do |event, index|
%tbody
%tr
%td #{index + 1}
%td #{event.submitter}
%td #{event.title}
%td #{event.conference.title}
%td
.span{'class'=>label_for(event.public_state)} #{event.public_state}
- else
%h5.text-warning.text-center
No submissions!

View File

@@ -0,0 +1,22 @@
- if recent_users && !recent_users.empty?
%table.table
%thead
%tr
%th #
%th E-Mail
%th Date registered
%th Status
- recent_users.each_with_index do |user, index|
%tbody
%tr
%td #{index}
%td #{user.email}
%td #{user.created_at.strftime('%m/%d/%Y')}
%td
- if user.confirmed?
%span.label.label-success Confirmed
-else
%span.label.label-danger Unconfirmed
- else
%h5.text-warning.text-center
No sign ups!

View File

@@ -0,0 +1,17 @@
.row
%h3
Top Submitter
- if @top_submitter && !@top_submitter.empty?
- @top_submitter.each do |key, value|
.row.top-submitter
.col-md-2
= image_tag(key.gravatar_url(size: '25'), title: "Yo #{key.public_name}!", :alt => '', 'class'=>'img-circle img-responsive text-center')
.col-md-10
%h4
#{key}
%div
%small
#{pluralize(value, 'submission')}
- else
%h4.text-warning
No submissions!

View File

@@ -10,4 +10,35 @@
.col-md-8
= render partial: 'registrations', locals: { conferences: @conferences, registrations: @registrations,
registration_weeks: @registration_weeks }
.col-md-4
.col-md-4
.col-md-8
.row
%ul.nav.nav-tabs#recentTable
%li.active
%a{:href=>"#recent_user", "data-toggle"=>"tab"}
%span.glyphicon.glyphicon-user
Recent Users
%li
%a{:href=>"#recent_reg", "data-toggle"=>"tab"}
%span.glyphicon.glyphicon-star
Recent Registrations
%li
%a{:href=>"#recent_submissions", "data-toggle"=>"tab"}
%span.glyphicon.glyphicon-comment
Recent Submissions
.tab-content
.tab-pane.active#recent_user
= render partial: 'recent_users', locals: {recent_users: @recent_users}
.tab-pane#recent_reg
= render partial: 'recent_registrations', locals: {recent_registrations: @recent_registrations}
.tab-pane#recent_submissions
= render partial: 'recent_submissions', locals: {recent_events: @recent_events}
.col-md-4
= render partial: 'top_submitter', locals: {top_submitter: @top_submitter}
:javascript
$('#recentTable a').click(function (e) {
e.preventDefault();
$(this).tab('show');
})

View File

@@ -5,3 +5,5 @@
.row
.col-md-4
= render partial: 'todo_list', locals: { conference_progress: @conference_progress }
.col-md-4
= render partial: 'top_submitter', locals: {top_submitter: @top_submitter}