summaryrefslogtreecommitdiff
path: root/workshop_app
diff options
context:
space:
mode:
authorpnshiralkar2020-05-05 12:11:12 +0530
committerpnshiralkar2020-05-05 12:11:12 +0530
commit0fd8703ca8e0b4caf02df30d6e63320fe6f98338 (patch)
tree4203677d5afaff90b48edffc3863b2d6d9fda958 /workshop_app
parentae1b1252f203b9c02139f4fe4d1f097af7952a44 (diff)
downloadworkshop_booking-0fd8703ca8e0b4caf02df30d6e63320fe6f98338.tar.gz
workshop_booking-0fd8703ca8e0b4caf02df30d6e63320fe6f98338.tar.bz2
workshop_booking-0fd8703ca8e0b4caf02df30d6e63320fe6f98338.zip
My workshops view for coordinator done
Diffstat (limited to 'workshop_app')
-rw-r--r--workshop_app/templates/workshop_app/my_workshops.html190
-rw-r--r--workshop_app/templates/workshop_app/workshop_status.html234
-rw-r--r--workshop_app/urls.py7
-rw-r--r--workshop_app/views.py129
4 files changed, 291 insertions, 269 deletions
diff --git a/workshop_app/templates/workshop_app/my_workshops.html b/workshop_app/templates/workshop_app/my_workshops.html
index b6e3731..b5b4add 100644
--- a/workshop_app/templates/workshop_app/my_workshops.html
+++ b/workshop_app/templates/workshop_app/my_workshops.html
@@ -1,203 +1,65 @@
{% extends "workshop_app/base.html" %}
{% block title %}
- Workshop Status
+ My Workshops
{% endblock %}
-{% block extra-dependencies %}
- <link rel="stylesheet" href="https://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://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
-{% endblock %}
-{% block extra-custom-scripts %}
- <script>
- //ToolTip popup function on-hover
- $(document).ready(function () {
- $('[data-toggle="popover"]').popover({
- placement: 'top',
- trigger: 'hover'
- });
- });
-
- //ToolTip popup function on-hover
- $(document).ready(function () {
- $('[data-toggle="popinfo"]').popover({
- placement: 'top',
- trigger: 'hover'
- });
- });
-
- // Change date modal
- function changeDate(date) {
- var previous_date = new Date(date);
- var dateToday = new Date();
- var upto = new Date();
-
- previous_date.setDate(previous_date.getDate() + 1);
- upto.setFullYear(dateToday.getFullYear() + 1);
-
- if (date[0] == 'P') {
- var counter = date.split(" ");
- var id = counter.slice(-1).pop();
- counter = '.pDate' + id
- $(counter).datepicker({
- changeMonth: true,
- changeYear: true,
- minDate: dateToday,
- maxDate: upto,
- dateFormat: "yy-mm-dd",
- });
- $(".ui-dialog-content").dialog("close");
- $('.myDialogP' + id).dialog();
-
- } else {
- var counter = date.split(" ");
- var id = counter.slice(-1).pop();
- counter = '.rDate' + id;
- $(counter).datepicker({
- changeMonth: true,
- changeYear: true,
- minDate: dateToday,
- maxDate: upto,
- dateFormat: "yy-mm-dd",
- });
- $(".ui-dialog-content").dialog("close");
- $('.myDialogR' + id).dialog();
-
- }
- };
-
- </script>
-{% endblock %}
-
-
{% block content %}
{% if workshops %}
- <h3 align="center" style="color:#2952a2;">The status of your workshops </h3>
+ <h3 class="text-center" style="color:#2952a2;">The status of your workshops </h3>
<br>
<!-- Accepted View -->
+
<br>
<div class="container">
- <h3 align="center" style="color: #04a9cf;"><strong>Workshops Accepted</strong></h3>
+ <h3 class="text-center" style="color: #04a9cf;"><strong>Workshops Accepted</strong></h3>
<table class="table table-striped">
<thead>
<tr>
- {% if request.user.profile.position == 'instructor' %}
- <th>Coordinator Name</th>
- <th>Institute</th>
- {% else %}
- <th>Instructor Name</th>
- {% endif %}
+ <th>Instructor Name</th>
<th>Workshop Name</th>
<th>Workshop Day</th>
<th>Status</th>
</tr>
</thead>
- {% csrf_token %}
+
{% for workshop in workshops %}
<tbody>
<tr>
- {% if workshop.status == 1 and workshop.workshop_type %}
- {% if request.user.profile.position == 'instructor' %}
- <td>
- <a href="{{ URL_ROOT }}/view_profile/{{ workshop.coordinator.profile.user.id }}">
- {{ workshop.coordinator.get_full_name }}</a></td>
- <td>{{ workshop.coordinator.profile.institute }}</td>
- {% else %}
- <td>{{ workshop.instructor.get_full_name }}</td>
- {% endif %}
+ {% if workshop.status %}
+ <td>{{ workshop.instructor.get_full_name }}</td>
<td>{{ workshop.workshop_type |capfirst }}</td>
- {% if workshop.date > today %}
- <td>{{ workshop.date | date }}
- <span class="material-icons" style="cursor:pointer;" data-toggle="popinfo"
- title="Note"
- data-content="Click here to change date"
- class="datepicker"
- onclick="changeDate('R,{{ workshop.date| safe }}, {{ forloop.counter }}')">event</span>
- <div class="myDialogR{{ forloop.counter }}" style="display: none;"
- title="Select New Date">
- <form method="post">
- <input type="text" name="new_date" class="rDate{{ forloop.counter }}"/><br>
- <input type="hidden" name="action" value="change_date">
- <input type="hidden" name="workshop_id" value="{{ workshop.id }}">
- <input type="hidden" name="cid" value="{{ workshop.coordinator.id }}">
- {% csrf_token %}
- <button class="btn btn-primary btn-xs" type="submit">Save</button>
- </form>
- </div>
- </td>
- {% else %}
- <td>{{ workshop.date | date }}</td>
- {% endif %}
+ <td>{{ workshop.date | date }}</td>
<td><span class="badge badge-success">{{ workshop.get_status }}</span></td>
{% endif %}
</tr>
</tbody>
-
{% endfor %}
</table>
</div>
-
<!-- Proposed View -->
+
<br>
<div class="container">
-
- {% if request.user.profile.position == 'instructor' %}
- <h3 align="center" style="color: #04a9cf;"><strong>Workshops Proposed By Coordinators</strong>
- </h3>
- {% else %}
- <h3 align="center" style="color: #04a9cf;"><strong>Workshops Proposed By Me</strong></h3>
- {% endif %}
+ <h3 class="text-center" style="color: #04a9cf;"><strong>Workshops Proposed By Me</strong></h3>
<table class="table table-striped">
<thead>
<tr>
- {% if request.user.profile.position == 'instructor' %}
- <th>Coordinator Name</th>
- <th>Institute</th>
- {% else %}
-
- {% endif %}
<th>Workshop Name</th>
<th>Workshop Day</th>
<th>Status</th>
- {% if request.user.profile.position == 'instructor' %}
- <th>Action</th>
- {% endif %}
</tr>
</thead>
- {% csrf_token %}
{% for workshop in workshops %}
<tbody>
<tr>
- {% if workshop.status == 0 and workshop.tnc_accepted %}
- {% if request.user.profile.position == 'instructor' %}
-
- <td>
- <a href="{{ URL_ROOT }}/view_comment_profile/{{ workshop.coordinator.profile.user.id }}">
- {{ workshop.coordinator.get_full_name }}</a></td>
- <td>{{ workshop.coordinator.profile.institute }}</td>
- {% endif %}
+ {% if not workshop.status and workshop.tnc_accepted %}
<td>{{ workshop.workshop_type }}</td>
<td>{{ workshop.date | date }}</td>
-
<td><span class="badge badge-warning">{{ workshop.get_status }}</span></td>
- {% if request.user.profile.position == 'instructor' and workshop.status == 0 %}
- <td>
- <form method="post">
- <input type="hidden" name="action" value="accept">
- <input type="hidden" name="workshop_id" value="{{ workshop.id }}">
- {% csrf_token %}
- <button class="btn btn-primary btn-sm" id="book-btn" 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>
- </form>
- </td>
- {% endif %}
{% endif %}
</tr>
</tbody>
@@ -206,29 +68,15 @@
</table>
</div>
-
-
{% else %}
- {% if request.user.profile.position == 'instructor' %}
- <div class="container">
- <div class="jumbotron">
- <h1>Welcome {{ user.first_name }}</h1>
- <p>Your workshop related information will be shown here, Please navigate to <b>Workshop list</b> and
- depending upon
- your expertise and availability create a workshop by going to
- <b>Create Workshop</b>.</p>
- </div>
- </div>
- {% else %}
- <div class="container">
- <div class="jumbotron">
- <h1>Welcome {{ user.first_name }}</h1>
- <p>Information Related to your workshops will be shown here, you can also
- propose a Workshop as per your available date in <strong>Workshops > Propose a Workshop
- tab</strong> .</p>
- </div>
+ <div class="container">
+ <div class="jumbotron">
+ <h1>Welcome {{ user.first_name }}</h1>
+ <p>Information Related to your workshops will be shown here, you can also
+ propose a Workshop as per your available date in <strong>Workshops > Propose a Workshop
+ tab</strong> .</p>
</div>
- {% endif %}
+ </div>
{% endif %}
{% endblock %}
diff --git a/workshop_app/templates/workshop_app/workshop_status.html b/workshop_app/templates/workshop_app/workshop_status.html
new file mode 100644
index 0000000..b6e3731
--- /dev/null
+++ b/workshop_app/templates/workshop_app/workshop_status.html
@@ -0,0 +1,234 @@
+{% extends "workshop_app/base.html" %}
+
+{% block title %}
+ Workshop Status
+{% endblock %}
+
+{% block extra-dependencies %}
+ <link rel="stylesheet" href="https://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://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
+{% endblock %}
+{% block extra-custom-scripts %}
+ <script>
+ //ToolTip popup function on-hover
+ $(document).ready(function () {
+ $('[data-toggle="popover"]').popover({
+ placement: 'top',
+ trigger: 'hover'
+ });
+ });
+
+ //ToolTip popup function on-hover
+ $(document).ready(function () {
+ $('[data-toggle="popinfo"]').popover({
+ placement: 'top',
+ trigger: 'hover'
+ });
+ });
+
+ // Change date modal
+ function changeDate(date) {
+ var previous_date = new Date(date);
+ var dateToday = new Date();
+ var upto = new Date();
+
+ previous_date.setDate(previous_date.getDate() + 1);
+ upto.setFullYear(dateToday.getFullYear() + 1);
+
+ if (date[0] == 'P') {
+ var counter = date.split(" ");
+ var id = counter.slice(-1).pop();
+ counter = '.pDate' + id
+ $(counter).datepicker({
+ changeMonth: true,
+ changeYear: true,
+ minDate: dateToday,
+ maxDate: upto,
+ dateFormat: "yy-mm-dd",
+ });
+ $(".ui-dialog-content").dialog("close");
+ $('.myDialogP' + id).dialog();
+
+ } else {
+ var counter = date.split(" ");
+ var id = counter.slice(-1).pop();
+ counter = '.rDate' + id;
+ $(counter).datepicker({
+ changeMonth: true,
+ changeYear: true,
+ minDate: dateToday,
+ maxDate: upto,
+ dateFormat: "yy-mm-dd",
+ });
+ $(".ui-dialog-content").dialog("close");
+ $('.myDialogR' + id).dialog();
+
+ }
+ };
+
+ </script>
+{% endblock %}
+
+
+{% block content %}
+ {% if workshops %}
+ <h3 align="center" style="color:#2952a2;">The status of your workshops </h3>
+ <br>
+
+ <!-- Accepted View -->
+ <br>
+ <div class="container">
+ <h3 align="center" style="color: #04a9cf;"><strong>Workshops Accepted</strong></h3>
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ {% if request.user.profile.position == 'instructor' %}
+ <th>Coordinator Name</th>
+ <th>Institute</th>
+ {% else %}
+ <th>Instructor Name</th>
+ {% endif %}
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
+ <th>Status</th>
+ </tr>
+ </thead>
+ {% csrf_token %}
+ {% for workshop in workshops %}
+ <tbody>
+ <tr>
+ {% if workshop.status == 1 and workshop.workshop_type %}
+ {% if request.user.profile.position == 'instructor' %}
+ <td>
+ <a href="{{ URL_ROOT }}/view_profile/{{ workshop.coordinator.profile.user.id }}">
+ {{ workshop.coordinator.get_full_name }}</a></td>
+ <td>{{ workshop.coordinator.profile.institute }}</td>
+ {% else %}
+ <td>{{ workshop.instructor.get_full_name }}</td>
+ {% endif %}
+ <td>{{ workshop.workshop_type |capfirst }}</td>
+ {% if workshop.date > today %}
+ <td>{{ workshop.date | date }}
+ <span class="material-icons" style="cursor:pointer;" data-toggle="popinfo"
+ title="Note"
+ data-content="Click here to change date"
+ class="datepicker"
+ onclick="changeDate('R,{{ workshop.date| safe }}, {{ forloop.counter }}')">event</span>
+ <div class="myDialogR{{ forloop.counter }}" style="display: none;"
+ title="Select New Date">
+ <form method="post">
+ <input type="text" name="new_date" class="rDate{{ forloop.counter }}"/><br>
+ <input type="hidden" name="action" value="change_date">
+ <input type="hidden" name="workshop_id" value="{{ workshop.id }}">
+ <input type="hidden" name="cid" value="{{ workshop.coordinator.id }}">
+ {% csrf_token %}
+ <button class="btn btn-primary btn-xs" type="submit">Save</button>
+ </form>
+ </div>
+ </td>
+ {% else %}
+ <td>{{ workshop.date | date }}</td>
+ {% endif %}
+ <td><span class="badge badge-success">{{ workshop.get_status }}</span></td>
+ {% endif %}
+ </tr>
+ </tbody>
+
+ {% endfor %}
+
+ </table>
+ </div>
+
+
+ <!-- Proposed View -->
+ <br>
+ <div class="container">
+
+ {% if request.user.profile.position == 'instructor' %}
+ <h3 align="center" style="color: #04a9cf;"><strong>Workshops Proposed By Coordinators</strong>
+ </h3>
+ {% else %}
+ <h3 align="center" style="color: #04a9cf;"><strong>Workshops Proposed By Me</strong></h3>
+ {% endif %}
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ {% if request.user.profile.position == 'instructor' %}
+ <th>Coordinator Name</th>
+ <th>Institute</th>
+ {% else %}
+
+ {% endif %}
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
+ <th>Status</th>
+ {% if request.user.profile.position == 'instructor' %}
+ <th>Action</th>
+ {% endif %}
+ </tr>
+ </thead>
+ {% csrf_token %}
+ {% for workshop in workshops %}
+ <tbody>
+ <tr>
+ {% if workshop.status == 0 and workshop.tnc_accepted %}
+ {% if request.user.profile.position == 'instructor' %}
+
+ <td>
+ <a href="{{ URL_ROOT }}/view_comment_profile/{{ workshop.coordinator.profile.user.id }}">
+ {{ workshop.coordinator.get_full_name }}</a></td>
+ <td>{{ workshop.coordinator.profile.institute }}</td>
+ {% endif %}
+ <td>{{ workshop.workshop_type }}</td>
+ <td>{{ workshop.date | date }}</td>
+
+ <td><span class="badge badge-warning">{{ workshop.get_status }}</span></td>
+ {% if request.user.profile.position == 'instructor' and workshop.status == 0 %}
+ <td>
+ <form method="post">
+ <input type="hidden" name="action" value="accept">
+ <input type="hidden" name="workshop_id" value="{{ workshop.id }}">
+ {% csrf_token %}
+ <button class="btn btn-primary btn-sm" id="book-btn" 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>
+ </form>
+ </td>
+ {% endif %}
+ {% endif %}
+ </tr>
+ </tbody>
+
+ {% endfor %}
+ </table>
+ </div>
+
+
+
+ {% else %}
+ {% if request.user.profile.position == 'instructor' %}
+ <div class="container">
+ <div class="jumbotron">
+ <h1>Welcome {{ user.first_name }}</h1>
+ <p>Your workshop related information will be shown here, Please navigate to <b>Workshop list</b> and
+ depending upon
+ your expertise and availability create a workshop by going to
+ <b>Create Workshop</b>.</p>
+ </div>
+ </div>
+ {% else %}
+ <div class="container">
+ <div class="jumbotron">
+ <h1>Welcome {{ user.first_name }}</h1>
+ <p>Information Related to your workshops will be shown here, you can also
+ propose a Workshop as per your available date in <strong>Workshops > Propose a Workshop
+ tab</strong> .</p>
+ </div>
+ </div>
+ {% endif %}
+ {% endif %}
+
+{% endblock %}
diff --git a/workshop_app/urls.py b/workshop_app/urls.py
index 4bb140c..57baaf5 100644
--- a/workshop_app/urls.py
+++ b/workshop_app/urls.py
@@ -17,7 +17,7 @@ from django.conf.urls import url
from workshop_app import views
js_info_dict = {
- 'packages': ('recurrence', ),
+ 'packages': ('recurrence',),
}
urlpatterns = [
@@ -29,9 +29,10 @@ urlpatterns = [
url(r'^logout/$', views.user_logout),
url(r'^view_profile/$', views.view_profile),
url(r'^edit_profile/$', views.edit_profile),
- url(r'^my_workshops/$', views.my_workshops),
+ url(r'^my_workshops/$', views.my_workshops, name='my_workshops'), # Coordinator
+ url(r'^workshop_status/$', views.workshop_status, name='workshop_status'), # Instructor
url(r'^propose_workshop/$', views.propose_workshop),
url(r'^workshop_types/$', views.workshop_type_list),
url(r'^workshop_type_details/([1-9][0-9]*)$', views.workshop_type_details),
url(r'^view_profile/([1-9][0-9]*)$', views.view_comment_profile),
- ]
+]
diff --git a/workshop_app/views.py b/workshop_app/views.py
index 5d0525c..cd58326 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -1,3 +1,5 @@
+from django.urls import reverse
+
try:
from StringIO import StringIO as string_io
except ImportError:
@@ -6,7 +8,7 @@ from datetime import datetime
from django.contrib.auth import login, logout, authenticate
from django.contrib.auth.decorators import login_required
-from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
+from django.core.paginator import Paginator
from django.shortcuts import render, redirect
from django.utils import timezone
@@ -42,8 +44,8 @@ def is_instructor(user):
def get_landing_page(user):
# For now, landing pages of both instructor and coordinator are same
if is_instructor(user):
- return '/my_workshops/'
- return '/my_workshops/'
+ return reverse('workshop_status')
+ return reverse('my_workshops')
# View functions
@@ -194,103 +196,40 @@ def edit_profile(request):
# Workshop views
-@login_required
-def my_workshops(request):
- user = request.user
- if user.is_authenticated:
- # View for instructor
- if is_instructor(user):
- if request.method == 'POST':
- client_data = request.POST
- action = request.POST.get('action')
- if action == 'accept':
- workshop = Workshop.objects.get(id=client_data.get('workshop_id'))
- # Change Status of the selected workshop
- workshop.status = 1
- workshop.instructor = user
- workshop.save()
- # Parameters for emails
- coordinator_email = workshop.coordinator.email
- coordinator_name = workshop.coordinator.profile.user.get_full_name()
- coordinator_phone = workshop.coordinator.profile.phone_number
- coordinator_institute = workshop.coordinator.profile.institute
- instructor_phone = request.user.profile.phone_number
- workshop_title = workshop.workshop_type.name
- workshop_date = str(workshop.date)
-
- # For Instructor
- send_email(request, call_on='Booking Confirmed',
- user_position='instructor',
- workshop_date=workshop_date,
- workshop_title=workshop_title,
- user_name=str(coordinator_name),
- other_email=coordinator_email,
- phone_number=coordinator_phone,
- institute=coordinator_institute
- )
-
- # For Coordinator
- send_email(request, call_on='Booking Confirmed',
- workshop_date=workshop_date,
- workshop_title=workshop_title,
- other_email=coordinator_email,
- phone_number=instructor_phone
- )
-
- elif action == 'change_date':
- cid = client_data.get('cid')
- new_workshop_date = datetime.strptime(client_data.get('new_date'), "%Y-%m-%d")
- coordinator_email = User.objects.get(id=cid)
- today = datetime.today()
- if today > new_workshop_date:
- # Invalid date
- pass
- else:
- workshop = Workshop.objects.filter(id=client_data.get('workshop_id'))
- workshop_date = workshop.first().date
- workshop.update(date=new_workshop_date)
-
- # For Instructor
- send_email(request, call_on='Change Date',
- user_position='instructor',
- workshop_date=str(workshop_date),
- new_workshop_date=str(new_workshop_date.date())
- )
- # For Coordinator
- send_email(request, call_on='Change Date',
- new_workshop_date=str(new_workshop_date.date()),
- workshop_date=str(workshop_date),
- other_email=coordinator_email.email
- )
- today = timezone.now()
- proposed_workshop = Workshop.objects.filter(
- instructor=user.id,
- date__gte=today,
- ).order_by('-date')
+def my_workshops(request):
+ """ Workshops proposed by Coordinator """
+ user = request.user
+ if is_instructor(user):
+ return redirect(get_landing_page(user))
+ workshops = Workshop.objects.filter(
+ coordinator=user.id
+ ).order_by('-date')
+ return render(request, 'workshop_app/my_workshops.html',
+ {"workshops": workshops})
- proposed_workshop_pending = Workshop.objects.filter(
- status=0
- ).order_by('-date')
- workshops = list(proposed_workshop) + list(proposed_workshop_pending)
+def workshop_status(request):
+ """ Workshops to accept and accepted by Instructor """
+ user = request.user
+ if not is_instructor(user):
+ return redirect(get_landing_page(user))
+ today = timezone.now().date()
+ proposed_workshop = Workshop.objects.filter(
+ instructor=user.id,
+ date__gte=today,
+ ).order_by('-date')
- return render(request, 'workshop_app/my_workshops.html',
- {"workshops": workshops,
- "today": today})
+ proposed_workshop_pending = Workshop.objects.filter(
+ status=0
+ ).order_by('-date')
- # Coordinator view
- else:
- workshops = Workshop.objects.filter(
- coordinator=user.id
- ).order_by('-date')
- return render(request, 'workshop_app/my_workshops.html',
- {"workshops": workshops})
- # Not logged in view
- else:
- return redirect('/login/')
+ workshops = list(proposed_workshop) + list(proposed_workshop_pending)
+ return render(request, 'workshop_app/workshop_status.html',
+ {"workshops": workshops,
+ "today": today})
# TODO: Show terms n conditions of selected ws type
@@ -362,14 +301,14 @@ def workshop_type_list(request):
paginator = Paginator(workshop_types, 12) # Show upto 12 workshops per page
page = request.GET.get('page')
- workshop_type = paginator.get_page(paginator.num_pages)
+ workshop_type = paginator.get_page(page)
return render(request, 'workshop_app/workshop_type_list.html', {'workshop_type': workshop_type})
@login_required
def view_comment_profile(request, user_id):
- """instructor can view/post comments on coordinator profile """
+ """Instructor can view coordinator profile """
user = request.user
if is_instructor(user) and is_email_checked(user):
coordinator_profile = Profile.objects.get(user_id=user_id)