Cook up the new editor summary page

This commit is contained in:
Gregory Koberger 2011-01-20 14:06:34 -08:00
Родитель 0cc9d823cc
Коммит 5024ede67a
4 изменённых файлов: 190 добавлений и 3 удалений

Просмотреть файл

@ -1,6 +1,95 @@
{% extends "editors/base.html" %}
{% block content %}
The front page. Don't put sensitive data on this page until it's restricted by
@editor_required!
<div id="editor-stats">
{# TODO(gkoberger): Fill in the MOTD below #}
<div class="featured daily-message">
<div class="featured-inner">
<h2>{{ _('Announcement') }}</h2>
<p>This is where the Message of the Day will eventually go!</p>
</div>
</div>
<div class="featured" id="editors_stats">
<div class="featured-inner">
<div class="listing-header">
<div class="editor-stats-title"><span>{{ _('Total Reviews') }}</span></div>
<div class="editor-stats-title"><span>{{ _('Month Reviews') }}</span></div>
<div class="editor-stats-title"><span>{{ _('New Editors') }}</span></div>
</div>
<div class="editor-stats">
<div class="editor-stats-table">
<div>
<table>
{% for row in reviews_total: %}
<tr>
<td>{{ row['user__display_name'] }}</td>
<td class="int">{{ row['approval__count']|numberfmt }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
<div class="editor-stats-table">
<div>
<table>
{% for row in reviews_monthly: %}
<tr>
<td>{{ row['user__display_name'] }}</td>
<td class="int">{{ row['approval__count']|numberfmt }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
<div class="editor-stats-table">
<div>
<table>
{# TODO(dd): ActivityLog stuff #}
{% for i in range(5) %}
<tr>
<td>John Smith</td>
<td class="date">Today</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
</div>
</div>
{# TODO(dd): ActivityLog stuff (this is a placeholder) #}
<div class="listing results">
<div class="results-inner">
<div class="row">
<a href="/en-US/firefox/addon/test_addon2/">Kris Maglione</a> deleted review <a href="#">263753</a>.
<time title="Jan 6, 2011 3:35:43 PM" datetime="2011-01-06T23:35:43Z">1 week, 6 days ago</time>
</div>
<div class="row">
<a href="/en-US/firefox/addon/test_addon2/">Kris Maglione</a> deleted review <a href="#">263753</a>.
<time title="Jan 6, 2011 3:35:43 PM" datetime="2011-01-06T23:35:43Z">1 week, 6 days ago</time>
</div>
<div class="row">
<a href="/en-US/firefox/addon/test_addon2/">Kris Maglione</a> deleted review <a href="#">263753</a>.
<time title="Jan 6, 2011 3:35:43 PM" datetime="2011-01-06T23:35:43Z">1 week, 6 days ago</time>
</div>
<div class="row">
<a href="/en-US/firefox/addon/test_addon2/">Kris Maglione</a> deleted review <a href="#">263753</a>.
<time title="Jan 6, 2011 3:35:43 PM" datetime="2011-01-06T23:35:43Z">1 week, 6 days ago</time>
</div>
<div class="row">
<a href="/en-US/firefox/addon/test_addon2/">Kris Maglione</a> deleted review <a href="#">263753</a>.
<time title="Jan 6, 2011 3:35:43 PM" datetime="2011-01-06T23:35:43Z">1 week, 6 days ago</time>
</div>
<div class="row">
<a href="/en-US/firefox/addon/test_addon2/">Kris Maglione</a> deleted review <a href="#">263753</a>.
<time title="Jan 6, 2011 3:35:43 PM" datetime="2011-01-06T23:35:43Z">1 week, 6 days ago</time>
</div>
</div>
</div>
</div>
{% endblock %}

Просмотреть файл

@ -11,6 +11,7 @@ from editors.models import ViewEditorQueue
from editors.helpers import ViewEditorQueueTable
from amo.utils import paginate
from amo.urlresolvers import reverse
from files.models import Approval
def editor_required(func):
@ -27,7 +28,10 @@ def editor_required(func):
@editor_required
def home(request):
return jingo.render(request, 'editors/home.html', {})
data = {'reviews_total': Approval.total_reviews(),
'reviews_monthly': Approval.monthly_reviews()}
return jingo.render(request, 'editors/home.html', data)
@editor_required

Просмотреть файл

@ -211,6 +211,20 @@ class Approval(amo.models.ModelBase):
class Meta(amo.models.ModelBase.Meta):
db_table = 'approvals'
@staticmethod
def total_reviews():
return (Approval.objects.values('user', 'user__display_name')
.annotate(models.Count('approval'))
.order_by('-approval__count')[:5])
@staticmethod
def monthly_reviews():
now = datetime.now()
created_date = datetime(now.year, now.month, 1)
return (Approval.objects.values('user', 'user__display_name')
.filter(created__gte=created_date)
.annotate(models.Count('approval'))
.order_by('-approval__count')[:5])
class Platform(amo.models.ModelBase):
# `name` and `shortname` are provided in amo.__init__

Просмотреть файл

@ -90,6 +90,7 @@ table.data-grid tbody tr:nth-child(odd) {
table.data-grid tbody tr:nth-child(even) {
background-color: #FFFFFF;
}
/* editors/queue tabs */
ul.tabnav {
list-style-type: none;
@ -128,4 +129,83 @@ ul.tabnav a:hover {
background-color: #ffffff;
border-color: #2E5186;
padding-bottom: 9px;
=======
#editor-stats .listing .results-inner {
padding: 0 0.5em;
}
#editor-stats .listing time {
color: #aaa;
font-style: italic;
}
#editor-stats .listing .row {
padding: 0.5em;
border-top: 1px dotted #ADD0DC;
}
#editor-stats .listing .row:first-child {
border-top-width: 0px;
}
.editor-stats-title,
.editor-stats-table {
width: 33%;
float: left;
}
.editor-stats-title span {
font-weight: bold;
padding-left: 7px;
}
.editor-stats-table > div {
padding: 0 10px;
margin: 5px 0;
border-left: 1px dotted #ADD0DC;
}
.editor-stats-table:first-child > div {
border-left-width: 0px;
}
.editor-stats-table table {
width: 100%;
margin: 0;
}
.editor-stats-table td, .editor-stats-table th {
padding: 0;
border-top: 1px solid #F0F7FE;
}
.editor-stats-table table tr:first-child td {
border-top-width: 0px;
}
.editor-stats-table .int {
text-align: right;
color: #37A632;
font-weight: bold;
}
.editor-stats-table .date {
text-align: right;
color: #999;
font-style: italic;
}
#editors_stats .listing-header {
line-height: 1.8em;
}
.daily-message div {
padding: 15px;
}
.daily-message h2 {
font-size: 1em;
font-weight: bold;
margin-top: 0;
}