cleaned up code style

This commit is contained in:
Brian Rosner 2013-06-11 11:10:29 -06:00
parent 1bf3a25e2c
commit 6c1cfd1a53
5 changed files with 22 additions and 21 deletions

View file

@ -3,11 +3,12 @@ import csv
from django.http import HttpResponse from django.http import HttpResponse
def export_as_csv_action(description="Export selected objects as CSV file", def export_as_csv_action(
description="Export selected objects as CSV file",
fields=None, exclude=None, header=True): fields=None, exclude=None, header=True):
""" """
This function returns an export csv action This function returns an export csv action
'fields' and 'exclude' work like in django ModelForm 'fields' and 'exclude' work like in Django ModelForm
'header' is whether or not to output the column names as the first row 'header' is whether or not to output the column names as the first row
""" """
def export_as_csv(modeladmin, request, queryset): def export_as_csv(modeladmin, request, queryset):
@ -22,10 +23,8 @@ def export_as_csv_action(description="Export selected objects as CSV file",
elif exclude: elif exclude:
excludeset = set(exclude) excludeset = set(exclude)
field_names = field_names - excludeset field_names = field_names - excludeset
response = HttpResponse(mimetype="text/csv")
response = HttpResponse(mimetype='text/csv') response["Content-Disposition"] = "attachment; filename=%s.csv" % unicode(opts).replace(".", "_")
response['Content-Disposition'] = 'attachment; filename=%s.csv' % unicode(opts).replace('.', '_')
writer = csv.writer(response) writer = csv.writer(response)
if header: if header:
writer.writerow(list(field_names)) writer.writerow(list(field_names))

View file

@ -23,7 +23,7 @@ from symposion.proposals.forms import AddSpeakerForm, SupportingDocumentCreateFo
def get_form(name): def get_form(name):
dot = name.rindex('.') dot = name.rindex(".")
mod_name, form_name = name[:dot], name[dot + 1:] mod_name, form_name = name[:dot], name[dot + 1:]
__import__(mod_name) __import__(mod_name)
return getattr(sys.modules[mod_name], form_name) return getattr(sys.modules[mod_name], form_name)

View file

@ -5,6 +5,7 @@ from symposion.reviews.models import Review, ReviewAssignment
register = template.Library() register = template.Library()
@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

@ -65,7 +65,7 @@ def proposals_generator(request, queryset, user_pk=None, check_speaker=True):
# Returns a list of all proposals, proposals reviewed by the user, or the proposals the user has yet to review # 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 # depending on the link user clicks in dashboard
@login_required @login_required
def review_section(request, section_slug, assigned=False, reviewed='all'): 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)
@ -77,16 +77,17 @@ def review_section(request, section_slug, assigned=False, reviewed='all'):
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)
# passing reviewed in from reviews.urls and out to review_list for appropriate template header rendering # passing reviewed in from reviews.urls and out to review_list for
if reviewed == 'all': # appropriate template header rendering
if reviewed == "all":
queryset = queryset.select_related("result").select_subclasses() queryset = queryset.select_related("result").select_subclasses()
reviewed = 'all_reviews' reviewed = "all_reviews"
elif reviewed == 'reviewed': elif reviewed == "reviewed":
queryset = queryset.filter(reviews__user=request.user) queryset = queryset.filter(reviews__user=request.user)
reviewed = 'user_reviewed' reviewed = "user_reviewed"
else: else:
queryset = queryset.exclude(reviews__user=request.user).exclude(speaker=request.user) queryset = queryset.exclude(reviews__user=request.user).exclude(speaker=request.user)
reviewed = 'user_not_reviewed' reviewed = "user_not_reviewed"
proposals = proposals_generator(request, queryset) proposals = proposals_generator(request, queryset)

View file

@ -188,7 +188,7 @@ class SponsorBenefit(models.Model):
upload = models.FileField(_("file"), blank=True, upload_to="sponsor_files") upload = models.FileField(_("file"), blank=True, upload_to="sponsor_files")
class Meta: class Meta:
ordering = ['-active'] ordering = ["-active"]
def __unicode__(self): def __unicode__(self):
return u"%s - %s" % (self.sponsor, self.benefit) return u"%s - %s" % (self.sponsor, self.benefit)