cleaned up code style
This commit is contained in:
parent
1bf3a25e2c
commit
6c1cfd1a53
5 changed files with 22 additions and 21 deletions
|
@ -3,11 +3,12 @@ import csv
|
|||
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):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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:
|
||||
excludeset = set(exclude)
|
||||
field_names = field_names - excludeset
|
||||
|
||||
response = HttpResponse(mimetype='text/csv')
|
||||
response['Content-Disposition'] = 'attachment; filename=%s.csv' % unicode(opts).replace('.', '_')
|
||||
|
||||
response = HttpResponse(mimetype="text/csv")
|
||||
response["Content-Disposition"] = "attachment; filename=%s.csv" % unicode(opts).replace(".", "_")
|
||||
writer = csv.writer(response)
|
||||
if header:
|
||||
writer.writerow(list(field_names))
|
||||
|
|
|
@ -23,7 +23,7 @@ from symposion.proposals.forms import AddSpeakerForm, SupportingDocumentCreateFo
|
|||
|
||||
|
||||
def get_form(name):
|
||||
dot = name.rindex('.')
|
||||
dot = name.rindex(".")
|
||||
mod_name, form_name = name[:dot], name[dot + 1:]
|
||||
__import__(mod_name)
|
||||
return getattr(sys.modules[mod_name], form_name)
|
||||
|
|
|
@ -5,6 +5,7 @@ from symposion.reviews.models import Review, ReviewAssignment
|
|||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.assignment_tag(takes_context=True)
|
||||
def review_assignments(context):
|
||||
request = context["request"]
|
||||
|
|
|
@ -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
|
||||
# depending on the link user clicks in dashboard
|
||||
@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):
|
||||
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")
|
||||
queryset = queryset.filter(id__in=assignments)
|
||||
|
||||
# passing reviewed in from reviews.urls and out to review_list for appropriate template header rendering
|
||||
if reviewed == 'all':
|
||||
# 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':
|
||||
reviewed = "all_reviews"
|
||||
elif reviewed == "reviewed":
|
||||
queryset = queryset.filter(reviews__user=request.user)
|
||||
reviewed = 'user_reviewed'
|
||||
reviewed = "user_reviewed"
|
||||
else:
|
||||
queryset = queryset.exclude(reviews__user=request.user).exclude(speaker=request.user)
|
||||
reviewed = 'user_not_reviewed'
|
||||
reviewed = "user_not_reviewed"
|
||||
|
||||
proposals = proposals_generator(request, queryset)
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ class SponsorBenefit(models.Model):
|
|||
upload = models.FileField(_("file"), blank=True, upload_to="sponsor_files")
|
||||
|
||||
class Meta:
|
||||
ordering = ['-active']
|
||||
ordering = ["-active"]
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s - %s" % (self.sponsor, self.benefit)
|
||||
|
|
Loading…
Reference in a new issue