Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drupal in a day workshop certificated generated #33

Merged
merged 2 commits into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions certificate/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ class Drupal_WS(models.Model):
name = models.CharField(max_length=200)
email = models.EmailField()
purpose = models.CharField(max_length=10, default='DRP')
status = models.BooleanField(default=False)
date = models.DateField(default='2016-01-01')

class OpenModelica_WS(models.Model):
name = models.CharField(max_length=200)
Expand Down
2 changes: 1 addition & 1 deletion certificate/templates/drupal_download.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% block header%}
<h1> Drupal Camp Mumbai 2015 </h1>
<h1> Drupal Camp Mumbai</h1>
{% endblock %}
{% block content %}
<div class="modal fade" id="invalidModal" tabindex="-1" role="dialog" aria-labelledby="invalidModalLabel" aria-hidden="true">
Expand Down
2 changes: 1 addition & 1 deletion certificate/templates/drupal_workshop_download.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% block header%}
<h1> Drupal Workshop 2016</h1>
<h1> Drupal Workshop</h1>
{% endblock %}
{% block content %}
<div class="modal fade" id="invalidModal" tabindex="-1" role="dialog" aria-labelledby="invalidModalLabel" aria-hidden="true">
Expand Down
4 changes: 2 additions & 2 deletions certificate/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1> FOSSEE Certificates </h1>
<li><a href="{% url 'certificate:python_workshop_download' %}" >Python Workshop</a></li>
<li><a href="{% url 'certificate:openmodelica_feedback_2017' %}" >OpenModelica Workshop 2017</a></li>
<li><a href="{% url 'certificate:scipy_feedback_2016' %}" >SciPy India Conference 2016</a></li>
<li><a href="{% url 'certificate:drupal_workshop_download' %}" >Drupal Workshop 2016</a></li>
<li><a href="{% url 'certificate:drupal_workshop_download' %}" >Drupal Workshop</a></li>
<li><a href="{% url 'certificate:esim_workshop_feedback' %}" >eSim Workshop 2016</a></li>
<li><a href="{% url 'certificate:osdag_workshop_download' %}" >Osdag Workshop</a></li>
<li><a href="{% url 'certificate:openfoam_symposium_feedback_2016' %}" >OpenFOAM Symposium 2016</a></li>
Expand All @@ -23,7 +23,7 @@ <h1> FOSSEE Certificates </h1>
<li><a href="{% url 'certificate:arduino_google_feedback' %}" >Scilab Arduino Workshop 2015</a></li>
<li><a href="{% url 'certificate:dwsim_feedback' %}" >DWSIM Workshop 2015</a></li>
<li><a href="{% url 'certificate:tbc_freeeda_download' %}" >FreeEDA Textbook Companion</a></li>
<li><a href="{% url 'certificate:drupal_feedback' %}" >Drupal Camp Mumbai 2015</a></li>
<li><a href="{% url 'certificate:drupal_feedback' %}" >Drupal Camp Mumbai</a></li>
<li><a href="{% url 'certificate:scipy_feedback' %}" >SciPy India Conference 2014</a></li>
<li><a href="{% url 'certificate:feedback' %}" >Scilab India Conference 2014</a></li>
<li><a href="{% url 'certificate:scipy_feedback_2017' %}" >Scilab India Conference 2017 Feedback</a></li>
Expand Down
44 changes: 27 additions & 17 deletions certificate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,11 @@ def verification(serial, _type):
('Year', year)
])
elif purpose == 'Drupal Workshop':
faculty = Drupal_WS.objects.get(email=certificate.email)
drupal_ws = Drupal_WS.objects.get(email=certificate.email)
detail = OrderedDict([
('Name', name),
('Event', purpose),
('Days', '30 July'),
('Year', year)
('Date', drupal_ws.date),
])
elif purpose == 'OpenModelica Workshop':
faculty = OpenModelica_WS.objects.get(email=certificate.email)
Expand Down Expand Up @@ -741,7 +740,7 @@ def drupal_download(request):
file_name = file_name.replace('.', '')
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)
qrcode = 'https://fossee.in/certificates/verify/{0} '.format(old_user.short_key)
details = {'name': name, 'day': day, 'serial_key': old_user.short_key}
certificate = create_drupal_certificate(certificate_path, details,
qrcode, type, paper, workshop, file_name)
Expand All @@ -759,7 +758,7 @@ def drupal_download(request):
uniqueness = True
else:
num += 1
qrcode = 'Verify at: http://fossee.in/certificates/verify/{0} '.format(short_key)
qrcode = 'https://fossee.in/certificates/verify/{0} '.format(short_key)
details = {'name': name, 'day': day, 'serial_key': short_key}
certificate = create_drupal_certificate(certificate_path, details,
qrcode, type, paper, workshop, file_name)
Expand Down Expand Up @@ -1366,7 +1365,10 @@ def drupal_workshop_download(request):
user = user[0]
name = user.name
purpose = user.purpose
year = '16'
status = 'successfully completed' if user.status else 'participated in'
ws_date = user.date
ws_date = datetime.strftime(ws_date, '%d %B %Y')
year = ws_date[-2:]
id = int(user.id)
hexa = hex(id).replace('0x', '').zfill(6).upper()
serial_no = '{0}{1}{2}{3}'.format(purpose, year, hexa, type)
Expand All @@ -1375,8 +1377,11 @@ def drupal_workshop_download(request):
file_name = file_name.replace('.', '')
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}
qrcode = 'https://fossee.in/certificates/verify/{0} '.format(old_user.short_key)
details = {
'name': name, 'serial_key': old_user.short_key,
'status': status, 'ws_date': ws_date
}
certificate = create_drupal_workshop_certificate(certificate_path, details,
qrcode, type, paper, workshop, file_name)
if not certificate[1]:
Expand All @@ -1393,8 +1398,11 @@ def drupal_workshop_download(request):
uniqueness = True
else:
num += 1
qrcode = 'Verify at: http://fossee.in/certificates/verify/{0} '.format(short_key)
details = {'name': name, 'serial_key': short_key}
qrcode = 'https://fossee.in/certificates/verify/{0} '.format(short_key)
details = {
'name': name, 'serial_key': short_key,
'status': status, 'ws_date': ws_date
}
certificate = create_drupal_workshop_certificate(certificate_path, details,
qrcode, type, paper, workshop, file_name)
if not certificate[1]:
Expand All @@ -1413,20 +1421,23 @@ def drupal_workshop_download(request):
return render_to_response('drupal_workshop_download.html', context, ci)


