summaryrefslogtreecommitdiff
path: root/certificate/views.py
diff options
context:
space:
mode:
authorkomalsheth2862016-12-19 17:32:16 +0530
committerkomalsheth2862016-12-19 17:32:16 +0530
commitbc71e53ba56cb2e1c94d9516b051893274d53bb8 (patch)
treea8df103ea5ac4d270ce23f06c135d89a3c433516 /certificate/views.py
parente17144699de75475870340b7a472737e046dae1b (diff)
downloadcertificate-generator-bc71e53ba56cb2e1c94d9516b051893274d53bb8.tar.gz
certificate-generator-bc71e53ba56cb2e1c94d9516b051893274d53bb8.tar.bz2
certificate-generator-bc71e53ba56cb2e1c94d9516b051893274d53bb8.zip
Scipy 2016
Diffstat (limited to 'certificate/views.py')
-rwxr-xr-xcertificate/views.py103
1 files changed, 39 insertions, 64 deletions
diff --git a/certificate/views.py b/certificate/views.py
index e797c7d..6972bc9 100755
--- a/certificate/views.py
+++ b/certificate/views.py
@@ -2,7 +2,7 @@ from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
-from certificate.models import Drupal_WS, Osdag_WS, Scipy_participant_2016, Scipy_speaker_2016, Scipy_workshop_2016, eSim_WS, Internship_participant,Internship16_participant, Scilab_participant, Certificate, Event, Scilab_speaker, Scilab_workshop, Question, Answer, FeedBack, Scipy_participant, Scipy_speaker, Drupal_camp, Tbc_freeeda, Dwsim_participant, Scilab_arduino, Esim_faculty, Scipy_participant_2015, Scipy_speaker_2015, OpenFOAM_Symposium_participant_2016, OpenFOAM_Symposium_speaker_2016
+from certificate.models import Drupal_WS, Osdag_WS, Scipy_TA_2016, Scipy_participant_2016, Scipy_speaker_2016, Scipy_workshop_2016, eSim_WS, Internship_participant,Internship16_participant, Scilab_participant, Certificate, Event, Scilab_speaker, Scilab_workshop, Question, Answer, FeedBack, Scipy_participant, Scipy_speaker, Drupal_camp, Tbc_freeeda, Dwsim_participant, Scilab_arduino, Esim_faculty, Scipy_participant_2015, Scipy_speaker_2015, OpenFOAM_Symposium_participant_2016, OpenFOAM_Symposium_speaker_2016
import subprocess
import os
from string import Template
@@ -140,6 +140,9 @@ def verification(serial, _type):
('Days', '11 June'), ('Year', year)])
elif purpose == 'SciPy India':
detail = OrderedDict([('Name', name), ('Event', purpose),
+ ('Days', '14 - 16 December'), ('Year', year)])
+ elif purpose == 'SciPy India 2016':
+ detail = OrderedDict([('Name', name), ('Event', purpose),
('Days', '10 - 11 December'), ('Year', year)])
elif purpose == 'OpenFOAM Symposium':
detail = OrderedDict([('Name', name), ('Event', purpose),
@@ -166,6 +169,8 @@ def verification(serial, _type):
detail = '{0} had presented paper on {3} in the {1} {2}'.format\
(name, purpose, year, paper)
if purpose == 'SciPy India':
+ detail = OrderedDict([('Name', name), ('Event', purpose), ('paper', paper), ('Days', '14 - 16 December'), ('Year', year)])
+ elif purpose == 'SciPy India 2016':
detail = OrderedDict([('Name', name), ('Event', purpose), ('paper', paper), ('Days', '10 - 11 December'), ('Year', year)])
elif purpose == 'OpenFOAM Symposium':
detail = OrderedDict([('Name', name), ('Event', purpose), ('paper', paper), ('Days', '27 February'), ('Year', year)])
@@ -184,7 +189,7 @@ def verification(serial, _type):
else:
detail = '{0} had attended {1} {2}'.format(name, purpose, year)
- elif type == 'W':
+ elif type == 'W' or type == 'T':
detail = '{0} had attended workshop on {3} in the {1} {2}'.format\
(name, purpose, year, workshop)
context['serial_key'] = True
@@ -222,7 +227,7 @@ def verification(serial, _type):
detail = '{0} had attended {1} {2}'.format(name, purpose, year)
elif type == 'A':
detail = '{0} had presented paper on {3} in the {1} {2}'.format(name, purpose, year, paper)
- elif type == 'W':
+ elif type == 'W' or type == 'T':
detail = '{0} had attended workshop on {3} in the {1} {2}'.format(name, purpose, year, workshop)
context['detail'] = detail
except Certificate.DoesNotExist:
@@ -251,6 +256,8 @@ def _get_detail(serial_no):
purpose = 'Scilab Conference'
elif serial_no[0:3] == 'SPC':
purpose = 'SciPy India'
+ elif serial_no[0:3] == 'S16':
+ purpose = 'SciPy India 2016'
elif serial_no[0:3] == 'DCM':
purpose = 'DrupalCamp Mumbai'
elif serial_no[0:3] == 'FET':
@@ -340,6 +347,8 @@ def _make_certificate_certificate(path, type, file_name):
command = 'paper_cert'
elif type == 'W':
command = 'workshop_cert'
+ elif type == 'T':
+ command = 'workshop_cert'
process = subprocess.Popen('timeout 15 make -C {0} {1} file_name={2}'.format(path, command, file_name),
stderr = subprocess.PIPE, shell = True)
err = process.communicate()[1]
@@ -1772,6 +1781,7 @@ def scipy_download_2016(request):
return render_to_response('scipy_download_2016.html', context, context_instance=ci)
else:
user = user[0]
+ paper = "paper name temporary"
elif type == 'A':
if paper:
user = Scipy_speaker_2016.objects.filter(email=email, paper=paper)
@@ -1790,24 +1800,33 @@ def scipy_download_2016(request):
user = user[0]
paper = user.paper
elif type == 'W':
- print " type w"
if paper:
- print " paper"
user = Scipy_workshop_2016.objects.filter(email=email, paper=paper)
if user:
- print " user"
user = [user[0]]
else:
- print "else 1"
user = Scipy_workshop_2016.objects.filter(email=email)
- for u in user:
- print "user", u.email
if not user:
- print "no user"
context["notregistered"] = 1
return render_to_response('scipy_download_2016.html', context, context_instance=ci)
if len(user) > 1:
- print "len > 1"
+ context['user_papers'] = user
+ context['v'] = 'paper'
+ return render_to_response('scipy_download_2016.html', context, context_instance=ci)
+ else:
+ user = user[0]
+ paper = user.paper
+ elif type == 'T':
+ if paper:
+ user = Scipy_TA_2016.objects.filter(email=email, paper=paper)
+ if user:
+ user = [user[0]]
+ else:
+ user = Scipy_TA_2016.objects.filter(email=email)
+ if not user:
+ context["notregistered"] = 1
+ return render_to_response('scipy_download_2016.html', context, context_instance=ci)
+ if len(user) > 1:
context['user_papers'] = user
context['v'] = 'paper'
return render_to_response('scipy_download_2016.html', context, context_instance=ci)
@@ -1816,7 +1835,6 @@ def scipy_download_2016(request):
paper = user.paper
name = user.name
email = user.email
- print ">>>>>>>>>>>>>>>>>>>>>>", email
purpose = user.purpose
year = '16'
id = int(user.id)
@@ -1832,7 +1850,6 @@ def scipy_download_2016(request):
qrcode = 'Verify at: http://fossee.in/certificates/verify/{0} '.format(old_user.short_key)
details = {'name': name, 'serial_key': old_user.short_key, 'email' : email}
certificate = create_scipy_certificate_2016(certificate_path, details, qrcode, type, paper, workshop, file_name)
- print "==========", certificate[1]
if not certificate[1]:
old_user.counter = old_user.counter + 1
old_user.save()
@@ -1866,44 +1883,6 @@ def scipy_download_2016(request):
return render_to_response('scipy_download_2016.html', context, ci)
-
-
- # try:
- # old_user = Certificate.objects.get(email=email, serial_no=serial_no)
- # qrcode = 'Verify at: http://fossee.in/certificates/verify/{0} '.format(old_user.short_key)
- # details = {'name': name, 'serial_key': old_user.short_key}
- # certificate = create_scipy_certificate_2016(certificate_path, details, qrcode, type, paper, workshop, file_name)
- # if not certificate[1]:
- # old_user.counter = old_user.counter + 1
- # old_user.save()
- # return certificate[0]
- # except Certificate.DoesNotExist:
- # uniqueness = False
- # num = 5
- # while not uniqueness:
- # present = Certificate.objects.filter(short_key__startswith=serial_key[0:num])
- # if not present:
- # short_key = serial_key[0:num]
- # uniqueness = True
- # else:
- # num += 1
- # qrcode = 'Verify at: http://fossee.in/certificates/verify/{0} '.format(short_key)
- # details = {'name': name, 'serial_key': short_key}
- # certificate = create_scipy_certificate_2016(certificate_path, details,
- # qrcode, type, paper, workshop, file_name)
- # if not certificate[1]:
- # certi_obj = Certificate(name=name, email=email, serial_no=serial_no,
- # counter=1, workshop=workshop, paper=paper, serial_key=serial_key, short_key=short_key)
- # certi_obj.save()
- # return certificate[0]
-
- # if certificate[1]:
- # _clean_certificate_certificate(certificate_path, file_name)
- # context['error'] = True
- # return render_to_response('scipy_download_2016.html', context, ci)
- # context['message'] = ''
- # return render_to_response('scipy_download_2016.html', context, ci)
-
@csrf_exempt
def create_scipy_certificate_2016(certificate_path, name, qrcode, type, paper, workshop, file_name):
error = False
@@ -1918,6 +1897,9 @@ def create_scipy_certificate_2016(certificate_path, name, qrcode, type, paper, w
elif type == 'A':
template = 'template_SPC2016Acertificate'
download_file_name = 'SPC2016Acertificate.pdf'
+ elif type == 'T':
+ template = 'template_SPC2016Tcertificate'
+ download_file_name = 'SPC2016Tcertificate.pdf'
template_file = open('{0}{1}'.format\
(certificate_path, template), 'r')
@@ -1932,22 +1914,15 @@ def create_scipy_certificate_2016(certificate_path, name, qrcode, type, paper, w
elif type == 'W':
content_tex = content.safe_substitute(name=name['name'].title(),
serial_key=name['serial_key'], qr_code=qrcode, paper=paper)
+ elif type == 'T':
+ content_tex = content.safe_substitute(name=name['name'].title(),
+ serial_key=name['serial_key'], qr_code=qrcode, paper=paper)
create_tex = open('{0}{1}.tex'.format\
(certificate_path, file_name), 'w')
create_tex.write(content_tex)
create_tex.close()
return_value, err = _make_certificate_certificate(certificate_path, type, file_name)
-
- # if return_value == 0:
- # pdf = open('{0}{1}.pdf'.format(certificate_path, file_name) , 'r')
- # response = HttpResponse(content_type='application/pdf')
- # response['Content-Disposition'] = 'attachment; \
- # filename=%s' % (download_file_name)
- # response.write(pdf.read())
- # _clean_certificate_certificate(certificate_path, file_name)
- # return [response, False]
- # else:
- # error = True
+
if return_value == 0:
pdf = open('{0}{1}.pdf'.format(certificate_path, file_name) , 'r')
@@ -1973,14 +1948,14 @@ def create_scipy_certificate_2016(certificate_path, name, qrcode, type, paper, w
email.send(fail_silently=True)
except Exception as e:
- print "===============================", e
+ pass
_clean_certificate_certificate(certificate_path, file_name)
return [None, False]
else:
error = True
- except Exception, e:
+ except Exception, e:
error = True
return [None, error]