summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--workshop_app/admin.py9
-rw-r--r--workshop_app/forms.py31
-rw-r--r--workshop_app/models.py91
-rw-r--r--workshop_app/send_mails.py6
-rw-r--r--workshop_app/templates/workshop_app/booking.html9
-rw-r--r--workshop_app/templates/workshop_app/create_workshop.html2
-rw-r--r--workshop_app/templates/workshop_app/edit_profile.html2
-rw-r--r--workshop_app/templates/workshop_app/manage.html6
-rw-r--r--workshop_app/templates/workshop_app/my_workshops.html76
-rw-r--r--workshop_app/templates/workshop_app/propose_workshop.html53
-rw-r--r--workshop_app/templates/workshop_app/view_profile.html2
-rw-r--r--workshop_app/templates/workshop_app/view_workshoptype_details.html (renamed from workshop_app/templates/workshop_app/view_course_details.html)2
-rw-r--r--workshop_app/templates/workshop_app/view_workshoptype_list.html (renamed from workshop_app/templates/workshop_app/view_course_list.html)26
-rw-r--r--workshop_app/views.py188
-rw-r--r--workshop_portal/urls.py5
15 files changed, 390 insertions, 118 deletions
diff --git a/workshop_app/admin.py b/workshop_app/admin.py
index b980438..bc0da0a 100644
--- a/workshop_app/admin.py
+++ b/workshop_app/admin.py
@@ -1,7 +1,10 @@
from django.contrib import admin
-from .models import Profile, Course, Workshop
+from .models import (
+ Profile, WorkshopType,
+ Workshop, ProposeWorkshopDate)
# Register your models here.
admin.site.register(Profile)
-admin.site.register(Course)
-admin.site.register(Workshop) \ No newline at end of file
+admin.site.register(WorkshopType)
+admin.site.register(Workshop)
+admin.site.register(ProposeWorkshopDate)
diff --git a/workshop_app/forms.py b/workshop_app/forms.py
index 86336f0..119794f 100644
--- a/workshop_app/forms.py
+++ b/workshop_app/forms.py
@@ -1,7 +1,7 @@
from django import forms
from .models import (
- Profile, User, Workshop, Course,
- RequestedWorkshop, BookedWorkshop
+ Profile, User, Workshop, WorkshopType,
+ RequestedWorkshop, BookedWorkshop, ProposeWorkshopDate
)
from string import punctuation, digits
try:
@@ -135,7 +135,10 @@ class ProfileForm(forms.ModelForm):
self.fields['last_name'].initial = user.last_name
class CreateWorkshop(forms.ModelForm):
- """Instructors can create Workshops based on the courses available."""
+ """
+ Instructors can create Workshops based on the Types
+ of available workshops.
+ """
def __init__( self, *args, **kwargs ):
super(CreateWorkshop, self).__init__( *args, **kwargs )
@@ -146,3 +149,25 @@ class CreateWorkshop(forms.ModelForm):
fields = ['workshop_title', 'recurrences']
+class ProposeWorkshopDateForm(forms.ModelForm):
+ """
+ Coordinators will propose a workshop and date
+ """
+
+ def __init__( self, *args, **kwargs ):
+ super(ProposeWorkshopDateForm, self).__init__( *args, **kwargs )
+ self.fields['conditionone'].label = " "
+ self.fields['conditionone'].required = True
+ self.fields['conditiontwo'].label = " "
+ self.fields['conditiontwo'].required = True
+ self.fields['conditionthree'].label = " "
+ self.fields['conditionthree'].required = True
+
+ class Meta:
+ model = ProposeWorkshopDate
+ fields = ['conditionone','conditiontwo','conditionthree','proposed_workshop_title', 'proposed_workshop_date']
+ widgets = {
+ 'proposed_workshop_date': forms.DateInput(attrs={
+ 'class':'datepicker'}),
+ }
+
diff --git a/workshop_app/models.py b/workshop_app/models.py
index a7ce494..5969532 100644
--- a/workshop_app/models.py
+++ b/workshop_app/models.py
@@ -26,8 +26,8 @@ class Profile(models.Model):
validators=[RegexValidator(
regex=r'^\+?1?\d{9,15}$', message=(
"Phone number must be entered \
- in the format: '+999999999'.\
- Up to 15 digits allowed.")
+ in the format: '+999999999'.\
+ Up to 15 digits allowed.")
)])
position = models.CharField(max_length=32, choices=position_choices)
@@ -40,35 +40,40 @@ class Profile(models.Model):
)
-class Course(models.Model):
- """"Admin creates courses which can be used by the instructor
+class WorkshopType(models.Model):
+ """"Admin creates types of workshops which can be used by the instructor
to create workshops.
"""
- course_name = models.CharField(max_length=120)
- course_description = models.TextField()
- course_duration = models.CharField(max_length=32, help_text='Please write this in \
+ workshoptype_name = models.CharField(max_length=120)
+ workshoptype_description = models.TextField()
+ workshoptype_duration = models.CharField(max_length=32,
+ help_text='Please write this in \
following format eg: 3days, 8hours a day')
def __str__(self):
- return u"{0} {1}".format(self.course_name, self.course_duration)
+ return u"{0} {1}".format(self.workshoptype_name,
+ self.workshoptype_duration
+ )
class Workshop(models.Model):
"""Instructor Creates workshop based on
- Courses available"""
+ WorkshopTypes available"""
workshop_instructor = models.ForeignKey(User, on_delete=models.CASCADE)
workshop_title = models.ForeignKey(
- Course, on_delete=models.CASCADE,\
- help_text='Select the course for which \
- you would like to create a workshop.'
- )
+ WorkshopType, on_delete=models.CASCADE,
+ help_text='Select the type of workshop.'
+ )
#For recurring workshops source: django-recurrence
recurrences = RecurrenceField()
def __str__(self):
- return u"{0} | {1} ".format(self.workshop_title, self.workshop_instructor)
+ return u"{0} | {1} ".format(
+ self.workshop_title,
+ self.workshop_instructor
+ )
class RequestedWorkshop(models.Model):
@@ -77,21 +82,53 @@ class RequestedWorkshop(models.Model):
"""
requested_workshop_instructor = models.ForeignKey(
- User,
- on_delete=models.CASCADE
- )
+ User,
+ on_delete=models.CASCADE
+ )
requested_workshop_coordinator = models.ForeignKey(
- User,
- related_name="%(app_label)s_%(class)s_related"
- )
+ User,
+ related_name="%(app_label)s_%(class)s_related"
+ )
requested_workshop_date = models.DateField()
status = models.CharField(
- max_length=32, default="Pending"
- )
+ max_length=32, default="Pending"
+ )
requested_workshop_title = models.ForeignKey(
- Course,
- on_delete=models.CASCADE
- )
+ WorkshopType,
+ on_delete=models.CASCADE
+ )
+
+
+class ProposeWorkshopDate(models.Model):
+ """
+ Contains details of proposed date and workshop from coordinator
+ """
+
+ conditionone = models.BooleanField(default=False, help_text='I will give\
+ minimum 50 participants for the workshop.')
+ conditiontwo = models.BooleanField(default=False, help_text='I agree \
+ that this booking won\'t be cancelled without \
+ prior notice to the instructor and fossee.')
+ conditionthree = models.BooleanField(default=False, help_text='This \
+ proposal is subject to FOSSEE and instructor approval.')
+
+ proposed_workshop_coordinator = models.ForeignKey(
+ User,
+ on_delete=models.CASCADE
+ )
+ proposed_workshop_instructor = models.ForeignKey(User, null=True,
+ related_name="%(app_label)s_%(class)s_related")
+
+ proposed_workshop_title = models.ForeignKey(
+ WorkshopType, on_delete=models.CASCADE,
+ help_text='Select the type of workshop.'
+ )
+
+ proposed_workshop_date = models.DateField()
+
+ status = models.CharField(
+ max_length=32, default="Pending"
+ )
class BookedWorkshop(models.Model):
@@ -99,5 +136,5 @@ class BookedWorkshop(models.Model):
Contains details about Confirmed Booked/Completed Workshops
"""
- booked_workshop = models.ForeignKey(RequestedWorkshop)
- \ No newline at end of file
+ booked_workshop_requested = models.ForeignKey(RequestedWorkshop, null=True)
+ booked_workshop_proposed = models.ForeignKey(ProposeWorkshopDate, null=True)
diff --git a/workshop_app/send_mails.py b/workshop_app/send_mails.py
index add55a6..ab2e638 100644
--- a/workshop_app/send_mails.py
+++ b/workshop_app/send_mails.py
@@ -35,11 +35,11 @@ def send_smtp_email(request=None, subject=None, message=None,
if attachment:
from django.conf import settings
- from os import listdir
+ from os import listdir, path
files = listdir(settings.MEDIA_ROOT)
-
for f in files:
- attachment = open(f, 'rb')
+ print(path.join(settings.MEDIA_ROOT,f))
+ attachment = open(path.join(settings.MEDIA_ROOT,f), 'rb')
part = MIMEBase('application', 'octet-stream')
part.set_payload((attachment).read())
encoders.encode_base64(part)
diff --git a/workshop_app/templates/workshop_app/booking.html b/workshop_app/templates/workshop_app/booking.html
index 0aab78d..d69bf8f 100644
--- a/workshop_app/templates/workshop_app/booking.html
+++ b/workshop_app/templates/workshop_app/booking.html
@@ -89,7 +89,8 @@
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="{{ URL_ROOT}}/my_workshops/">My Workshops</a></li>
- <li class="active"><a href="{{ URL_ROOT }}/view_course_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/view_workshoptype_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/propose_workshop/">Propose a Workshop</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="{{ URL_ROOT }}/view_profile/"><span class="glyphicon glyphicon-user"></span> Profile </a></li>
@@ -107,8 +108,8 @@
<thead>
<tr>
<th>Instructor Name</th>
- <th>Course Name</th>
- <th>Course Day</th>
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
<th>Booking</th>
</tr>
</thead>
@@ -119,7 +120,7 @@
<tr>
<td id="instructor-name">{{ workshop.1 }}</td>
- <td id="course-name">{{ workshop.2 }}</td>
+ <td id="workshop-name">{{ workshop.2 }}</td>
<td id="workshop-date{{ forloop.counter }}">{{ workshop.0 }}</td>
<td><button class="btn btn-primary btn-sm" id="book-btn" onClick="sendData('{{workshop.0}},{{workshop.3}},{{workshop.4}}')" > Book</button></td>
</tr>
diff --git a/workshop_app/templates/workshop_app/create_workshop.html b/workshop_app/templates/workshop_app/create_workshop.html
index fd3db5f..d057be8 100644
--- a/workshop_app/templates/workshop_app/create_workshop.html
+++ b/workshop_app/templates/workshop_app/create_workshop.html
@@ -18,7 +18,7 @@
<a class="navbar-brand" href="{{ URL_ROOT}}/manage/">WebSiteName</a>
</div>
<ul class="nav navbar-nav">
- <li class="active"><a href="{{ URL_ROOT }}/view_course_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/view_workshoptype_list/">View Workshop List</a></li>
<li class="active"><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
diff --git a/workshop_app/templates/workshop_app/edit_profile.html b/workshop_app/templates/workshop_app/edit_profile.html
index 5cbd529..1cb2a52 100644
--- a/workshop_app/templates/workshop_app/edit_profile.html
+++ b/workshop_app/templates/workshop_app/edit_profile.html
@@ -13,7 +13,7 @@
{% if request.user.profile.position == 'instructor' %}
<ul class="nav navbar-nav">
<li class="active"><a href="{{ URL_ROOT }}/create_workshop/">Create Workshop</a></li>
- <li class="active"><a href="{{ URL_ROOT }}/view_course_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/view_workshoptype_list/">View Workshop List</a></li>
<li class="active"><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li>
</ul>
{% else %}
diff --git a/workshop_app/templates/workshop_app/manage.html b/workshop_app/templates/workshop_app/manage.html
index ca270b0..23c15e3 100644
--- a/workshop_app/templates/workshop_app/manage.html
+++ b/workshop_app/templates/workshop_app/manage.html
@@ -8,7 +8,7 @@
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="{{ URL_ROOT }}/create_workshop/">Create Workshop</a></li>
- <li class="active"><a href="{{ URL_ROOT }}/view_course_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/view_workshoptype_list/">View Workshop List</a></li>
<li class="active"><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
@@ -67,8 +67,8 @@
<thead>
<tr>
<th>Instructor Name</th>
- <th>Course Name</th>
- <th>Course Day</th>
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
</tr>
</thead>
{% csrf_token %}
diff --git a/workshop_app/templates/workshop_app/my_workshops.html b/workshop_app/templates/workshop_app/my_workshops.html
index 213bc1b..6c6a756 100644
--- a/workshop_app/templates/workshop_app/my_workshops.html
+++ b/workshop_app/templates/workshop_app/my_workshops.html
@@ -49,11 +49,13 @@
{% if request.user.profile.position == 'instructor' %}
<ul class="nav navbar-nav">
<li class="active"><a href="{{ URL_ROOT }}/create_workshop/">Create Workshop</a></li>
- <li class="active"><a href="{{ URL_ROOT }}/view_course_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/view_workshoptype_list/">View Workshop List</a></li>
</ul>
{% else %}
<ul class="nav navbar-nav">
<li class="active"><a href="{{ URL_ROOT }}/book/">Home</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/view_workshoptype_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/propose_workshop/">Propose a Workshop</a></li>
</ul>
{% endif %}
@@ -82,8 +84,8 @@
{% else %}
<th>Instructor Name</th>
{% endif %}
- <th>Course Name</th>
- <th>Course Day</th>
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
<th>Status</th>
</tr>
</thead>
@@ -91,7 +93,7 @@
{% for workshop in workshop_occurences %}
<tbody>
<tr>
- {% if workshop.status == 'Pending' %}
+ {% if workshop.status == 'Pending' and workshop.requested_workshop_instructor %}
{% if request.user.profile.position == 'instructor' %}
<td>{{ workshop.requested_workshop_coordinator }}</td>
{% else %}
@@ -101,7 +103,7 @@
<td>{{ workshop.requested_workshop_date }}</td>
<td><span class = "label label-warning">{{ workshop.status }}</span></td>
{% endif %}
- {% if request.user.profile.position == 'instructor' and workshop.status == 'Pending' %}
+ {% if request.user.profile.position == 'instructor' and workshop.status == 'Pending' and workshop.requested_workshop_instructor %}
<td><button class="btn btn-primary btn-sm" id="book-btn" onClick="sendData('{{workshop.requested_workshop_coordinator}},{{workshop.requested_workshop_date| safe}},{{ workshop.requested_workshop_title_id }},ACCEPTED')" data-toggle="popover" title="Please Note" data-content="Once Accepted you can't Reject, you have to personally contact the Coordinator if the workshop is to be cancelled"> Accept</button></td>
<td><button class="btn btn-danger btn-sm" id="book-btn" onClick="sendData('{{workshop.requested_workshop_coordinator}},{{workshop.requested_workshop_date| safe}},{{ workshop.requested_workshop_title_id }},REJECTED')" data-toggle="popover" title="Please Note" data-content="Once Rejected you cannot revoke this action."> Reject </button></td>
{% endif %}
@@ -123,8 +125,8 @@
{% else %}
<th>Instructor Name</th>
{% endif %}
- <th>Course Name</th>
- <th>Course Day</th>
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
<th>Status</th>
</tr>
</thead>
@@ -132,7 +134,7 @@
{% for workshop in workshop_occurences %}
<tbody>
<tr>
- {% if workshop.status == 'ACCEPTED' %}
+ {% if workshop.status == 'ACCEPTED' and workshop.requested_workshop_title %}
{% if request.user.profile.position == 'instructor' %}
<td>{{ workshop.requested_workshop_coordinator }}</td>
{% else %}
@@ -142,6 +144,16 @@
<td>{{ workshop.requested_workshop_date }}</td>
<td><span class = "label label-success">{{ workshop.status }}</span></td>
{% endif %}
+ {% if workshop.status == 'ACCEPTED' and workshop.conditionone %}
+ {% if request.user.profile.position == 'instructor' %}
+ <td>{{ workshop.proposed_workshop_coordinator }}</td>
+ {% else %}
+ <td>{{ workshop.proposed_workshop_instructor }}</td>
+ {% endif %}
+ <td>{{ workshop.proposed_workshop_title }}</td>
+ <td>{{ workshop.proposed_workshop_date }}</td>
+ <td><span class = "label label-success">{{ workshop.status }}</span></td>
+ {% endif %}
</tr>
</tbody>
@@ -150,6 +162,47 @@
</table>
</div>
+
+<!-- Proposed View -->
+<div class="container">
+ <h3 align="center"><strong><u>Proposed</u></strong></h3>
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ {% if request.user.profile.position == 'instructor' %}
+ <th>Coordinator Name</th>
+ {% else %}
+
+ {% endif %}
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
+ <th>Status</th>
+ </tr>
+ </thead>
+ {% csrf_token %}
+ {% for workshop in workshop_occurences %}
+ <tbody>
+ <tr>
+ {% if workshop.status == 'Pending' and workshop.conditionone %}
+ {% if request.user.profile.position == 'instructor' %}
+ <td>{{ workshop.proposed_workshop_coordinator }}</td>
+ {% endif %}
+ <td>{{ workshop.proposed_workshop_title }}</td>
+ <td>{{ workshop.proposed_workshop_date }}</td>
+
+ <td><span class = "label label-warning">{{ workshop.status }}</span></td>
+ {% if request.user.profile.position == 'instructor' and workshop.status == 'Pending' %}
+ <td><button class="btn btn-primary btn-sm" id="book-btn" onClick="sendData('{{workshop.proposed_workshop_coordinator}},{{workshop.proposed_workshop_date| safe}},{{ workshop.proposed_workshop_title_id }},APPROVED')" data-toggle="popover" title="Please Note" data-content="Once Accepted you can't Reject, you have to personally contact the Coordinator if the workshop is to be cancelled"> Accept</button></td>
+ {% endif %}
+ {% endif %}
+ </tr>
+ </tbody>
+
+ {% endfor %}
+ </table>
+ </div>
+
+
<!-- Deleted/Rejected View -->
<div class="container">
<h3 align="center"><strong><u>Deleted/Rejected</u></strong></h3>
@@ -161,8 +214,8 @@
{% else %}
<th>Instructor Name</th>
{% endif %}
- <th>Course Name</th>
- <th>Course Day</th>
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
<th>Status</th>
</tr>
</thead>
@@ -229,7 +282,8 @@
<div class="container">
<div class="jumbotron">
<h1>Welcome Coordinator</h1>
- <p>Information Related to your workshops will be shown here.</p>
+ <p>Information Related to your workshops will be shown here, you can also
+ propose a Workshop as per your available date in <strong>Propose a Workshop tab</strong> .</p>
</div>
</div>
{% endif %}
diff --git a/workshop_app/templates/workshop_app/propose_workshop.html b/workshop_app/templates/workshop_app/propose_workshop.html
new file mode 100644
index 0000000..07267d7
--- /dev/null
+++ b/workshop_app/templates/workshop_app/propose_workshop.html
@@ -0,0 +1,53 @@
+{% extends "workshop_app/base.html" %}
+
+{% block title %}
+ Propose a workshop
+{% endblock %}
+
+ {% block extra %}
+ <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
+
+ <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
+ <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
+
+ <script>
+ $(function() {
+ $( ".datepicker" ).datepicker({
+ changeMonth: true,
+ changeYear: true,
+ yearRange: "1994:2049",
+ // You can put more options here.
+ });
+ });
+ </script>
+ {% endblock %}
+
+{% block header %}
+ <nav class="navbar navbar-inverse">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="{{ URL_ROOT}}/book/">WebSiteName</a>
+ </div>
+ <ul class="nav navbar-nav">
+ <li class="active"><a href="{{ URL_ROOT }}/view_workshoptype_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li>
+ </ul>
+ <ul class="nav navbar-nav navbar-right">
+ <li><a href="{{ URL_ROOT }}/view_profile/"><span class="glyphicon glyphicon-user"></span> Profile </a></li>
+ <li><a href="{{ URL_ROOT }}/logout/"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
+ </ul>
+ </div>
+ </nav>
+{% endblock %}
+
+{% block content %}
+ <div class="container">
+ <form method="post">
+ {% csrf_token %}
+ <br/>
+ {{ form.as_p }}
+ <br><br>
+ <button class="btn btn-success" type="submit">Submit</button>
+ </form>
+ </div>
+{% endblock %} \ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html
index 13e9216..7227d87 100644
--- a/workshop_app/templates/workshop_app/view_profile.html
+++ b/workshop_app/templates/workshop_app/view_profile.html
@@ -13,7 +13,7 @@
<ul class="nav navbar-nav">
<li class="active"><a href="{{ URL_ROOT }}/manage/">Home</a></li>
<li class="active"><a href="{{ URL_ROOT }}/create_workshop/">Create Workshop</a></li>
- <li class="active"><a href="{{ URL_ROOT }}/view_course_list/">View Workshop List</a></li>
+ <li class="active"><a href="{{ URL_ROOT }}/view_workshoptype_list/">View Workshop List</a></li>
<li class="active"><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li>
</ul>
{% else %}
diff --git a/workshop_app/templates/workshop_app/view_course_details.html b/workshop_app/templates/workshop_app/view_workshoptype_details.html
index a0e46c7..f033804 100644
--- a/workshop_app/templates/workshop_app/view_course_details.html
+++ b/workshop_app/templates/workshop_app/view_workshoptype_details.html
@@ -1,7 +1,7 @@
{% extends 'workshop_app/base.html' %}
{% block title %}
- View Course Details
+ View Details About Workshops
{% endblock %}
{% block header %}
diff --git a/workshop_app/templates/workshop_app/view_course_list.html b/workshop_app/templates/workshop_app/view_workshoptype_list.html
index 7e38d10..eb907c0 100644
--- a/workshop_app/templates/workshop_app/view_course_list.html
+++ b/workshop_app/templates/workshop_app/view_workshoptype_list.html
@@ -1,7 +1,7 @@
{% extends 'workshop_app/base.html' %}
{% block title %}
- View Course List
+ View Workshops Type List
{% endblock %}
@@ -42,18 +42,18 @@
<thead>
<tr>
<th>id</th>
- <th>Course Name</th>
- <th>Course Duration</th>
+ <th>Workshop Name</th>
+ <th>Workshop Duration</th>
</tr>
</thead>
- {% for course in courses %}
+ {% for w in workshoptype %}
<tbody>
<tr >
<td scope="row" id="{{ forloop.counter }}">{{ forloop.counter }}</td>
- <td>{{ course.course_name }}</td>
- <td>{{ course.course_duration }}</td>
- <td><button class="btn btn-default btn-sm" class="accordion-toggle" data-toggle="collapse" href="#collapseOne{{ forloop.counter }}">View Course Details</button></td>
+ <td>{{ w.workshoptype_name }}</td>
+ <td>{{ w.workshoptype_duration }}</td>
+ <td><button class="btn btn-default btn-sm" class="accordion-toggle" data-toggle="collapse" href="#collapseOne{{ forloop.counter }}">View Workshop Details</button></td>
</tr>
<tr>
@@ -62,7 +62,7 @@
<table class="table table-striped">
<tbody>
<tr>
- <td>{{ course.course_description|safe }}</td>
+ <td>{{ w.workshoptype_description|safe }}</td>
</tr>
</tbody>
</table>
@@ -82,19 +82,19 @@
<nav aria-label="Page navigation">
<ul class="pagination pagination-sm">
<li class="page-item">
- {% if courses.has_previous %}
+ {% if workshoptype.has_previous %}
<a class="page-link" tabindex="-1"
- href="?page={{ courses.previous_page_number }}">Previous</a>
+ href="?page={{ workshoptype.previous_page_number }}">Previous</a>
{% endif %}
</li>
<li class="page-item">
<span class="current">
- Page {{ courses.number }} of {{ courses.paginator.num_pages }}
+ Page {{ workshoptype.number }} of {{ workshoptype.paginator.num_pages }}
</span>
</li>
<li class="page-item">
- {% if courses.has_next %}
- <a class="page-link" href="?page={{ courses.next_page_number }}">Next
+ {% if workshoptype.has_next %}
+ <a class="page-link" href="?page={{ workshoptype.next_page_number }}">Next
</a>
{% endif %}
</li>
diff --git a/workshop_app/views.py b/workshop_app/views.py
index f5d1b60..f77ca86 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -1,12 +1,13 @@
from .forms import (
UserRegistrationForm, UserLoginForm,
- ProfileForm, CreateWorkshop
+ ProfileForm, CreateWorkshop,
+ ProposeWorkshopDateForm
)
from .models import (
Profile, User,
has_profile, Workshop,
- Course, RequestedWorkshop,
- BookedWorkshop
+ WorkshopType, RequestedWorkshop,
+ BookedWorkshop, ProposeWorkshopDate
)
from django.template import RequestContext
from datetime import datetime, date
@@ -122,11 +123,11 @@ def book(request):
for d in range(len(dates)):
workshop_occurence = [
- dates[d].strftime("%d-%m-%Y"),
- workshops.workshop_instructor,
- workshops.workshop_title,
- workshops.workshop_instructor_id,
- workshops.workshop_title_id,
+ dates[d].strftime("%d-%m-%Y"),
+ workshops.workshop_instructor,
+ workshops.workshop_title,
+ workshops.workshop_instructor_id,
+ workshops.workshop_title_id,
]
workshop_occurence_list.append(workshop_occurence)
@@ -134,17 +135,23 @@ def book(request):
#Gives you the objects of BookedWorkshop
bookedworkshop = BookedWorkshop.objects.all()
- for b in bookedworkshop:
- '''
- b.booked_workshop.requested_workshop_date returns object from
- requestedworkshop table
- '''
- x = b.booked_workshop.requested_workshop_date.strftime("%d-%m-%Y")
- y = b.booked_workshop.requested_workshop_title
- for a in workshop_occurence_list:
- if a[0] == x and a[2] == y:
- workshop_occurence_list.remove(a)
- del x, y
+ if len(bookedworkshop) != 0:
+ for b in bookedworkshop:
+ '''
+ handles objects from bookedworkshop
+ -requested
+ -proposed
+ '''
+ try:
+ x = b.booked_workshop_requested.requested_workshop_date.strftime("%d-%m-%Y")
+ y = b.booked_workshop_requested.requested_workshop_title
+ except:
+ x = b.booked_workshop_proposed.proposed_workshop_date.strftime("%d-%m-%Y")
+ y = b.booked_workshop_proposed.proposed_workshop_title
+ for a in workshop_occurence_list:
+ if a[0] == x and a[2] == y:
+ workshop_occurence_list.remove(a)
+ del x, y
#Objects of RequestedWorkshop for that particular coordinator
rW_obj = RequestedWorkshop.objects.filter(
@@ -251,7 +258,7 @@ def book_workshop(request):
send_email(request, call_on='Booking',
user_position='instructor',
workshop_date=workshop_date,
- workshop_title=workshop.workshop_title.course_name,
+ workshop_title=workshop.workshop_title.workshoptype_name,
user_name=str(request.user),
other_email=workshop.workshop_instructor.email
)
@@ -259,7 +266,7 @@ def book_workshop(request):
#Mail to coordinator
send_email(request, call_on='Booking',
workshop_date=workshop_date,
- workshop_title=workshop.workshop_title.course_name,
+ workshop_title=workshop.workshop_title.workshoptype_name,
user_name=workshop.workshop_instructor.username,
other_email=workshop.workshop_instructor.email,
phone_number=phone_number)
@@ -366,7 +373,7 @@ def my_workshops(request):
workshop_status.status = client_data[-1]
workshop_status.save()
booked_workshop_obj = BookedWorkshop()
- booked_workshop_obj.booked_workshop = workshop_status
+ booked_workshop_obj.booked_workshop_requested = workshop_status
booked_workshop_obj.save()
cmail = workshop_status.requested_workshop_coordinator.email
@@ -374,7 +381,7 @@ def my_workshops(request):
cnum = workshop_status.requested_workshop_coordinator.profile.phone_number
cinstitute = workshop_status.requested_workshop_coordinator.profile.institute
inum = request.user.profile.phone_number
- wtitle = workshop_status.requested_workshop_title.course_name
+ wtitle = workshop_status.requested_workshop_title.workshoptype_name
#For Instructor
send_email(request, call_on='Booking Confirmed',
@@ -418,7 +425,7 @@ def my_workshops(request):
rW_obj.status = client_data[-1]
rW_obj.save()
bW_obj = BookedWorkshop()
- bW_obj.booked_workshop = rW_obj
+ bW_obj.booked_workshop_requested = rW_obj
bW_obj.save()
#For instructor
@@ -428,12 +435,57 @@ def my_workshops(request):
)
return HttpResponse("Workshop Deleted")
-
+
+ elif client_data[-1] == 'APPROVED':
+ print(client_data)
+ workshop_date = datetime.strptime(
+ client_data[1], "%Y-%m-%d"
+ )
+
+ coordinator_obj = User.objects.get(username=client_data[0][2:])
+ workshop_status = ProposeWorkshopDate.objects.get(
+ proposed_workshop_date=workshop_date,
+ proposed_workshop_coordinator=coordinator_obj.id,
+ proposed_workshop_title=client_data[2]
+ )
+
+ workshop_status.status = 'ACCEPTED'
+ workshop_status.proposed_workshop_instructor = user
+ workshop_status.save()
+ booked_workshop_obj = BookedWorkshop()
+ booked_workshop_obj.booked_workshop_proposed = workshop_status
+ booked_workshop_obj.save()
+
+ cmail = workshop_status.proposed_workshop_coordinator.email
+ cname = workshop_status.proposed_workshop_coordinator.username
+ cnum = workshop_status.proposed_workshop_coordinator.profile.phone_number
+ cinstitute = workshop_status.proposed_workshop_coordinator.profile.institute
+ inum = request.user.profile.phone_number
+ wtitle = workshop_status.proposed_workshop_title.workshoptype_name
+
+ #For Instructor
+ send_email(request, call_on='Booking Confirmed',
+ user_position='instructor',
+ workshop_date=str(client_data[1]),
+ workshop_title=wtitle,
+ user_name=str(cname),
+ other_email=cmail,
+ phone_number=cnum,
+ institute=cinstitute
+ )
+
+ #For Coordinator
+ send_email(request, call_on='Booking Confirmed',
+ workshop_date=str(client_data[1]),
+ workshop_title=wtitle,
+ other_email=cmail,
+ phone_number=inum
+ )
+
else:
workshop_date = datetime.strptime(
client_data[1], "%Y-%m-%d"
)
- print(client_data)
coordinator_obj = User.objects.get(username=client_data[0][2:])
workshop_status = RequestedWorkshop.objects.get(
requested_workshop_instructor=user.id,
@@ -444,7 +496,7 @@ def my_workshops(request):
workshop_status.status = client_data[-1]
workshop_status.save()
- wtitle = workshop_status.requested_workshop_title.course_name
+ wtitle = workshop_status.requested_workshop_title.workshoptype_name
cmail = workshop_status.requested_workshop_coordinator.email
cname = workshop_status.requested_workshop_coordinator.username
cnum = workshop_status.requested_workshop_coordinator.profile.phone_number
@@ -468,12 +520,27 @@ def my_workshops(request):
other_email=cmail
)
+ workshops = []
workshop_occurence_list = RequestedWorkshop.objects.filter(
requested_workshop_instructor=user.id
)
-
+ for w in workshop_occurence_list:
+ workshops.append(w)
+
+ proposed_workshop = ProposeWorkshopDate.objects.filter(
+ proposed_workshop_instructor=user.id
+ )
+ for p in proposed_workshop:
+ workshops.append(p)
+
+ proposed_workshop_pending = ProposeWorkshopDate.objects.filter(
+ status='Pending'
+ )
+ for p in proposed_workshop_pending:
+ workshops.append(p)
+
#Show upto 12 Workshops per page
- paginator = Paginator(workshop_occurence_list, 12)
+ paginator = Paginator(workshops, 12)
page = request.GET.get('page')
try:
workshop_occurences = paginator.page(page)
@@ -488,13 +555,21 @@ def my_workshops(request):
else:
+ workshops = []
workshop_occurence_list = RequestedWorkshop.objects.filter(
- requested_workshop_coordinator=user.id
- )
-
+ requested_workshop_coordinator=user.id
+ )
+ for w in workshop_occurence_list:
+ workshops.append(w)
+
+ proposed_workshop = ProposeWorkshopDate.objects.filter(
+ proposed_workshop_coordinator=user.id
+ )
+ for p in proposed_workshop:
+ workshops.append(p)
+
#Show upto 12 Workshops per page
- paginator = Paginator(workshop_occurence_list, 12)
- print(paginator)
+ paginator = Paginator(workshops, 12)
page = request.GET.get('page')
try:
workshop_occurences = paginator.page(page)
@@ -514,6 +589,29 @@ def my_workshops(request):
@login_required
+def propose_workshop(request):
+ '''Coordinator proposed a workshop and date'''
+
+ user = request.user
+ if is_instructor(user):
+ return redirect('/manage/')
+ else:
+ if request.method == 'POST':
+ form = ProposeWorkshopDateForm(request.POST)
+ if form.is_valid():
+ form_data = form.save(commit=False)
+ form_data.proposed_workshop_coordinator = user
+ form_data.proposed_workshop_coordinator.save()
+ form_data.save()
+ return redirect('/my_workshops/')
+ else:
+ form = ProposeWorkshopDateForm()
+ return render(
+ request, 'workshop_app/propose_workshop.html',
+ {"form": form }
+ )
+
+@login_required
def view_profile(request):
""" view instructor and coordinator profile """
return render(request, "workshop_app/view_profile.html")
@@ -583,31 +681,31 @@ def create_workshop(request):
@login_required
-def view_course_list(request):
- '''Gives the course details '''
+def view_workshoptype_list(request):
+ '''Gives the types of workshop details '''
user = request.user
- course_list = Course.objects.all()
- paginator = Paginator(course_list, 12) #Show upto 12 Courses per page
+ workshoptype_list = WorkshopType.objects.all()
+ paginator = Paginator(workshoptype_list, 12) #Show upto 12 workshops per page
page = request.GET.get('page')
try:
- courses = paginator.page(page)
+ workshoptype = paginator.page(page)
except PageNotAnInteger:
#If page is not an integer, deliver first page.
- courses = paginator.page(1)
+ workshoptype = paginator.page(1)
except EmptyPage:
#If page is out of range(e.g 999999), deliver last page.
- courses = paginator.page(paginator.num_pages)
+ workshoptype = paginator.page(paginator.num_pages)
return render(
- request, 'workshop_app/view_course_list.html', \
- {'courses': courses}
+ request, 'workshop_app/view_workshoptype_list.html', \
+ {'workshoptype': workshoptype}
)
@login_required
-def view_course_details(request):
- '''Gives the course details '''
+def view_workshoptype_details(request):
+ '''Gives the details for types of workshops.'''
user = request.user
if is_instructor(user):
diff --git a/workshop_portal/urls.py b/workshop_portal/urls.py
index 90f4ca5..137385f 100644
--- a/workshop_portal/urls.py
+++ b/workshop_portal/urls.py
@@ -35,9 +35,10 @@ urlpatterns = [
url(r'^book_workshop/$', views.book_workshop),
url(r'^my_workshops/$', views.my_workshops),
url(r'^manage/$', views.manage),
- url(r'^view_course_list/$', views.view_course_list),
- url(r'^view_course_details/$', views.view_course_details),
+ url(r'^view_workshoptype_list/$', views.view_workshoptype_list),
+ url(r'^view_workshoptype_details/$', views.view_workshoptype_details),
url(r'^create_workshop/$', views.create_workshop),
+ url(r'^propose_workshop/$', views.propose_workshop),
url(r'^jsi18n/$', django.views.i18n.javascript_catalog, js_info_dict),
]