def create_drupal_workshop_certificate(certificate_path, name, qrcode, type, paper, workshop, file_name):
def create_drupal_workshop_certificate(certificate_path, detail, qrcode, type, paper, workshop, file_name):
error = False
err = None
try:
year = detail["ws_date"][-4:]
download_file_name = None
template = 'template_DWS2016Pcertificate'
download_file_name = 'DWS2016Pcertificate.pdf'
template = 'template_DWS2018Pcertificate'
download_file_name = 'DWS%sPcertificate.pdf'% year

template_file = open('{0}{1}'.format(certificate_path, template), 'r')
content = Template(template_file.read())
template_file.close()

content_tex = content.safe_substitute(name=name['name'].title(),
serial_key=name['serial_key'], qr_code=qrcode)
content_tex = content.safe_substitute(name=detail['name'].title(),
serial_key=detail['serial_key'], qr_code=qrcode,
status=detail['status'], ws_date=detail['ws_date']
)
create_tex = open('{0}{1}.tex'.format(certificate_path, file_name), 'w')
create_tex.write(content_tex)
create_tex.close()
Expand Down Expand Up @@ -2622,7 +2633,6 @@ def python_workshop_download(request):
ws_date[1] = calendar.month_name[int(ws_date[1])]
ws_date.reverse()
ws_date = ' '.join(ws_date)
print(ws_date)
paper = None
workshop = None
if type == 'P':
Expand Down Expand Up @@ -2721,7 +2731,7 @@ def create_python_workshop_certificate(certificate_path, name, qrcode, type, pap
template_file.close()

content_tex = content.safe_substitute(name=name['name'].title(),
serial_key = name['serial_key'], qr_code=qrcode, college = college, paper = paper, ws_date= ws_date)
serial_key=name['serial_key'], qr_code=qrcode, college=college, paper=paper, ws_date=ws_date)
create_tex = open('{0}{1}.tex'.format\
(certificate_path, file_name), 'w')
create_tex.write(content_tex)
Expand Down