Changeset 7d7801f
- Timestamp:
- Mar 17, 2013, 6:58:58 AM (13 years ago)
- Branches:
- master, space-access, stable, stage
- Children:
- cf509c0
- Parents:
- d848b98
- git-author:
- Alex Dehnert <adehnert@…> (03/17/13 06:58:58)
- git-committer:
- Alex Dehnert <adehnert@…> (03/17/13 06:58:58)
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r7ef7143 r7d7801f 7 7 asadb/media/fysm/slides/ 8 8 asadb/media/page-previews/fysm/ 9 asadb/media/midway/maps/ 9 10 asadb/util/saved-data/ 10 11 asadb/util/static-data/ -
asadb/forms/views.py
rd848b98 r7d7801f 23 23 from django.db.models import Q, Count 24 24 25 import collections 25 26 import csv 26 27 import datetime … … 576 577 assignments = forms.models.MidwayAssignment.objects.filter(midway=midway) 577 578 context['assignments'] = assignments 579 context['pagename'] = 'midway' 578 580 579 581 return context … … 587 589 midway = get_object_or_404(forms.models.Midway, slug=slug, ) 588 590 591 uploaded = False 592 found = [] 593 issues = collections.defaultdict(list) 594 589 595 if request.method == 'POST': # If the form has been submitted... 590 596 form = MidwayAssignmentsUploadForm(request.POST, request.FILES, ) # A form bound to the POST data 591 597 592 598 if form.is_valid(): # All validation rules pass 593 pass 599 uploaded = True 600 reader = csv.DictReader(request.FILES['assignments']) 601 for row in reader: 602 group_name = row['Group'] 603 group_officers = row['officers'] 604 table = row['Table'] 605 issue = False 606 try: 607 group = groups.models.Group.objects.get(name=group_name) 608 assignment = forms.models.MidwayAssignment( 609 midway=midway, 610 location=table, 611 group=group, 612 ) 613 assignment.save() 614 found.append(assignment) 615 status = group.group_status.slug 616 if status != 'active': 617 issue = 'status=%s (added anyway)' % (status, ) 618 except groups.models.Group.DoesNotExist: 619 issue = 'unknown group (ignored)' 620 if issue: 621 issues[issue].append((group_name, group_officers, table)) 622 for issue in issues: 623 issues[issue] = sorted(issues[issue], key=lambda x: x[0]) 624 594 625 else: 595 626 form = MidwayAssignmentsUploadForm() # An unbound form … … 598 629 'midway':midway, 599 630 'form':form, 631 'uploaded': uploaded, 632 'found': found, 633 'issues': dict(issues), 634 #'issues': issues, 600 635 'pagename':'midway', 601 636 } -
asadb/template/midway/upload.html
rd848b98 r7d7801f 3 3 {% block title %}ASA: {{midway.name}}: upload assignments{% endblock %} 4 4 {% block content %} 5 <h2>{{midway.name}}: upload assignments</h2> 5 <h1>{{midway.name}}: upload assignments</h1> 6 7 {% if uploaded %} 8 <h2>Results</h2> 9 10 <h3>New entries added ({{found|length}})</h3> 11 12 <table class='pretty-table'> 13 <tr> 14 <th>Group</th> 15 <th>Table</th> 16 </tr> 17 {% for assignment in found %} 18 <tr> 19 <th>{{assignment.group}}</th> 20 <td>{{assignment.location}}</td> 21 </tr> 22 {% endfor %} 23 </table> 24 25 {% for issue, cases in issues.items %} 26 <h3>Issue: {{issue}} ({{cases|length}})</h3> 27 <table class='pretty-table'> 28 <tr> 29 <th>Name</th> 30 <th>Email</th> 31 <th>Table</th> 32 </tr> 33 {% for name, email, table in cases %} 34 <tr> 35 <th>{{name}}</th> 36 <td>{{email}}</td> 37 <td>{{table}}</td> 38 </tr> 39 {% endfor %} 40 </table> 41 {% endfor %} 42 43 <!-- end of results --> 44 {% endif %} 45 46 <h2>Input</h2> 6 47 7 48 <form enctype="multipart/form-data" method="post" action="">
Note: See TracChangeset
for help on using the changeset viewer.