From b9940ff15c335a4c7fc7f59868377ed271d021db Mon Sep 17 00:00:00 2001 From: Akshen Doke Date: Mon, 3 Apr 2017 16:44:51 +0530 Subject: Created RequestWorkshop --- .gitignore | 3 + requirements.txt | 4 +- workshop_app/forms.py | 8 +- workshop_app/models.py | 39 ++++-- workshop_app/send_mails.py | 55 ++++++++ workshop_app/static/workshop_app/img/img1.png | Bin 0 -> 19947 bytes workshop_app/static/workshop_app/img/img2.png | Bin 0 -> 14023 bytes workshop_app/templates/workshop_app/base.html | 2 +- workshop_app/templates/workshop_app/booking.html | 34 ++++- .../templates/workshop_app/create_workshop.html | 11 +- workshop_app/templates/workshop_app/index.html | 20 +++ .../templates/workshop_app/view_course_list.html | 1 + workshop_app/views.py | 142 +++++++++++---------- workshop_portal/urls.py | 1 + 14 files changed, 227 insertions(+), 93 deletions(-) create mode 100644 workshop_app/send_mails.py create mode 100644 workshop_app/static/workshop_app/img/img1.png create mode 100644 workshop_app/static/workshop_app/img/img2.png diff --git a/.gitignore b/.gitignore index 8a2b936..3909759 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,6 @@ db.sqlite3 # Django Migration files migrations/ + +#MAC OS specific +.DS_Store diff --git a/requirements.txt b/requirements.txt index 73747b4..d40ba0a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ appdirs==1.4.0 -Django==1.10.4 +Django==1.9 +django-recurrence==1.4.1 packaging==16.8 pyparsing==2.1.10 python-dateutil==2.6.0 +pytz==2016.10 six==1.10.0 diff --git a/workshop_app/forms.py b/workshop_app/forms.py index eb74a99..fa0834c 100644 --- a/workshop_app/forms.py +++ b/workshop_app/forms.py @@ -40,7 +40,9 @@ class UserRegistrationForm(forms.Form): help_text='Institute/Organization') department = forms.CharField(max_length=64, help_text='Department you work \ study at') - position = forms.ChoiceField(help_text='If you are an instructor please \ + position = forms.ChoiceField(help_text='Instructors, please wait \ + for our admin approval, if your instructor \ + account is not activated in 7 days, please\ mail us at python[at]fossee[dot]in', choices=position_choices ) @@ -132,6 +134,10 @@ class ProfileForm(forms.ModelForm): class CreateWorkshop(forms.ModelForm): """Instructors can create Workshops based on the courses available.""" + def __init__( self, *args, **kwargs ): + super(CreateWorkshop, self).__init__( *args, **kwargs ) + self.fields['recurrences'].label = " " #the trick to hide field :) + class Meta: model = Workshop fields = ['workshop_title', 'recurrences'] diff --git a/workshop_app/models.py b/workshop_app/models.py index a16c6a3..096ce5d 100644 --- a/workshop_app/models.py +++ b/workshop_app/models.py @@ -50,12 +50,13 @@ class Course(models.Model): course_name = models.CharField(max_length=120) course_description = models.TextField() - course_duration = models.CharField(max_length=12) + course_duration = models.CharField(max_length=32) def __str__(self): return u"{0} {1}".format(self.course_name, self.course_duration) + class Workshop(models.Model): """Instructor Creates workshop based on Courses available""" @@ -63,26 +64,38 @@ class Workshop(models.Model): workshop_instructor = models.ForeignKey(User, on_delete=models.CASCADE) workshop_title = models.ForeignKey( Course, on_delete=models.CASCADE,\ - help_text='Select the course you \ - would like to create a workshop for' + help_text='Select the course for which \ + you would like to create a workshop.' ) - + #For recurring workshops source: django-recurrence recurrences = RecurrenceField() - #status = models.BooleanField() Book, Pending, Booked def __str__(self): return u"{0} | {1} ".format(self.workshop_title, self.workshop_instructor) -# class completed_Workshop(models.Model): -# """ -# Contains Data of Booked/Completed Workshops -# """ +class RequestedWorkshop(models.Model): + """ + Contains Data of Booked/Completed Workshops + """ + + requested_workshop_instructor = models.ForeignKey( + User, + on_delete=models.CASCADE + ) + requested_workshop_coordinator = models.ForeignKey( + User, + related_name="%(app_label)s_%(class)s_related" + ) + status = models.CharField( + max_length=32, default="Pending", + choices=status_choices + ) + requested_workshop_title = models.ForeignKey( + Workshop, + on_delete=models.CASCADE + ) -# workshop_instructor = models.ForeignKey(User, on_delete=models.CASCADE) -# workshop_coordinator = models.ForeignKey(User) -# status = models.CharField(max_length=32, choices=status_choices) -# workshop_title = models.ForeignKey(Course, on_delete=models.CASCADE) diff --git a/workshop_app/send_mails.py b/workshop_app/send_mails.py new file mode 100644 index 0000000..4eff778 --- /dev/null +++ b/workshop_app/send_mails.py @@ -0,0 +1,55 @@ +from django.core.mail import send_mail +from workshop_portal.settings import ( + EMAIL_HOST, + EMAIL_PORT, + EMAIL_HOST_USER, + EMAIL_HOST_PASSWORD, + EMAIL_USE_TLS + ) + +def send_email(request, call_on, user_position=None): + ''' + Email sending function while registration and + booking confirmation. + ''' + + if call_on == 'Registration': + if user_position == 'instructor': + message = 'Thank You for Registering on this platform. \n \ + Since you have ask for Instructor Profile, \n \ + we will get back to you soon after verifying your \n \ + profile. \ + In case if you don\'t get any response within 3days, \ + Please contact us at ' + send_mail( + 'Welcome to FOSSEE', message, EMAIL_HOST_USER, + [request.user.email], fail_silently=False + ) + #Send a mail to admin as well as a notification. + else: + message = 'Thank You for Registering on this platform.\n \ + Rules. \n \ If you face any issue during \ + your session please contact fossee.' + send_mail( + 'Welcome to FOSSEE', message, EMAIL_HOST_USER, + [request.user.email], fail_silently=False + ) + + elif call_on == 'Booking': + if user_position == 'instructor': + message = 'You got a workshop booking request \ + from user name ' + send_mail( + 'Python Workshop Booking | FOSSEE', message, EMAIL_HOST_USER, + [request.user.email], fail_silently=False + ) + + else: + message = 'Thank You for Booking on this platform.\n \ + Rules to be added \ + If you face any issue during your session please contact \ + fossee.' + send_mail( + 'Python Workshop Booking | FOSSEE', message, EMAIL_HOST_USER, + [request.user.email], fail_silently=False + ) diff --git a/workshop_app/static/workshop_app/img/img1.png b/workshop_app/static/workshop_app/img/img1.png new file mode 100644 index 0000000..07dc07f Binary files /dev/null and b/workshop_app/static/workshop_app/img/img1.png differ diff --git a/workshop_app/static/workshop_app/img/img2.png b/workshop_app/static/workshop_app/img/img2.png new file mode 100644 index 0000000..0e47923 Binary files /dev/null and b/workshop_app/static/workshop_app/img/img2.png differ diff --git a/workshop_app/templates/workshop_app/base.html b/workshop_app/templates/workshop_app/base.html index 9971dd4..fef8840 100644 --- a/workshop_app/templates/workshop_app/base.html +++ b/workshop_app/templates/workshop_app/base.html @@ -21,7 +21,7 @@ {% block extra %} {% endblock %} -
+ {% block header %}