summaryrefslogtreecommitdiff
path: root/workshop_app
diff options
context:
space:
mode:
Diffstat (limited to 'workshop_app')
-rw-r--r--[-rwxr-xr-x]workshop_app/data/Basics_of_Python/Basics_of_Python.pdf (renamed from workshop_app/data/Basic Python Schedule.pdf)bin55260 -> 55260 bytes
-rw-r--r--[-rwxr-xr-x]workshop_app/data/Basics_of_Python/instructions-for-coordinators.pdf (renamed from workshop_app/data/instructions-for-coordinators.pdf)bin36506 -> 36506 bytes
-rw-r--r--[-rwxr-xr-x]workshop_app/data/Basics_of_Python/instructions-for-participants.pdf (renamed from workshop_app/data/instructions-for-participants.pdf)bin51627 -> 51627 bytes
-rw-r--r--workshop_app/data/ISCP/Basics_of_Python.pdfbin0 -> 55260 bytes
-rw-r--r--[-rwxr-xr-x]workshop_app/data/ISCP/ISCP.pdf (renamed from workshop_app/data/ISCP schedule.pdf)bin32900 -> 32900 bytes
-rw-r--r--workshop_app/data/ISCP/instructions-for-participants.pdfbin0 -> 51627 bytes
-rw-r--r--workshop_app/data/flowchart.pdf (renamed from workshop_app/data/structure.pdf)bin27485 -> 27485 bytes
-rw-r--r--workshop_app/forms.py3
-rw-r--r--workshop_app/models.py9
-rw-r--r--workshop_app/send_mails.py29
-rw-r--r--workshop_app/templates/workshop_app/index.html2
-rw-r--r--workshop_app/views.py11
12 files changed, 30 insertions, 24 deletions
diff --git a/workshop_app/data/Basic Python Schedule.pdf b/workshop_app/data/Basics_of_Python/Basics_of_Python.pdf
index 00401d0..00401d0 100755..100644
--- a/workshop_app/data/Basic Python Schedule.pdf
+++ b/workshop_app/data/Basics_of_Python/Basics_of_Python.pdf
Binary files differ
diff --git a/workshop_app/data/instructions-for-coordinators.pdf b/workshop_app/data/Basics_of_Python/instructions-for-coordinators.pdf
index 7601616..7601616 100755..100644
--- a/workshop_app/data/instructions-for-coordinators.pdf
+++ b/workshop_app/data/Basics_of_Python/instructions-for-coordinators.pdf
Binary files differ
diff --git a/workshop_app/data/instructions-for-participants.pdf b/workshop_app/data/Basics_of_Python/instructions-for-participants.pdf
index 93a3e5d..93a3e5d 100755..100644
--- a/workshop_app/data/instructions-for-participants.pdf
+++ b/workshop_app/data/Basics_of_Python/instructions-for-participants.pdf
Binary files differ
diff --git a/workshop_app/data/ISCP/Basics_of_Python.pdf b/workshop_app/data/ISCP/Basics_of_Python.pdf
new file mode 100644
index 0000000..00401d0
--- /dev/null
+++ b/workshop_app/data/ISCP/Basics_of_Python.pdf
Binary files differ
diff --git a/workshop_app/data/ISCP schedule.pdf b/workshop_app/data/ISCP/ISCP.pdf
index 203f5e0..203f5e0 100755..100644
--- a/workshop_app/data/ISCP schedule.pdf
+++ b/workshop_app/data/ISCP/ISCP.pdf
Binary files differ
diff --git a/workshop_app/data/ISCP/instructions-for-participants.pdf b/workshop_app/data/ISCP/instructions-for-participants.pdf
new file mode 100644
index 0000000..93a3e5d
--- /dev/null
+++ b/workshop_app/data/ISCP/instructions-for-participants.pdf
Binary files differ
diff --git a/workshop_app/data/structure.pdf b/workshop_app/data/flowchart.pdf
index 35e6776..35e6776 100644
--- a/workshop_app/data/structure.pdf
+++ b/workshop_app/data/flowchart.pdf
Binary files differ
diff --git a/workshop_app/forms.py b/workshop_app/forms.py
index ec6db80..b5c3d27 100644
--- a/workshop_app/forms.py
+++ b/workshop_app/forms.py
@@ -1,4 +1,3 @@
-
from django import forms
from django.utils import timezone
from .models import (
@@ -25,7 +24,7 @@ position_choices = (
)
department_choices = (
- ("computer", "Computer Science"),
+ ("computer engineering", "Computer Science"),
("information technology", "Information Technology"),
("civil engineering", "Civil Engineering"),
("electrical engineering", "Electrical Engineering"),
diff --git a/workshop_app/models.py b/workshop_app/models.py
index 9745fd3..35a1f38 100644
--- a/workshop_app/models.py
+++ b/workshop_app/models.py
@@ -3,6 +3,7 @@ from django.db import models
from django.contrib.auth.models import User
from django.core.validators import RegexValidator
from recurrence.fields import RecurrenceField
+import os
position_choices = (
("coordinator", "Coordinator"),
@@ -27,6 +28,9 @@ def has_profile(user):
""" check if user has profile """
return True if hasattr(user, 'profile') else False
+def attachments(instance, filename):
+ return os.sep.join((instance.workshoptype_name.replace(" ", '_'), filename))
+
class Profile(models.Model):
"""Profile for users(instructors and coordinators)"""
@@ -70,6 +74,11 @@ class WorkshopType(models.Model):
workshoptype_duration = models.CharField(max_length=32,
help_text='Please write this in \
following format eg: 3days, 8hours a day')
+ workshoptype_attachments = models.FileField(upload_to=attachments, blank=True,
+ help_text='Please upload workshop documents one by one, \
+ ie.workshop schedule, instructions etc. \
+ Please Note: Name of Schedule file should be similar to \
+ WorkshopType Name')
def __str__(self):
return u"{0} {1}".format(self.workshoptype_name,
diff --git a/workshop_app/send_mails.py b/workshop_app/send_mails.py
index 7eb5fff..3f2e7c2 100644
--- a/workshop_app/send_mails.py
+++ b/workshop_app/send_mails.py
@@ -28,6 +28,7 @@ from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
from time import sleep
+from .models import WorkshopType
def generate_activation_key(username):
"""Generates hashed secret key for email activation"""
@@ -239,20 +240,16 @@ def send_email( request, call_on,
subject = "FOSSEE Workshop booking confirmation on {0}".\
format(workshop_date)
msg = EmailMultiAlternatives(subject, message, SENDER_EMAIL, [request.user.email])
-
- files = listdir(settings.MEDIA_ROOT)
+ attachment_paths = path.join(settings.MEDIA_ROOT, workshop_title.replace(" ","_"))
+ files = listdir(attachment_paths)
for f in files:
- print(f, workshop_title)
- if f == workshop_title+' schedule.pdf' or \
- f == 'instructions-for-coordinators.pdf' or \
- f == 'instructions-for-participants.pdf':
- attachment = open(path.join(settings.MEDIA_ROOT,f), 'rb')
- part = MIMEBase('application', 'octet-stream')
- part.set_payload((attachment).read())
- encoders.encode_base64(part)
- part.add_header('Content-Disposition', "attachment; filename= %s " % f)
- msg.attach(part)
- sleep(1)
+ attachment = open(path.join(attachment_paths, f), 'rb')
+ part = MIMEBase('application', 'octet-stream')
+ part.set_payload((attachment).read())
+ encoders.encode_base64(part)
+ part.add_header('Content-Disposition', "attachment; filename= %s " % f)
+ msg.attach(part)
+ sleep(1)
msg.send()
else:
@@ -275,10 +272,10 @@ def send_email( request, call_on,
subject = "FOSSEE Workshop booking confirmation on {0}".\
format(workshop_date)
msg = EmailMultiAlternatives(subject, message, SENDER_EMAIL, [other_email])
-
- files = listdir(settings.MEDIA_ROOT)
+ attachment_paths = path.join(settings.MEDIA_ROOT, workshop_title.replace(" ","_"))
+ files = listdir(attachment_paths)
for f in files:
- attachment = open(path.join(settings.MEDIA_ROOT,f), 'rb')
+ attachment = open(path.join(attachment_paths, f), 'rb')
part = MIMEBase('application', 'octet-stream')
part.set_payload((attachment).read())
encoders.encode_base64(part)
diff --git a/workshop_app/templates/workshop_app/index.html b/workshop_app/templates/workshop_app/index.html
index 4b57b46..e13677c 100644
--- a/workshop_app/templates/workshop_app/index.html
+++ b/workshop_app/templates/workshop_app/index.html
@@ -76,7 +76,7 @@
<br><br>
</div>
<div class="col-md-3" style="align-items: center;">
- <a href="{{ URL_ROOT }}/pdf_view/structure" >
+ <a href="{{ URL_ROOT }}/pdf_view/flowchart" >
<img src="{{ URL_ROOT}}/static/workshop_app/img/part.png"><br><br>
How to Participate</a>
<br><br>
diff --git a/workshop_app/views.py b/workshop_app/views.py
index bec2b06..6250ad4 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -820,12 +820,13 @@ def how_to_participate(request):
return render(request, 'workshop_app/how_to_participate.html')
def pdf_view(request, workshop_title):
- if workshop_title == 'ISCP':
- pdf_file = open(path.join(settings.MEDIA_ROOT,'ISCP schedule.pdf'), 'rb')
- elif workshop_title == 'structure':
- pdf_file = open(path.join(settings.MEDIA_ROOT,'structure.pdf'), 'rb')
+ filename = WorkshopType.objects.filter(workshoptype_name=workshop_title)
+ if filename.exists():
+ attachment_path = path.join(settings.MEDIA_ROOT, workshop_title.replace(" ","_"))
+ pdf_file = open(path.join(attachment_path, \
+ '{0}.pdf'.format(workshop_title.replace(" ","_"))), 'rb')
else:
- pdf_file = open(path.join(settings.MEDIA_ROOT,'Basic Python Schedule.pdf'), 'rb')
+ pdf_file = open(path.join(settings.MEDIA_ROOT,'flowchart.pdf'), 'rb')
return HttpResponse(pdf_file, content_type="application/pdf")