Skip to content

Commit

Permalink
Bitsians qrcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Megh-Thakkar committed Nov 6, 2017
1 parent 43bd1f5 commit 3093cb4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 70 deletions.
10 changes: 9 additions & 1 deletion messportal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,15 @@ def view_all_profshow_bills(request):
'headings':headings,
'title':title,
}
return render(request, 'messportal/tables.html', {'tables':[table, table2]})
rows = [{'data':[attendance.bitsian.name, attendance.bitsian.long_id, attendance.prof_show.name,attendance.count,attendance.passed_count, ], 'link':[]} for attendance in Attendance.objects.filter(bitsian__isnull=False)]
headings = ['Name', 'Id', 'Prof Show', 'Passed Left','Passes Used']
title = 'Bitsian QR Signings'
table3 = {
'rows':rows,
'headings':headings,
'title':title,
}
return render(request, 'messportal/tables.html', {'tables':[table, table2, table3]})

def get_bits_id(bill):
if bill.bits_id:
Expand Down
1 change: 0 additions & 1 deletion registrations/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@
url(r'^email_confirm/(?P<token>\w+)/$', views.email_confirm, name="email_confirm"),
url(r'^payment_api_request', views.apirequest, name="API Request"),
url(r'^manage_events/$', views.manage_events, name='manage_events'),
url(r'^get_list/$', views.get_list, name='get_list'),
]
69 changes: 1 addition & 68 deletions registrations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,71 +970,4 @@ def send_mail():
print 'Error sending mail'
print 'Emails sent'

##########################################################

@staff_member_required
def get_list(request):
from django.http import HttpResponse, HttpResponseRedirect
import xlsxwriter
from .models import Participant
try:
import cStringIO as StringIO
except ImportError:
import StringIO
a_list = []


entries = [part for part in Participant.objects.filter(firewallz_passed=True) if part.participation_set.filter(event__name='FashP')]

for p in entries:
a_list.append({'obj': p})
data = sorted(a_list, key=lambda k: k['obj'].id)
output = StringIO.StringIO()
workbook = xlsxwriter.Workbook(output)
worksheet = workbook.add_worksheet('new-spreadsheet')
date_format = workbook.add_format({'num_format': 'mmmm d yyyy'})
worksheet.write(0, 0, "Generated:")
from time import gmtime, strftime
generated = strftime("%d-%m-%Y %H:%M:%S UTC", gmtime())
worksheet.write(0, 1, generated)

worksheet.write(1, 0, "ID")
worksheet.write(1, 1, "Name")
worksheet.write(1, 2, "Email ID")
worksheet.write(1, 3, "Mobile No.")
worksheet.write(1, 4, "College")

for i, row in enumerate(data):
"""for each object in the date list, attribute1 & attribute2
are written to the first & second column respectively,
for the relevant row. The 3rd arg is a failure message if
there is no data available"""

worksheet.write(i+2, 0, deepgetattr(row['obj'], 'id', 'NA'))
worksheet.write(i+2, 1, deepgetattr(row['obj'], 'name', 'NA'))
worksheet.write(i+2, 2, deepgetattr(row['obj'], 'email', 'NA'))
worksheet.write(i+2, 3, deepgetattr(row['obj'], 'phone', 'NA'))
worksheet.write(i+2, 4, get_college_name(row['obj']))

workbook.close()
filename = 'ExcelReport.xlsx'
output.seek(0)
response = HttpResponse(output.read(), content_type="application/ms-excel")
response['Content-Disposition'] = 'attachment; filename=%s' % filename
return response

def get_college_name(part):
return part.college.name

def deepgetattr(obj, attr, default = None):

attributes = attr.split(".")
for i in attributes:
try:
obj = getattr(obj, i)
except AttributeError:
if default:
return default
else:
raise
return obj
##########################################################

0 comments on commit 3093cb4

Please sign in to comment.