[extensions-web: 11/75] Add reviews and extensions to profile.
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web: 11/75] Add reviews and extensions to profile.
- Date: Fri, 23 Sep 2011 03:15:21 +0000 (UTC)
commit bf77cfcdc6be98d4a8b3d16dc89ded01cb935b42
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Sep 13 14:16:10 2011 -0400
Add reviews and extensions to profile.
sweettooth/auth/templates/auth/profile.html | 17 +++++++++
sweettooth/auth/views.py | 15 ++++++--
sweettooth/review/templates/review/review.html | 39 +-------------------
.../review/templates/review/review_table.html | 38 +++++++++++++++++++
sweettooth/static/css/review-table.css | 36 ++++++++++++++++++
sweettooth/static/css/review.css | 37 +------------------
6 files changed, 105 insertions(+), 77 deletions(-)
---
diff --git a/sweettooth/auth/templates/auth/profile.html b/sweettooth/auth/templates/auth/profile.html
index 1a2192b..04333d8 100644
--- a/sweettooth/auth/templates/auth/profile.html
+++ b/sweettooth/auth/templates/auth/profile.html
@@ -17,5 +17,22 @@
<td>{{ request.user.email }}</td>
</tr>
</table>
+
+ <h3> {{ display_name }} has authored </h3>
+ <ul>
+ {% for extension in extensions %}
+ <li><a href="{% url extensions-detail pk=extension.pk %}">{{ extension.name }}</a></li>
+ {% endfor %}
+ </ul>
+
+ <h3> {{ display_name }} has reviewed </h3>
+ <ul>
+ {% include "review/review_table.html" with reviews=reviews %}
+ </ul>
</div>
{% endblock %}
+
+{% block head %}
+ {{ block.super }}
+ <link rel="stylesheet" href="/static/css/review-table.css" />
+{% endblock %}
diff --git a/sweettooth/auth/views.py b/sweettooth/auth/views.py
index e8d5822..8eafbe0 100644
--- a/sweettooth/auth/views.py
+++ b/sweettooth/auth/views.py
@@ -3,6 +3,9 @@ from django.contrib.auth import forms, models
from django.contrib.auth.views import login, logout
from django.shortcuts import get_object_or_404, render
+from review.models import CodeReview
+from extensions.models import Extension
+
class AutoFocusAuthenticationForm(forms.AuthenticationForm):
def __init__(self, *a, **kw):
super(AutoFocusAuthenticationForm, self).__init__(*a, **kw)
@@ -15,14 +18,20 @@ class InlineAuthenticationForm(forms.AuthenticationForm):
field.widget.attrs['placeholder'] = field.label
def profile(request, user):
- user = get_object_or_404(models.User, username=user)
+ userobj = get_object_or_404(models.User, username=user)
template = 'auth/profile.html'
if request.user == user:
template = 'auth/profile-edit.html'
- display_name = user.get_full_name() or request.user.username
- return render(request, template, dict(user=user, display_name=display_name))
+ display_name = userobj.get_full_name() or userobj.username
+ extensions = Extension.objects.filter(creator=userobj)
+ reviews = CodeReview.objects.filter(reviewer=userobj)
+
+ return render(request, template, dict(user=userobj,
+ display_name=display_name,
+ extensions=extensions,
+ reviews=reviews,))
def register(request):
return None
diff --git a/sweettooth/review/templates/review/review.html b/sweettooth/review/templates/review/review.html
index 5072d3b..caba36f 100644
--- a/sweettooth/review/templates/review/review.html
+++ b/sweettooth/review/templates/review/review.html
@@ -38,44 +38,7 @@
<h2 class="expanded"> Previous Reviews </h2>
<div id="previous">
- <table>
- <thead>
- <tr>
- <th>Version</th>
- <th>Reviewer</th>
- <th>Date</th>
- <th>Comments</th>
- <th>Result</th>
- </tr>
- </thead>
-
- <tbody>
- {% for review in previous_reviews %}
- <tr>
- <td>
- <a href="{% url extensions-version-detail ext_pk=review.version.extension.pk slug=review.version.extension pk=review.version.pk %}">
- {{ review.version.version }}
- </a>
- </td>
- <td>{{ review.reviewer }}</td>
- <td>{{ review.date }}</td>
- <td>{{ review.comments }}</td>
- <td>
- {% if review.is_rejected %}
- <span class="rejected">
- {% else %}{% if review.is_active %}
- <span class="active">
- {% else %}
- <span>
- {% endif %}{% endif %}
- {{ review.get_newstatus_display }}
- </span>
- </tr>
- {% empty %}
- <tr><td colspan="5"> There were no previous reviews of this extension </td></tr>
- {% endfor %}
- </tbody>
- </table>
+ {% include "review/review_table.html" with reviews=previous_reviews empty="There were no previous reviews of this extension." %}
</div>
<h2 class="expanded"> Review </h2>
diff --git a/sweettooth/review/templates/review/review_table.html b/sweettooth/review/templates/review/review_table.html
new file mode 100644
index 0000000..e026c02
--- /dev/null
+++ b/sweettooth/review/templates/review/review_table.html
@@ -0,0 +1,38 @@
+<table class="reviews">
+ <thead>
+ <tr>
+ <th>Version</th>
+ <th>Reviewer</th>
+ <th>Date</th>
+ <th>Comments</th>
+ <th>Result</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {% for review in reviews %}
+ <tr>
+ <td>
+ <a href="{% url extensions-version-detail ext_pk=review.version.extension.pk slug=review.version.extension pk=review.version.pk %}">
+ {{ review.version.version }}
+ </a>
+ </td>
+ <td>{{ review.reviewer }}</td>
+ <td>{{ review.date }}</td>
+ <td>{{ review.comments }}</td>
+ <td>
+ {% if review.is_rejected %}
+ <span class="rejected">
+ {% else %}{% if review.is_active %}
+ <span class="active">
+ {% else %}
+ <span>
+ {% endif %}{% endif %}
+ {{ review.get_newstatus_display }}
+ </span>
+ </tr>
+ {% empty %}
+ <tr><td colspan="5"> {{ empty|default:"No reviews." }} </td></tr>
+ {% endfor %}
+ </tbody>
+</table>
diff --git a/sweettooth/static/css/review-table.css b/sweettooth/static/css/review-table.css
new file mode 100644
index 0000000..5f2e5ff
--- /dev/null
+++ b/sweettooth/static/css/review-table.css
@@ -0,0 +1,36 @@
+
+table.reviews {
+ width: 100%;
+}
+
+table.reviews thead, table.reviews tbody {
+ border-bottom: 1px solid #ccc;
+}
+
+table.reviews th {
+ border-left: 1px solid #eee;
+}
+
+table.reviews td {
+ border-left: 1px solid #ccc;
+}
+
+table.reviews tr {
+ line-height: 2em;
+ text-align: left;
+ text-indent: 1em;
+}
+
+table.reviews tbody tr:nth-child(odd) {
+ background-color: #eee;
+}
+
+table.reviews .rejected {
+ color: #c00;
+ font-weight: bold;
+}
+
+table.reviews .active {
+ color: #0a0;
+ font-weight: bold;
+}
diff --git a/sweettooth/static/css/review.css b/sweettooth/static/css/review.css
index ef14522..f263366 100644
--- a/sweettooth/static/css/review.css
+++ b/sweettooth/static/css/review.css
@@ -1,5 +1,6 @@
@import url("pygments.css");
+ import url("review-table.css");
#files table {
width: 100%;
@@ -122,39 +123,3 @@ h2.expanded:before {
#review_form input[type=submit] {
float: right;
}
-
-#previous table {
- width: 100%;
-}
-
-#previous thead, #previous tbody {
- border-bottom: 1px solid #ccc;
-}
-
-#previous th {
- border-left: 1px solid #eee;
-}
-
-#previous td {
- border-left: 1px solid #ccc;
-}
-
-#previous tr {
- line-height: 2em;
- text-align: left;
- text-indent: 1em;
-}
-
-#previous tbody tr:nth-child(odd) {
- background-color: #eee;
-}
-
-#previous .rejected {
- color: #c00;
- font-weight: bold;
-}
-
-#previous .active {
- color: #0a0;
- font-weight: bold;
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]