summaryrefslogtreecommitdiff
path: root/workshop_app
diff options
context:
space:
mode:
Diffstat (limited to 'workshop_app')
-rw-r--r--workshop_app/forms.py4
-rw-r--r--workshop_app/send_mails.py6
-rw-r--r--workshop_app/templates/workshop_app/booking.html17
-rw-r--r--workshop_app/templates/workshop_app/index.html15
-rw-r--r--workshop_app/templates/workshop_app/login.html15
-rw-r--r--workshop_app/templates/workshop_app/logout.html15
-rw-r--r--workshop_app/templates/workshop_app/manage.html12
-rw-r--r--workshop_app/templates/workshop_app/my_workshops.html8
-rw-r--r--workshop_app/templates/workshop_app/register.html15
-rw-r--r--workshop_app/templates/workshop_app/view_course_list.html2
-rw-r--r--workshop_app/templates/workshop_app/view_profile.html2
-rw-r--r--workshop_app/views.py296
12 files changed, 255 insertions, 152 deletions
diff --git a/workshop_app/forms.py b/workshop_app/forms.py
index 0b3a7e6..158e9fa 100644
--- a/workshop_app/forms.py
+++ b/workshop_app/forms.py
@@ -41,8 +41,8 @@ class UserRegistrationForm(forms.Form):
Up to 15 digits allowed."))
institute = forms.CharField(max_length=128,
help_text='Institute/Organization')
- department = forms.CharField(max_length=64, help_text='Department you work \
- study at')
+ department = forms.CharField(max_length=64, help_text='Department you work/\
+ study')
position = forms.ChoiceField(help_text='Instructors, please wait \
for our admin approval, if your instructor \
account is not activated in 7 days, please\
diff --git a/workshop_app/send_mails.py b/workshop_app/send_mails.py
index 3b71b38..a4bbc0b 100644
--- a/workshop_app/send_mails.py
+++ b/workshop_app/send_mails.py
@@ -73,13 +73,13 @@ def send_email(request, call_on,
send_mail("Python Workshop Booking Rejected", message, EMAIL_HOST_USER,
[request.user.email], fail_silently=False)
else:
- message = "Your workshop request for "+workshop_date+" has been cancelled please \
- try for some other day."
+ message = "Your workshop request for "+workshop_date+" has been rejected by the instructor,\
+ please try for some other day."
send_mail("Python Workshop Booking Request Rejected", message, EMAIL_HOST_USER,
[other_email], fail_silently=False)
elif call_on =='Workshop Deleted':
- message = "You have deleted a Workshop, "+workshop_title+" scheduled on "+workshop_date+"."
+ message = "You have deleted a Workshop, scheduled on "+workshop_date+"."
send_mail("Python Workshop Deleted", message, EMAIL_HOST_USER,
[request.user.email], fail_silently=False)
diff --git a/workshop_app/templates/workshop_app/booking.html b/workshop_app/templates/workshop_app/booking.html
index 051dfeb..9321e33 100644
--- a/workshop_app/templates/workshop_app/booking.html
+++ b/workshop_app/templates/workshop_app/booking.html
@@ -13,11 +13,13 @@
<script>
// Button function
function sendData(d){
+ console.log(d);
+
var $dialog = $('<div></div').html(
'<form id="myform" action="">\
<input type="checkbox" id="one"\
- name="one" value="one"/>We will give minimum 50 participants for the workshop.<br/>\
- <input type="checkbox" id="two" name="two" value="two" />We agree that this booking won\'t be cancelled(if you want to cancel please contact the instructor 2days before the event).<br/>\
+ name="one" value="one"/> I will give minimum 50 participants for the workshop.<br/>\
+ <input type="checkbox" id="two" name="two" value="two" /> I agree that this booking won\'t be cancelled(if you want to cancel please contact the instructor 2days before the event).<br/>\
</form> ')
.dialog({
autoOpen: false,
@@ -40,7 +42,7 @@
$dialog.dialog('open');
}
-function booking_confirmed(d){
+ function booking_confirmed(d){
var URL = "{{ URL_ROOT }}/book_workshop/";
$.ajax({
@@ -69,6 +71,7 @@ function booking_confirmed(d){
</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 Course List</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>
@@ -79,6 +82,8 @@ function booking_confirmed(d){
{% endblock %}
{% block content %}
+ <h4 align="center">This is the list of events available, if you haved booked a workshop please goto My Workshops and check your workshop status.</h4>
+ <br>
<div class="container">
<table class="table table-hover">
<thead>
@@ -95,10 +100,10 @@ function booking_confirmed(d){
<tbody>
<tr>
- <td id="instructor-name">{{ workshop.1.0 }}</td>
- <td id="course-name">{{ workshop.1.1 }}</td>
+ <td id="instructor-name">{{ workshop.1 }}</td>
+ <td id="course-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.1.2}},{{workshop.1.3}}')" > Book</button></td>
+ <td><button class="btn btn-primary btn-sm" id="book-btn" onClick="sendData('{{workshop.0}},{{workshop.3}},{{workshop.4}}')" > Book</button></td>
</tr>
</tbody>
diff --git a/workshop_app/templates/workshop_app/index.html b/workshop_app/templates/workshop_app/index.html
index a7664ed..10ba623 100644
--- a/workshop_app/templates/workshop_app/index.html
+++ b/workshop_app/templates/workshop_app/index.html
@@ -7,6 +7,21 @@
Welcome
{% endblock %}
</head>
+
+ {% block header %}
+ <nav class="navbar navbar-inverse">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="{{ URL_ROOT }}/">Booking</a>
+ </div>
+
+ <ul class="nav navbar-nav navbar-right">
+ <li><a href="{{ URL_ROOT }}/register"><span class="glyphicon glyphicon-user"></span> Register</a></li>
+ <li><a href="{{ URL_ROOT }}/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
+ </ul>
+ </div>
+ </nav>
+ {% endblock %}
{% block content %}
<div class="container">
diff --git a/workshop_app/templates/workshop_app/login.html b/workshop_app/templates/workshop_app/login.html
index cc733c7..6c4b82b 100644
--- a/workshop_app/templates/workshop_app/login.html
+++ b/workshop_app/templates/workshop_app/login.html
@@ -4,6 +4,21 @@
Login
{% endblock %}
+{% block header %}
+ <nav class="navbar navbar-inverse">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="{{ URL_ROOT }}/">Booking</a>
+ </div>
+
+ <ul class="nav navbar-nav navbar-right">
+ <li><a href="{{ URL_ROOT }}/register"><span class="glyphicon glyphicon-user"></span> Register</a></li>
+ <li><a href="{{ URL_ROOT }}/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
+ </ul>
+ </div>
+ </nav>
+ {% endblock %}
+
{% block content %}
<div class="container" align="center">
<br>
diff --git a/workshop_app/templates/workshop_app/logout.html b/workshop_app/templates/workshop_app/logout.html
index 793bf5a..492f914 100644
--- a/workshop_app/templates/workshop_app/logout.html
+++ b/workshop_app/templates/workshop_app/logout.html
@@ -4,6 +4,21 @@
Logged out
{% endblock %}
+{% block header %}
+ <nav class="navbar navbar-inverse">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="{{ URL_ROOT }}/">Booking</a>
+ </div>
+
+ <ul class="nav navbar-nav navbar-right">
+ <li><a href="{{ URL_ROOT }}/register"><span class="glyphicon glyphicon-user"></span> Register</a></li>
+ <li><a href="{{ URL_ROOT }}/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
+ </ul>
+ </div>
+ </nav>
+ {% endblock %}
+
{% block content %}
<div class="container" align="center">
diff --git a/workshop_app/templates/workshop_app/manage.html b/workshop_app/templates/workshop_app/manage.html
index 070bd00..235f985 100644
--- a/workshop_app/templates/workshop_app/manage.html
+++ b/workshop_app/templates/workshop_app/manage.html
@@ -4,7 +4,7 @@
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
- <a class="navbar-brand" href="#">WebSiteName</a>
+ <a class="navbar-brand" href="#">Instructor Profile</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="{{ URL_ROOT }}/create_workshop">Create Event</a></li>
@@ -42,12 +42,16 @@
alert("Refreshing Page please wait, if you don't see your changes, please refresh this page again.");
}
</script>
+
+
{% endblock %}
{% block content %}
{% if workshop_occurence_list %}
+ <h4 align="center">This is the list of workshops you have created, you can delete a workshop if you are not availble on that day. </h4>
+ <br>
<div class="container">
<table class="table table-hover">
<thead>
@@ -58,17 +62,15 @@
</tr>
</thead>
{% csrf_token %}
- {% for workshop in workshop_occurence_list %}
- {% for w in workshop %}
+ {% for w in workshop_occurence_list %}
<tbody>
<tr>
<td>{{ w.user }}</td>
<td>{{ w.workshop }}</td>
<td>{{ w.date | date}}</td>
- <td><button class="btn btn-danger btn-sm" id="delete-btn" onClick="sendData('{{ w.user}},{{w.date | safe}},{{ w.workshop.id }},DELETED')" > Delete Event </button></td>
+ <td><button data-toggle="tooltip" data-placement="top" title="Tooltip on top" class="btn btn-danger btn-sm" id="delete-btn" onClick="sendData('{{ w.user}},{{w.date | safe}},{{ w.workshop.id }},DELETED')" > Delete Event </button></td>
</tr>
</tbody>
- {% endfor %}
{% endfor %}
</table>
</div>
diff --git a/workshop_app/templates/workshop_app/my_workshops.html b/workshop_app/templates/workshop_app/my_workshops.html
index c5189a7..ced8758 100644
--- a/workshop_app/templates/workshop_app/my_workshops.html
+++ b/workshop_app/templates/workshop_app/my_workshops.html
@@ -59,6 +59,8 @@
{% block content %}
{% if workshop_occurences %}
+ <h3 align="center">The status of your workshops </h3>
+ <br>
<div class="container">
<table class="table table-hover">
<thead>
@@ -91,9 +93,9 @@
{% else %}
<td><span class = "label label-danger">{{ workshop.status }}</span></td>
{% endif %}
- {% if request.user.profile.position == '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 }},ACCEPTED')" > 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 }},REJECTED')" > Reject </button></td>
+ {% if request.user.profile.position == 'instructor' and workshop.status != 'DELETED' %}
+ <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')" > 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')" > Reject </button></td>
{% endif %}
</tr>
</tbody>
diff --git a/workshop_app/templates/workshop_app/register.html b/workshop_app/templates/workshop_app/register.html
index 3009048..db69118 100644
--- a/workshop_app/templates/workshop_app/register.html
+++ b/workshop_app/templates/workshop_app/register.html
@@ -4,6 +4,21 @@
Register
{% endblock %}
+ {% block header %}
+ <nav class="navbar navbar-inverse">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="{{ URL_ROOT }}/">Booking</a>
+ </div>
+
+ <ul class="nav navbar-nav navbar-right">
+ <li><a href="{{ URL_ROOT }}/register"><span class="glyphicon glyphicon-user"></span> Register</a></li>
+ <li><a href="{{ URL_ROOT }}/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
+ </ul>
+ </div>
+ </nav>
+ {% endblock %}
+
{% block content %}
<div class="container" >
<br>
diff --git a/workshop_app/templates/workshop_app/view_course_list.html b/workshop_app/templates/workshop_app/view_course_list.html
index d1fb343..bd2bcea 100644
--- a/workshop_app/templates/workshop_app/view_course_list.html
+++ b/workshop_app/templates/workshop_app/view_course_list.html
@@ -12,7 +12,9 @@
<a class="navbar-brand" href="{{ URL_ROOT}}/manage/">WebSiteName</a>
</div>
<ul class="nav navbar-nav">
+ {% if request.user.profile.position == 'instructor'%}
<li class="active"><a href="{{ URL_ROOT }}/create_workshop">Create Workshop</a></li>
+ {% endif %}
<li class="active"><a href="{{ URL_ROOT }}/my_workshops">My Workshops</a></li>
</ul>
diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html
index c223a66..f3f0652 100644
--- a/workshop_app/templates/workshop_app/view_profile.html
+++ b/workshop_app/templates/workshop_app/view_profile.html
@@ -8,10 +8,10 @@
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
- <a class="navbar-brand" href="#">WebSiteName</a>
</div>
{% if request.user.profile.position == 'instructor' %}
<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 Event</a></li>
<li class="active"><a href="{{ URL_ROOT }}/view_course_list">View Course List</a></li>
<li class="active"><a href="{{ URL_ROOT }}/my_workshops">My Workshops</a></li>
diff --git a/workshop_app/views.py b/workshop_app/views.py
index f6f6b11..f028ed5 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -19,7 +19,7 @@ from django.db import IntegrityError
from collections import OrderedDict
from dateutil.parser import parse
from .send_mails import send_email
-from django.http import HttpResponse
+from django.http import HttpResponse, HttpResponseRedirect
def index(request):
@@ -100,6 +100,7 @@ def user_register(request):
return render(request, "workshop_app/register.html", {"form": form})
+#This is shown to coordinator for booking workshops
def book(request):
user = request.user
if user.is_authenticated():
@@ -107,40 +108,45 @@ def book(request):
return redirect('/manage/')
workshop_details = Workshop.objects.all()
- workshop_occurence = {}
+
+ workshop_occurence_list = []
+
for workshops in workshop_details:
dates = workshops.recurrences.between(
datetime(2017, 3, 12, 0, 0, 0),
- datetime(2017, 12, 31, 0, 0, 0), #Needs to be changed yearly
+ datetime(2040, 12, 31, 0, 0, 0), #Needs to be changed yearly
inc=True
)
for d in range(len(dates)):
- workshop_occurence[dates[d].strftime("%d-%m-%Y")] = [
+ workshop_occurence = [
+ dates[d].strftime("%d-%m-%Y"),
workshops.workshop_instructor,
workshops.workshop_title,
workshops.workshop_instructor_id,
- workshops.workshop_title_id
- ]
+ workshops.workshop_title_id,
+ ]
- # workshop_occurence = OrderedDict(sorted(workshop_occurence.items()))
- workshop_occurence = list(workshop_occurence.items())
+ workshop_occurence_list.append(workshop_occurence)
+ del workshop_occurence
+
#Gives you the objects of BookedWorkshop
- requested_workshop = BookedWorkshop.objects.all()
- for j in requested_workshop:
+ bookedworkshop = BookedWorkshop.objects.all()
+ for j in bookedworkshop:
'''
j.booked_workshop.requested_workshop_date returns object from
requestedworkshop table
'''
- j = j.booked_workshop.requested_workshop_date.strftime("%d-%m-%Y")
- for i in workshop_occurence:
- if i[0] == j:
- workshop_occurence.remove(i)
-
-
- #Show upto 6 Workshops per page
- paginator = Paginator(workshop_occurence, 6)
+ a = j.booked_workshop.requested_workshop_date.strftime("%d-%m-%Y")
+ b = j.booked_workshop.requested_workshop_title
+ for i in workshop_occurence_list:
+ if i[0] == a and i[2] == b:
+ workshop_occurence_list.remove(i)
+ del a, b
+
+ #Show upto 12 Workshops per page
+ paginator = Paginator(workshop_occurence_list, 12)
page = request.GET.get('page')
try:
workshop_occurences = paginator.page(page)
@@ -163,64 +169,68 @@ def book(request):
@login_required
def book_workshop(request):
'''
- Function for Updating requested_workshop table
+ Function for Updating RequestedWorkshop Model
'''
if request.method == 'POST':
user_position = request.user.profile.position
client_data = request.body.decode("utf-8").split("&")
client_data = client_data[0].split("%2C")
workshop_date = client_data[0][2:]
-
instructor_profile = Profile.objects.filter(user=client_data[1])
- workshop = Workshop.objects.get(
- workshop_instructor=client_data[1]
+
+
+ workshops_list = Workshop.objects.filter(
+ workshop_instructor=client_data[1],
+ workshop_title_id=client_data[2]
)
- workshop_recurrence_list = workshop.recurrences.between(
- datetime(2017, 3, 12, 0, 0, 0),
- datetime(2017, 12, 31, 0, 0, 0),
- inc=True
- )
- rW_obj = RequestedWorkshop()
-
- workshop_obj = Workshop.objects.get(
- workshop_instructor=client_data[1],
- workshop_title_id=client_data[2]
- )
-
- for d in workshop_recurrence_list:
- if workshop_date == (d.strftime("%d-%m-%Y")):
- # rW_obj = RequestedWorkshop()
-
- # workshop_obj = Workshop.objects.get(
- # workshop_instructor=client_data[1],
- # workshop_title_id=client_data[2]
- # )
- rW_obj.requested_workshop_instructor = workshop_obj.workshop_instructor
- rW_obj.requested_workshop_coordinator = request.user
- rW_obj.requested_workshop_date = datetime.strptime(
- client_data[0][2:], "%d-%m-%Y"
- )
- rW_obj.requested_workshop_title = workshop_obj.workshop_title
- rW_obj.save()
-
- # Mail to instructor
- send_email(request, call_on='Booking',
- user_position='instructor',
- workshop_date=workshop_date,
- workshop_title=workshop_obj.workshop_title.course_name,
- user_name=str(request.user),
- other_email=workshop_obj.workshop_instructor.email
- )
-
- #Mail to coordinator
- send_email(request, call_on='Booking',
- workshop_date=workshop_date,
- workshop_title=workshop_obj.workshop_title.course_name,
- user_name=workshop_obj.workshop_instructor.username)
-
- return HttpResponse("Thank You, Please check your email for further \
- information.")
+ for workshop in workshops_list:
+ workshop_recurrence_list = workshop.recurrences.between(
+ datetime(2017, 3, 12, 0, 0, 0),
+ datetime(2040, 12, 31, 0, 0, 0),
+ inc=True
+ )
+
+ rW_obj = RequestedWorkshop()
+ if RequestedWorkshop.objects.filter(
+ requested_workshop_instructor=workshop.workshop_instructor,
+ requested_workshop_date=datetime.strptime(
+ client_data[0][2:], "%d-%m-%Y",
+ ),
+ requested_workshop_coordinator=request.user,
+ requested_workshop_title=client_data[-1]
+ ).count() > 0:
+
+ return HttpResponse("You already have a booking for this workshop \
+ please check the instructors response in My Workshops tab and \
+ also check your email.")
+ else:
+ for d in workshop_recurrence_list:
+ if workshop_date == (d.strftime("%d-%m-%Y")):
+ rW_obj.requested_workshop_instructor = workshop.workshop_instructor
+ rW_obj.requested_workshop_coordinator = request.user
+ rW_obj.requested_workshop_date = datetime.strptime(
+ client_data[0][2:], "%d-%m-%Y"
+ )
+ rW_obj.requested_workshop_title = workshop.workshop_title
+ rW_obj.save()
+
+ # Mail to instructor
+ send_email(request, call_on='Booking',
+ user_position='instructor',
+ workshop_date=workshop_date,
+ workshop_title=workshop.workshop_title.course_name,
+ user_name=str(request.user),
+ other_email=workshop.workshop_instructor.email
+ )
+
+ #Mail to coordinator
+ send_email(request, call_on='Booking',
+ workshop_date=workshop_date,
+ workshop_title=workshop.workshop_title.course_name,
+ user_name=workshop.workshop_instructor.username)
+
+ return HttpResponse("Thank You, Please check your email for further information.")
else:
return HttpResponse("Some Error Occurred.")
@@ -232,37 +242,43 @@ def manage(request):
#Move user to the group via admin
if user.groups.filter(name='instructor').count() > 0:
try:
- #Can't Handle Multiple objects Fix this asap
- workshop_details = Workshop.objects.get(
+ #Can Handle Multiple Workshops
+ workshop_details = Workshop.objects.filter(
workshop_instructor=user.id
)
- workshop_occurence_list = workshop_details.recurrences.between(
- datetime(2017, 3, 12, 0, 0, 0),
- datetime(2017, 12, 31, 0, 0, 0),
- inc=True
- )
-
- for i in range(len(workshop_occurence_list)):
- workshop_occurence_list[i] = [{
- "user": str(user),
- "workshop": workshop_details.workshop_title,
- "date": workshop_occurence_list[i].date()
- }]
+ workshop_occurence_list = []
+ for workshop in workshop_details:
+ workshop_occurence = workshop.recurrences.between(
+ datetime(2017, 3, 12, 0, 0, 0),
+ datetime(2040, 12, 31, 0, 0, 0),
+ inc=True
+ )
+ for i in range(len(workshop_occurence)):
+ workshop_occurence_list.append({
+ "user": str(user),
+ "workshop": workshop.workshop_title,
+ "date": workshop_occurence[i].date()
+ })
+
requested_workshop = RequestedWorkshop.objects.filter(
- requested_workshop_instructor=user.id
- )
+ requested_workshop_instructor=user.id
+ )
+
#Need to recheck logic
for j in range(len(requested_workshop)):
for i in workshop_occurence_list:
- if i[0]['date'] == requested_workshop[j].requested_workshop_date:
+ a = requested_workshop[j].requested_workshop_date
+ b = requested_workshop[j].requested_workshop_title
+ if i['date'] == a and i['workshop'] == b:
workshop_occurence_list.remove(i)
+ del a, b
-
- #Show upto 3 Workshops per page
- paginator = Paginator(workshop_occurence_list, 3)
+
+ #Show upto 12 Workshops per page
+ paginator = Paginator(workshop_occurence_list, 12)
page = request.GET.get('page')
try:
workshops = paginator.page(page)
@@ -295,7 +311,7 @@ def my_workshops(request):
user_position = request.user.profile.position
client_data = request.body.decode("utf-8").split("&")
client_data = client_data[0].split("%2C")
-
+
if client_data[-1] == 'ACCEPTED':
workshop_date = datetime.strptime(
client_data[1], "%Y-%m-%d"
@@ -305,13 +321,14 @@ def my_workshops(request):
workshop_status = RequestedWorkshop.objects.get(
requested_workshop_instructor=user.id,
requested_workshop_date=workshop_date,
- requested_workshop_coordinator=coordinator_obj.id
+ requested_workshop_coordinator=coordinator_obj.id,
+ requested_workshop_title=client_data[2]
)
workshop_status.status = client_data[-1]
workshop_status.save()
- confirm_workshop = BookedWorkshop()
- confirm_workshop.booked_workshop = workshop_status
- confirm_workshop.save()
+ booked_workshop_obj = BookedWorkshop()
+ booked_workshop_obj.booked_workshop = workshop_status
+ booked_workshop_obj.save()
#For Instructor
@@ -331,24 +348,29 @@ def my_workshops(request):
elif client_data[-1] == 'DELETED':
workshop_date = client_data[1]
- workshop = Workshop.objects.get(workshop_instructor=request.user.id,
- workshop_title_id=client_data[2])
+ workshops_list = Workshop.objects.filter(workshop_instructor=request.user.id,
+ workshop_title_id=client_data[2]
+ )
- workshop_recurrence_list = workshop.recurrences.between(
- datetime(2017, 3, 12, 0, 0, 0),
- datetime(2017, 12, 31, 0, 0, 0),
- inc=True
- )
+ for workshop in workshops_list:
+ workshop_recurrence_list = workshop.recurrences.between(
+ datetime(2017, 3, 12, 0, 0, 0),
+ datetime(2040, 12, 31, 0, 0, 0),
+ inc=True
+ )
- for d in workshop_recurrence_list:
- if workshop_date == d.strftime("%Y-%m-%d"):
- rW_obj = RequestedWorkshop()
- rW_obj.requested_workshop_instructor = request.user
- rW_obj.requested_workshop_coordinator = request.user
- rW_obj.requested_workshop_date = workshop_date
- rW_obj.requested_workshop_title = workshop.workshop_title
- rW_obj.status = client_data[-1]
- rW_obj.save()
+ for d in workshop_recurrence_list:
+ if workshop_date == d.strftime("%Y-%m-%d"):
+ rW_obj = RequestedWorkshop()
+ rW_obj.requested_workshop_instructor = request.user
+ rW_obj.requested_workshop_coordinator = request.user
+ rW_obj.requested_workshop_date = workshop_date
+ rW_obj.requested_workshop_title = workshop.workshop_title
+ rW_obj.status = client_data[-1]
+ rW_obj.save()
+ bW_obj = BookedWorkshop()
+ bW_obj.booked_workshop = rW_obj
+ bW_obj.save()
#For instructor
send_email(request, call_on='Workshop Deleted',
@@ -358,6 +380,20 @@ def my_workshops(request):
return HttpResponse("Workshop Deleted")
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,
+ requested_workshop_date=workshop_date,
+ requested_workshop_coordinator=coordinator_obj.id,
+ requested_workshop_title=client_data[2]
+ )
+ workshop_status.status = client_data[-1]
+ workshop_status.save()
+
#For Instructor
send_email(request, call_on='Booking Request Rejected',
user_position='instructor',
@@ -377,8 +413,8 @@ def my_workshops(request):
requested_workshop_instructor=user.id
)
- #Show upto 6 Workshops per page
- paginator = Paginator(workshop_occurence_list, 9)
+ #Show upto 12 Workshops per page
+ paginator = Paginator(workshop_occurence_list, 12)
page = request.GET.get('page')
try:
workshop_occurences = paginator.page(page)
@@ -397,8 +433,8 @@ def my_workshops(request):
requested_workshop_coordinator=user.id
)
- #Show upto 6 Workshops per page
- paginator = Paginator(workshop_occurence_list, 9)
+ #Show upto 12 Workshops per page
+ paginator = Paginator(workshop_occurence_list, 12)
print(paginator)
page = request.GET.get('page')
try:
@@ -491,27 +527,23 @@ def create_workshop(request):
def view_course_list(request):
'''Gives the course details '''
user = request.user
- if is_instructor(user):
- course_list = Course.objects.all()
- paginator = Paginator(course_list, 6) #Show upto 12 Courses per page
+ course_list = Course.objects.all()
+ paginator = Paginator(course_list, 12) #Show upto 12 Courses per page
- page = request.GET.get('page')
- try:
- courses = paginator.page(page)
- except PageNotAnInteger:
- #If page is not an integer, deliver first page.
- courses = paginator.page(1)
- except EmptyPage:
- #If page is out of range(e.g 999999), deliver last page.
- courses = paginator.page(paginator.num_pages)
-
- return render(
- request, 'workshop_app/view_course_list.html', \
- {'courses': courses}
- )
-
- else:
- return redirect('/book/')
+ page = request.GET.get('page')
+ try:
+ courses = paginator.page(page)
+ except PageNotAnInteger:
+ #If page is not an integer, deliver first page.
+ courses = paginator.page(1)
+ except EmptyPage:
+ #If page is out of range(e.g 999999), deliver last page.
+ courses = paginator.page(paginator.num_pages)
+
+ return render(
+ request, 'workshop_app/view_course_list.html', \
+ {'courses': courses}
+ )
@login_required