Merge pull request #30 from florapdx/master

change sponsorship/views.py so that admins can add logos/text from dashboard
This commit is contained in:
Luke Hatcher 2013-04-30 00:10:11 -07:00
commit 475b32f4bb
7 changed files with 39 additions and 41 deletions

View file

@ -5,14 +5,6 @@ from symposion.reviews.models import Review, ReviewAssignment
register = template.Library() register = template.Library()
@register.assignment_tag(takes_context=True)
def user_reviews(context):
request = context["request"]
reviews = Review.objects.filter(user=request.user)
return reviews
@register.assignment_tag(takes_context=True) @register.assignment_tag(takes_context=True)
def review_assignments(context): def review_assignments(context):
request = context["request"] request = context["request"]

View file

@ -2,7 +2,9 @@ from django.conf.urls.defaults import patterns, url
urlpatterns = patterns("symposion.reviews.views", urlpatterns = patterns("symposion.reviews.views",
url(r"^section/(?P<section_slug>[\w\-]+)/$", "review_section", name="review_section"), url(r"^section/(?P<section_slug>[\w\-]+)/all/$", "review_section", {"reviewed": "all"}, name="review_section"),
url(r"^section/(?P<section_slug>[\w\-]+)/reviewed/$", "review_section", {"reviewed": "reviewed"}, name="user_reviewed"),
url(r"^section/(?P<section_slug>[\w\-]+)/not_reviewed/$", "review_section", {"reviewed": "not_reviewed"}, name="user_not_reviewed"),
url(r"^section/(?P<section_slug>[\w\-]+)/assignments/$", "review_section", {"assigned": True}, name="review_section_assignments"), url(r"^section/(?P<section_slug>[\w\-]+)/assignments/$", "review_section", {"assigned": True}, name="review_section_assignments"),
url(r"^section/(?P<section_slug>[\w\-]+)/status/$", "review_status", name="review_status"), url(r"^section/(?P<section_slug>[\w\-]+)/status/$", "review_status", name="review_status"),
url(r"^section/(?P<section_slug>[\w\-]+)/status/(?P<key>\w+)/$", "review_status", name="review_status"), url(r"^section/(?P<section_slug>[\w\-]+)/status/(?P<key>\w+)/$", "review_status", name="review_status"),

View file

@ -62,8 +62,10 @@ def proposals_generator(request, queryset, user_pk=None, check_speaker=True):
yield obj yield obj
# Returns a list of all proposals, proposals reviewed by the user, or the proposals the user has yet to review
# depending on the link user clicks in dashboard
@login_required @login_required
def review_section(request, section_slug, assigned=False): def review_section(request, section_slug, assigned=False, reviewed='all'):
if not request.user.has_perm("reviews.can_review_%s" % section_slug): if not request.user.has_perm("reviews.can_review_%s" % section_slug):
return access_not_permitted(request) return access_not_permitted(request)
@ -74,19 +76,28 @@ def review_section(request, section_slug, assigned=False):
if assigned: if assigned:
assignments = ReviewAssignment.objects.filter(user=request.user).values_list("proposal__id") assignments = ReviewAssignment.objects.filter(user=request.user).values_list("proposal__id")
queryset = queryset.filter(id__in=assignments) queryset = queryset.filter(id__in=assignments)
queryset = queryset.select_related("result").select_subclasses() # passing reviewed in from reviews.urls and out to review_list for appropriate template header rendering
if reviewed == 'all':
queryset = queryset.select_related("result").select_subclasses()
reviewed = 'all_reviews'
elif reviewed == 'reviewed':
queryset = queryset.filter(reviews__user=request.user)
reviewed = 'user_reviewed'
else:
queryset = queryset.exclude(reviews__user=request.user).exclude(speaker=request.user)
reviewed = 'user_not_reviewed'
proposals = proposals_generator(request, queryset) proposals = proposals_generator(request, queryset)
ctx = { ctx = {
"proposals": proposals, "proposals": proposals,
"section": section, "section": section,
"reviewed": reviewed,
} }
return render(request, "reviews/review_list.html", ctx) return render(request, "reviews/review_list.html", ctx)
@login_required @login_required
def review_list(request, section_slug, user_pk): def review_list(request, section_slug, user_pk):

View file

@ -26,12 +26,16 @@ class Speaker(models.Model):
default = datetime.datetime.now, default = datetime.datetime.now,
editable = False editable = False
) )
class Meta:
ordering = ['name']
def __unicode__(self): def __unicode__(self):
if self.user: if self.user:
return self.name return self.name
else: else:
return "?" return "?"
def get_absolute_url(self): def get_absolute_url(self):
return reverse("speaker_edit") return reverse("speaker_edit")

View file

@ -35,7 +35,7 @@ def sponsor_add(request):
sponsor = form.save(commit=False) sponsor = form.save(commit=False)
sponsor.active = True sponsor.active = True
sponsor.save() sponsor.save()
return redirect("dashboard") return redirect("sponsor_detail", pk=sponsor.pk)
else: else:
form = SponsorApplicationForm(user=request.user) form = SponsorApplicationForm(user=request.user)

View file

@ -131,38 +131,19 @@
<i class="icon-briefcase"></i> <i class="icon-briefcase"></i>
<h3>{% trans "Reviews" %}</h3> <h3>{% trans "Reviews" %}</h3>
</div> </div>
{% user_reviews as user_reviews %}
<div class="dashboard-panel-content"> <div class="dashboard-panel-content">
<h4>Review Sections</h4> <h4>Reviews by Section</h4>
<ul> <ul>
{% for section in review_sections %} {% for section in review_sections %}
<li><a href="{% url review_section section.section.slug %}">{{ section }}</a></li> <h5>{{ section }}</h5>
<li><a href="{% url review_section section.section.slug %}">All</a></li>
<li><a href="{% url user_reviewed section.section.slug %}">Reviewed by you</a></li>
<li><a href="{% url user_not_reviewed section.section.slug %}">Not Reviewed by you</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
<h4>Proposals you have reviewed</h4>
<table class="table table-condensed">
<thead>
<th>#</th>
<th>Speaker / Title</th>
<th>Your Vote</th>
</thead>
<tbody>
{% for review in user_reviews %}
<tr>
<td>{{ review.proposal.number }}</td>
<td>
<b>{{ review.proposal.speaker }}</b>
<br />
{{ review.proposal.title }}
</td>
<td>{{ review.vote }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% comment %} {% comment %}
<h4>My Assignments</h4> <h4>My Assignments</h4>
<table class="table"> <table class="table">

View file

@ -1,6 +1,14 @@
{% extends "reviews/base.html" %} {% extends "reviews/base.html" %}
{% block body %} {% block body %}
<h3>{{ section }}</h3> <h3>{{ section }}</h3>
{% if reviewed == 'all_reviews' %}
<h4>All proposals</h4>
{% elif reviewed == 'user_reviewed' %}
<h4>Proposals you have reviewed</h4>
{% else %}
<h4>Proposals you have not yet reviewed</h4>
{% endif %}
{% include "reviews/_review_table.html" %} {% include "reviews/_review_table.html" %}
{% endblock %} {% endblock %}