From bc71e53ba56cb2e1c94d9516b051893274d53bb8 Mon Sep 17 00:00:00 2001
From: komalsheth286
Date: Mon, 19 Dec 2016 17:32:16 +0530
Subject: Scipy 2016
---
certificate/models.py | 14 ++-
.../template_SPC2016Tcertificate | 21 +++++
certificate/templates/scipy_download_2016.html | 1 +
certificate/views.py | 103 ++++++++-------------
4 files changed, 71 insertions(+), 68 deletions(-)
create mode 100644 certificate/scipy_template_2016/template_SPC2016Tcertificate
diff --git a/certificate/models.py b/certificate/models.py
index 7d028a0..13b1483 100755
--- a/certificate/models.py
+++ b/certificate/models.py
@@ -5,6 +5,7 @@ from django.contrib.auth.models import User
events = (
('SLC', 'Scilab Conference'),
('SPC', 'Scipy Conference'),
+ ('S16', 'Scipy 2016 Conference'),
('PTC', 'Python Textbook Companion'),
('STC', 'Scilab Textbook Companion'),
('DCM', 'DrupalCamp Mumbai'),
@@ -185,20 +186,25 @@ class Scipy_speaker_2015(models.Model):
class Scipy_participant_2016(models.Model):
name = models.CharField(max_length=50, null=True, blank=True)
email = models.CharField(max_length=50, null=True, blank=True)
- purpose = models.CharField(max_length=10, default='SPC')
-
+ purpose = models.CharField(max_length=10, default='S16')
class Scipy_speaker_2016(models.Model):
name = models.CharField(max_length=300)
email = models.CharField(max_length=300)
paper = models.CharField(max_length=300)
- purpose = models.CharField(max_length=10, default='SPC')
+ purpose = models.CharField(max_length=10, default='S16')
class Scipy_workshop_2016(models.Model):
name = models.CharField(max_length=300)
email = models.CharField(max_length=300)
paper = models.CharField(max_length=300)
- purpose = models.CharField(max_length=10, default='SPC')
+ purpose = models.CharField(max_length=10, default='S16')
+
+class Scipy_TA_2016(models.Model):
+ name = models.CharField(max_length=300)
+ email = models.CharField(max_length=300)
+ paper = models.CharField(max_length=300)
+ purpose = models.CharField(max_length=10, default='S16')
class OpenFOAM_Symposium_participant_2016(models.Model):
name = models.CharField(max_length=50, null=True, blank=True)
diff --git a/certificate/scipy_template_2016/template_SPC2016Tcertificate b/certificate/scipy_template_2016/template_SPC2016Tcertificate
new file mode 100644
index 0000000..3371830
--- /dev/null
+++ b/certificate/scipy_template_2016/template_SPC2016Tcertificate
@@ -0,0 +1,21 @@
+* certificate template
+
+** Usage
+ - To generate a PDF file type,
+ #+BEGIN_SRC sh
+ make $command
+ #+END_SRC sh
+
+ - To clean the project
+ #+BEGIN_SRC sh
+ make clean
+ #+END_SRC sh
+
+** License
+ The tex file and all the images within this project are entirely
+ PRIVATE. It's usage outside the `Fossee Project` is an legal
+ offense and will be subject to suitable punishment by Indian law.
+
+
+** Website
+ [[http://fossee.in]]
diff --git a/certificate/templates/scipy_download_2016.html b/certificate/templates/scipy_download_2016.html
index 0c33134..596dfe0 100644
--- a/certificate/templates/scipy_download_2016.html
+++ b/certificate/templates/scipy_download_2016.html
@@ -24,6 +24,7 @@
Participant
Speaker
Workshop Instructor
+
{% if user_papers %}
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
@@ -139,6 +139,9 @@ def verification(serial, _type):
detail = OrderedDict([('Name', name), ('Event', purpose),
('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':
@@ -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]
--
cgit