summaryrefslogtreecommitdiff
path: root/workshop_app
diff options
context:
space:
mode:
Diffstat (limited to 'workshop_app')
-rw-r--r--workshop_app/templates/workshop_app/my_workshops.html780
-rw-r--r--workshop_app/templates/workshop_app/workshop_type_details.html (renamed from workshop_app/templates/workshop_app/view_workshoptype_details.html)2
-rw-r--r--workshop_app/templates/workshop_app/workshop_type_list.html (renamed from workshop_app/templates/workshop_app/view_workshoptype_list.html)16
-rw-r--r--workshop_app/urls.py18
-rw-r--r--workshop_app/views.py1062
5 files changed, 569 insertions, 1309 deletions
diff --git a/workshop_app/templates/workshop_app/my_workshops.html b/workshop_app/templates/workshop_app/my_workshops.html
index ed79934..9d81c84 100644
--- a/workshop_app/templates/workshop_app/my_workshops.html
+++ b/workshop_app/templates/workshop_app/my_workshops.html
@@ -1,403 +1,419 @@
{% extends "workshop_app/base.html" %}
{% block title %}
- Workshop Status
+ Workshop Status
{% endblock %}
{% block extra %}
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
- <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script src="{{URL_ROOT}}/static/workshop_app/js/bootstrap-3.3.7.min.js"></script>
- <script src="{{URL_ROOT}}/static/workshop_app/js/jquery-1.12.1-ui.min.js"></script>
-
- <script>
- //ToolTip popup function onhover
- $(document).ready(function(){
- $('[data-toggle="popover"]').popover({
- placement : 'top',
- trigger : 'hover'
- });
- });
-
- function sendData(d){
- var URL = "{{ URL_ROOT }}/my_workshops/"
- $.ajax({
- url: URL,
- type: "POST",
- dataType: 'json',
- data: {
- d,
- csrfmiddlewaretoken: $("input[name=csrfmiddlewaretoken]").val()
- },
- });
-
- window.location.reload();
- alert("Refreshing Page please wait, if you don't see your changes, please refresh this page again.");
- }
- </script>
-
- <!-- Change Workshop Date -->
- <script type="text/javascript">
- //ToolTip popup function onhover
- $(document).ready(function(){
- $('[data-toggle="popinfo"]').popover({
- placement : 'top',
- trigger : 'hover'
- });
- });
-
- 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();
-
- }
- };
-
- function submitNewDate(info){
- var data = info.split(",");
- if(data[1] == 'R'){
- var date = document.getElementsByClassName('rDate'+data[0]);
- info = data.slice(2);
- }
- else{
- var date = document.getElementsByClassName('pDate'+data[0]);
- info = data.slice(2);
- }
- var data_c = info + ',new_date=' + date[0].value +',CHANGE_DATE';
- var URL = "{{ URL_ROOT }}/my_workshops/";
- $.ajax({
- url: URL,
- async: false,
- type: "POST",
- data: {
- data_c,
- csrfmiddlewaretoken: $("input[name=csrfmiddlewaretoken]").val()
- },
- success:function(response){
- window.location.reload();
- alert(response);
- }
- });
-
- };
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
+ <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
+ <script src="{{ URL_ROOT }}/static/workshop_app/js/bootstrap-3.3.7.min.js"></script>
+ <script src="{{ URL_ROOT }}/static/workshop_app/js/jquery-1.12.1-ui.min.js"></script>
+
+ <script>
+ //ToolTip popup function onhover
+ $(document).ready(function () {
+ $('[data-toggle="popover"]').popover({
+ placement: 'top',
+ trigger: 'hover'
+ });
+ });
+
+ function sendData(d) {
+ var URL = "{{ URL_ROOT }}/my_workshops/"
+ $.ajax({
+ url: URL,
+ type: "POST",
+ dataType: 'json',
+ data: {
+ d,
+ csrfmiddlewaretoken: $("input[name=csrfmiddlewaretoken]").val()
+ },
+ });
+
+ window.location.reload();
+ alert("Refreshing Page please wait, if you don't see your changes, please refresh this page again.");
+ }
+ </script>
+
+ <!-- Change Workshop Date -->
+ <script type="text/javascript">
+ //ToolTip popup function onhover
+ $(document).ready(function () {
+ $('[data-toggle="popinfo"]').popover({
+ placement: 'top',
+ trigger: 'hover'
+ });
+ });
+
+ 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();
+
+ }
+ };
+
+ function submitNewDate(info) {
+ var data = info.split(",");
+ if (data[1] == 'R') {
+ var date = document.getElementsByClassName('rDate' + data[0]);
+ info = data.slice(2);
+ } else {
+ var date = document.getElementsByClassName('pDate' + data[0]);
+ info = data.slice(2);
+ }
+ var data_c = info + ',new_date=' + date[0].value + ',CHANGE_DATE';
+ var URL = "{{ URL_ROOT }}/my_workshops/";
+ $.ajax({
+ url: URL,
+ async: false,
+ type: "POST",
+ data: {
+ data_c,
+ csrfmiddlewaretoken: $("input[name=csrfmiddlewaretoken]").val()
+ },
+ success: function (response) {
+ window.location.reload();
+ alert(response);
+ }
+ });
+
+ };
</script>
{% endblock %}
{% block content %}
-{% if workshops %}
- <h3 align="center" style="color:#2952a2;">The status of your workshops </h3>
- <br>
-
- <!-- Pending View -->
- <div class="container">
- {% if request.user.profile.position == 'instructor'%}
- <h3 align="center" style="color: #04a9cf;"><strong><u>Team Member Requests</u></strong></h3>
-
- <table class="table">
- <thead>
- <tr>
- <th>Coordinator Name</th>
- <th>Team Member</th>
- <th>Workshop Name</th>
- <th>Workshop Day</th>
- </tr>
- </thead>
- <tbody>
- {% for workshop in team_workshops %}
- <tr>
- <td><a href="{{ URL_ROOT }}/view_comment_profile/{{ workshop.coordinator.id }}">
- {{ workshop.coordinator.get_full_name }}</a>
- </td>
- <td>
- {{ workshop.instructor.get_full_name }}
- </td>
- <td>
- {{ workshop.title }}
- </td>
- <td>
- {{ workshop.date | date }}
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {% endif %}
- {% if request.user.profile.position == 'instructor' %}
- <h3 align="center" style="color: #04a9cf;"><strong><u>Requests for Me</u></strong></h3>
- {% else %}
- <h3 align="center" style="color: #04a9cf;"><strong><u>My Requests</u></strong></h3>
- {% endif %}
- <table class="table table-striped">
- <thead>
- <tr>
- {% if request.user.profile.position == 'instructor' %}
- <th>Coordinator Name</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 == 0 and workshop.instructor %}
- {% 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>
- {% else %}
- <td>{{ workshop.instructor.get_full_name }}</td>
- {% endif %}
- <td>{{ workshop.title }}</td>
- <td>{{ workshop.date | date }}</td>
- <td><span class = "label label-warning">{{ workshop.status }}</span></td>
- {% endif %}
- {% if request.user.profile.position == 'instructor' and workshop.status == 0 and workshop.instructor %}
- <td><button class="btn btn-primary btn-sm" id="book-btn" onClick="sendData('{{workshop.coordinator}},{{workshop.date| safe}},{{ 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.coordinator}},{{workshop.date| safe}},{{ workshop.title_id }},REJECTED')" data-toggle="popover" title="Please Note" data-content="Once Rejected you cannot revoke this action."> Reject </button></td>
- {% endif %}
- </tr>
- </tbody>
- {% endfor %}
- </table>
- </div>
-
- <!-- Accepted View -->
- <div class="container">
- <h3 align="center" style="color: #04a9cf;"><strong><u>Workshops Accepted</u></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_comment_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.title |capfirst }}</td>
- {% if workshop.date > today %}
- <td>{{ workshop.date | date }}
- <span class="glyphicon glyphicon-calendar" data-toggle="popinfo" title="Note" data-content="Click here to change date"
- class="datepicker" onclick="changeDate('R,{{ workshop.date| safe}}, {{forloop.counter}}')">
+ {% if workshops %}
+ <h3 align="center" style="color:#2952a2;">The status of your workshops </h3>
+ <br>
+
+ <!-- Pending View -->
+ <div class="container">
+ {% if request.user.profile.position == 'instructor' %}
+ <h3 align="center" style="color: #04a9cf;"><strong><u>Team Member Requests</u></strong></h3>
+
+ <table class="table">
+ <thead>
+ <tr>
+ <th>Coordinator Name</th>
+ <th>Team Member</th>
+ <th>Workshop Name</th>
+ <th>Workshop Day</th>
+ </tr>
+ </thead>
+ <tbody>
+ </tbody>
+ </table>
+ {% endif %}
+ {% if request.user.profile.position == 'instructor' %}
+ <h3 align="center" style="color: #04a9cf;"><strong><u>Requests for Me</u></strong></h3>
+ {% else %}
+ <h3 align="center" style="color: #04a9cf;"><strong><u>My Requests</u></strong></h3>
+ {% endif %}
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ {% if request.user.profile.position == 'instructor' %}
+ <th>Coordinator Name</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 == 0 and workshop.instructor %}
+ {% 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>
+ {% else %}
+ <td>{{ workshop.instructor.get_full_name }}</td>
+ {% endif %}
+ <td>{{ workshop.title }}</td>
+ <td>{{ workshop.date | date }}</td>
+ <td><span class="label label-warning">{{ workshop.status }}</span></td>
+ {% endif %}
+ {% if request.user.profile.position == 'instructor' and workshop.status == 0 and workshop.instructor %}
+ <td>
+ <button class="btn btn-primary btn-sm" id="book-btn"
+ onClick="sendData('{{ workshop.coordinator }},{{ workshop.date| safe }},{{ 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.coordinator }},{{ workshop.date| safe }},{{ workshop.title_id }},REJECTED')"
+ data-toggle="popover" title="Please Note"
+ data-content="Once Rejected you cannot revoke this action."> Reject
+ </button>
+ </td>
+ {% endif %}
+ </tr>
+ </tbody>
+ {% endfor %}
+ </table>
+ </div>
+
+ <!-- Accepted View -->
+ <div class="container">
+ <h3 align="center" style="color: #04a9cf;"><strong><u>Workshops Accepted</u></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_comment_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.title |capfirst }}</td>
+ {% if workshop.date > today %}
+ <td>{{ workshop.date | date }}
+ <span class="glyphicon glyphicon-calendar" data-toggle="popinfo" title="Note"
+ data-content="Click here to change date"
+ class="datepicker"
+ onclick="changeDate('R,{{ workshop.date| safe }}, {{ forloop.counter }}')">
</span>
- <div class="myDialogR{{forloop.counter}}" style="display: none;" title="Select New Date">
+ <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="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>
+ <button class="btn btn-primary btn-xs" type="submit">Save</button>
</form>
- </div>
- </td>
- {% else %}
- <td>{{ workshop.date | date }}</td>
- {% endif %}
- <td><span class = "label label-success">{{ workshop.get_status }}</span></td>
- {% endif %}
- {% if workshop.status == 1 and workshop.condition_one %}
- {% 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>
- {% else %}
- <td>{{ workshop.instructor.get_full_name }}</td>
- {% endif %}
- <td>{{ workshop.title }}</td>
- {% if workshop.date > today %}
- <td>{{ workshop.date | date }}
- <span class="glyphicon glyphicon-calendar"
- class="datepicker" data-toggle="popinfo" title="Note" data-content="Click here to change date"
- onclick="changeDate('P,{{ workshop.date | safe}}, {{forloop.counter}}')">
+ </div>
+ </td>
+ {% else %}
+ <td>{{ workshop.date | date }}</td>
+ {% endif %}
+ <td><span class="label label-success">{{ workshop.get_status }}</span></td>
+ {% endif %}
+ {% if workshop.status == 1 and workshop.condition_one %}
+ {% 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>
+ {% else %}
+ <td>{{ workshop.instructor.get_full_name }}</td>
+ {% endif %}
+ <td>{{ workshop.title }}</td>
+ {% if workshop.date > today %}
+ <td>{{ workshop.date | date }}
+ <span class="glyphicon glyphicon-calendar"
+ class="datepicker" data-toggle="popinfo" title="Note"
+ data-content="Click here to change date"
+ onclick="changeDate('P,{{ workshop.date | safe }}, {{ forloop.counter }}')">
</span>
- <div class="myDialogP{{forloop.counter}}" style="display: none;" title="Select New Date">
-
- <input type="text" class="pDate{{forloop.counter}}" /><br>
- <button class="btn btn-primary btn-xs" type="submit" onclick="submitNewDate('{{forloop.counter}},P,{{workshop.instructor_id}},{{workshop.coordinator_id}},{{ workshop.title_id }},{{ workshop.date | safe}}')">Update</button>
- </div>
- </td>
- {% else %}
- <td>{{ workshop.date | date }}</td>
- {% endif %}
- <td><span class = "label label-success">{{ workshop.status }}</span></td>
- {% endif %}
- </tr>
- </tbody>
-
- {% endfor %}
-
- </table>
- </div>
-
-
-<!-- Proposed View -->
-<div class="container">
- {% if request.user.profile.position == 'instructor' %}
- <h3 align="center" style="color: #04a9cf;"><strong><u>Workshops Proposed By Coordinators</u></strong></h3>
- {% else %}
- <h3 align="center" style="color: #04a9cf;"><strong><u>Workshops Proposed By Me</u></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>
- </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 = "label label-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="approve">
- <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>
-
-
-<!-- Deleted/Rejected View -->
-<div class="container">
- <h3 align="center" style="color: #04a9cf;"><strong><u>Workshops Deleted/Rejected</u></strong></h3>
- <table class="table table-striped">
- <thead>
- <tr>
- {% if request.user.profile.position == 'instructor' %}
- <th>Coordinator Name</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 == 'DELETED' or workshop.status == 'REJECTED' %}
- {% if request.user.profile.position == 'instructor' %}
- <td>{{ workshop.coordinator.get_full_name }}</td>
- {% else %}
- <td>{{ workshop.instructor.get_full_name }}</td>
- {% endif %}
- <td>{{ workshop.title | capfirst }}</td>
- <td>{{ workshop.date | date }}</td>
-
- <td><span class = "label label-danger">{{ workshop.status }}</span></td>
- {% 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 %}
+ <div class="myDialogP{{ forloop.counter }}" style="display: none;"
+ title="Select New Date">
+
+ <input type="text" class="pDate{{ forloop.counter }}"/><br>
+ <button class="btn btn-primary btn-xs" type="submit"
+ onclick="submitNewDate('{{ forloop.counter }},P,{{ workshop.instructor_id }},{{ workshop.coordinator_id }},{{ workshop.title_id }},{{ workshop.date | safe }}')">
+ Update
+ </button>
+ </div>
+ </td>
+ {% else %}
+ <td>{{ workshop.date | date }}</td>
+ {% endif %}
+ <td><span class="label label-success">{{ workshop.status }}</span></td>
+ {% endif %}
+ </tr>
+ </tbody>
+
+ {% endfor %}
+
+ </table>
+ </div>
+
+
+ <!-- Proposed View -->
+ <div class="container">
+ {% if request.user.profile.position == 'instructor' %}
+ <h3 align="center" style="color: #04a9cf;"><strong><u>Workshops Proposed By Coordinators</u></strong>
+ </h3>
+ {% else %}
+ <h3 align="center" style="color: #04a9cf;"><strong><u>Workshops Proposed By Me</u></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>
+ </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="label label-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>
+
+
+ <!-- Deleted/Rejected View -->
+ <div class="container">
+ <h3 align="center" style="color: #04a9cf;"><strong><u>Workshops Deleted/Rejected</u></strong></h3>
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ {% if request.user.profile.position == 'instructor' %}
+ <th>Coordinator Name</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 == 'DELETED' or workshop.status == 'REJECTED' %}
+ {% if request.user.profile.position == 'instructor' %}
+ <td>{{ workshop.coordinator.get_full_name }}</td>
+ {% else %}
+ <td>{{ workshop.instructor.get_full_name }}</td>
+ {% endif %}
+ <td>{{ workshop.title | capfirst }}</td>
+ <td>{{ workshop.date | date }}</td>
+
+ <td><span class="label label-danger">{{ workshop.status }}</span></td>
+ {% 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/templates/workshop_app/view_workshoptype_details.html b/workshop_app/templates/workshop_app/workshop_type_details.html
index 1504430..b8d6559 100644
--- a/workshop_app/templates/workshop_app/view_workshoptype_details.html
+++ b/workshop_app/templates/workshop_app/workshop_type_details.html
@@ -16,7 +16,7 @@
{% block content %}
<div class="container">
- {{ workshoptype.workshoptype_description | safe }}
+ {{ workshop_type.description | safe }}
</div>
{% endblock %}
diff --git a/workshop_app/templates/workshop_app/view_workshoptype_list.html b/workshop_app/templates/workshop_app/workshop_type_list.html
index 2a561e7..0531864 100644
--- a/workshop_app/templates/workshop_app/view_workshoptype_list.html
+++ b/workshop_app/templates/workshop_app/workshop_type_list.html
@@ -63,13 +63,13 @@
</tr>
</thead>
- {% for w in workshoptype %}
+ {% for w in workshop_type %}
<tbody>
<tr >
<td scope="row" id="{{ forloop.counter }}">{{ forloop.counter }}</td>
- <td>{{ w.workshoptype_name }}</td>
- <td>{{ w.workshoptype_duration }}</td>
- <td><a href="{{URL_ROOT}}/view_workshoptype_details/{{ w.id }}" class="btn btn-default btn-sm" class="accordion-toggle" >View Workshop Details</a></td>
+ <td>{{ w.name }}</td>
+ <td>{{ w.duration }}</td>
+ <td><a href="{{URL_ROOT}}/workshop_type_details/{{ w.id }}" class="btn btn-default btn-sm" class="accordion-toggle" >View Workshop Details</a></td>
</tr>
</tbody>
{% endfor %}
@@ -101,17 +101,17 @@
<li class="page-item">
{% if workshoptype.has_previous %}
<a class="page-link" tabindex="-1"
- href="?page={{ workshoptype.previous_page_number }}">Previous</a>
+ href="?page={{ workshop_type.previous_page_number }}">Previous</a>
{% endif %}
</li>
<li class="page-item">
<span class="current">
- Page {{ workshoptype.number }} of {{ workshoptype.paginator.num_pages }}
+ Page {{ workshop_type.number }} of {{ workshop_type.paginator.num_pages }}
</span>
</li>
<li class="page-item">
- {% if workshoptype.has_next %}
- <a class="page-link" href="?page={{ workshoptype.next_page_number }}">Next
+ {% if workshop_type.has_next %}
+ <a class="page-link" href="?page={{ workshop_type.next_page_number }}">Next
</a>
{% endif %}
</li>
diff --git a/workshop_app/urls.py b/workshop_app/urls.py
index c58ba3b..059c1b5 100644
--- a/workshop_app/urls.py
+++ b/workshop_app/urls.py
@@ -15,7 +15,6 @@ Including another URLconf
"""
from django.conf.urls import url
from workshop_app import views
-import django
js_info_dict = {
'packages': ('recurrence', ),
@@ -30,21 +29,8 @@ urlpatterns = [
url(r'^logout/$', views.user_logout),
url(r'^view_profile/$', views.view_profile),
url(r'^edit_profile/$', views.edit_profile),
- # url(r'^book/$', views.book),
- # url(r'^book_workshop/$', views.book_workshop),
url(r'^my_workshops/$', views.my_workshops),
- # url(r'^how_to_participate/$', views.how_to_participate),
- # url(r'^faq/$', views.faq),
- # url(r'^manage/$', views.manage),
- # url(r'^view_workshoptype_list/$', views.view_workshoptype_list),
- # url(r'^view_workshoptype_details/([1-9][0-9]*)$', \
- # views.view_workshoptype_details),
- # url(r'^create_workshop/$', views.create_workshop),
url(r'^propose_workshop/$', views.propose_workshop),
- # url(r'^workshop_stats/$', views.workshop_stats),
- # url(r'^jsi18n/$', django.views.i18n.javascript_catalog, js_info_dict),
- # url(r'^self_workshop', views.self_workshop),
- # url(r'^view_comment_profile/([1-9][0-9]*)$', views.view_comment_profile),
- # url(r'^download/',views.download_csv_data),
+ url(r'^workshop_type_list/$', views.workshop_type_list),
+ url(r'^workshop_type_details/([1-9][0-9]*)$', views.workshop_type_details),
]
-
diff --git a/workshop_app/views.py b/workshop_app/views.py
index ac8fff3..65c08b2 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -1,8 +1,3 @@
-from os import listdir, path, sep
-from zipfile import ZipFile
-
-from teams.models import Team
-
try:
from StringIO import StringIO as string_io
except ImportError:
@@ -14,18 +9,15 @@ from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import render, redirect
from django.utils import timezone
-from django.http import HttpResponse
from .forms import (
UserRegistrationForm, UserLoginForm,
- ProfileForm, CreateWorkshop,
- WorkshopForm
+ ProfileForm, WorkshopForm
)
from .models import (
Profile, User,
- has_profile, Workshop,
- WorkshopType,
- Testimonial, Banner
+ Workshop,
+ WorkshopType
)
from .send_mails import send_email
@@ -36,6 +28,8 @@ __credits__ = ["Mahesh Gudi", "Aditya P.", "Ankit Javalkar",
"Arun KP"]
+# Helper functions
+
def is_email_checked(user):
if hasattr(user, 'profile'):
return True if user.profile.is_email_verified else False
@@ -43,63 +37,49 @@ def is_email_checked(user):
return False
-def is_superuser(user):
- return True if user.is_superuser else False
+def is_instructor(user):
+ """Check if the user is having instructor rights"""
+ return True if user.groups.filter(name='instructor').count() > 0 else False
-def index(request):
- '''Landing Page'''
+def get_landing_page(user):
+ # For now, landing pages of both instructor and coordinator are same
+ if user.groups.filter(name='instructor').count() > 0:
+ return '/my_workshops/'
+ return '/my_workshops/'
+
+# View functions
+
+def index(request):
+ """Landing Page : Redirect to login page if not logged in
+ Redirect to respective landing page according to position"""
user = request.user
- form = UserLoginForm()
- testimonials = Testimonial.objects.all()
if user.is_authenticated and is_email_checked(user):
- if user.groups.filter(name='instructor').count() > 0:
- return redirect('/manage/')
- return redirect('/book/')
- elif request.method == "POST":
- form = UserLoginForm(request.POST)
- if form.is_valid():
- user = form.cleaned_data
- login(request, user)
- if is_superuser(user):
- return redirect("/admin")
- if user.groups.filter(name='instructor').count() > 0:
- return redirect('/manage/')
- return redirect('/book/')
-
- return render(request, "workshop_app/index.html",
- {
- "form": form,
- "testimonials": testimonials,
- "banners": Banner.objects.all(),
- }
- )
+ return redirect(get_landing_page(user))
+ return redirect('/login/')
-def is_instructor(user):
- '''Check if the user is having instructor rights'''
- return True if user.groups.filter(name='instructor').count() > 0 else False
+# User views
def user_login(request):
- '''User Login'''
+ """User Login"""
user = request.user
- if is_superuser(user):
+ if user.is_superuser:
return redirect('/admin')
if user.is_authenticated:
- if user.groups.filter(name='instructor').count() > 0:
- return redirect('/manage/')
- return redirect('/book/')
+ return redirect(get_landing_page(user))
if request.method == "POST":
form = UserLoginForm(request.POST)
if form.is_valid():
user = form.cleaned_data
- login(request, user)
- if user.groups.filter(name='instructor').count() > 0:
- return redirect('/manage/')
- return redirect('/book/')
+ if user.profile.is_email_verified:
+ login(request, user)
+ return redirect(get_landing_page(user))
+ else:
+ return render(request, 'workshop_app/activation.html')
else:
return render(request, 'workshop_app/login.html', {"form": form})
else:
@@ -108,14 +88,14 @@ def user_login(request):
def user_logout(request):
- '''Logout'''
+ """Logout"""
logout(request)
return render(request, 'workshop_app/logout.html')
def activate_user(request, key=None):
user = request.user
- if is_superuser(user):
+ if user.is_superuser:
return redirect("/admin")
if key is None:
if user.is_authenticated and user.profile.is_email_verified == 0 and \
@@ -134,28 +114,25 @@ def activate_user(request, key=None):
else:
return redirect('/register/')
- try:
- user = Profile.objects.get(activation_key=key)
- except:
- return redirect('/register/')
-
- if key == user.activation_key:
- user.is_email_verified = True
- user.save()
- status = "0"
+ user = Profile.objects.filter(activation_key=key)
+ if user.count() > 0:
+ user = user[0]
else:
logout(request)
- return redirect('/logout/')
+ return redirect('/register/')
+
+ user.is_email_verified = True
+ user.save()
+ status = "0"
return render(request, 'workshop_app/activation.html',
{"status": status})
def user_register(request):
- '''User Registration form'''
+ """User Registration form"""
if request.method == 'POST':
form = UserRegistrationForm(request.POST)
if form.is_valid():
- data = form.cleaned_data
username, password, key = form.save()
new_user = authenticate(username=username, password=password)
login(request, new_user)
@@ -165,7 +142,6 @@ def user_register(request):
user_position=user_position,
key=key
)
-
return render(request, 'workshop_app/activation.html')
else:
if request.user.is_authenticated:
@@ -183,304 +159,93 @@ def user_register(request):
return render(request, "workshop_app/registration/register.html", {"form": form})
-# This is shown to coordinator for booking workshops
-# def book(request):
-# user = request.user
-# if user.is_authenticated:
-# if is_email_checked(user):
-# if user.groups.filter(name='instructor').count() > 0:
-# return redirect('/manage/')
-#
-# workshop_details = Workshop.objects.all()
-#
-# workshop_occurence_list = []
-# today = datetime.now() + dt.timedelta(days=3)
-# upto = datetime.now() + dt.timedelta(weeks=52)
-# for workshops in workshop_details:
-# dates = workshops.recurrences.between(
-# today,
-# upto,
-# inc=True
-# )
-#
-# 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,
-# workshops.workshop_title.workshoptype_description
-# ]
-#
-# workshop_occurence_list.append(workshop_occurence)
-# del workshop_occurence
-#
-# # Gives you the objects of BookedWorkshop
-# bookedworkshop = BookedWorkshop.objects.all()
-# 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(
-# requested_workshop_coordinator=request.user
-# )
-# for r in rW_obj:
-# x = r.requested_workshop_date.strftime("%d-%m-%Y")
-# for a in workshop_occurence_list:
-# if a[0] == x:
-# workshop_occurence_list.remove(a)
-# del x
-#
-#
-# # Show upto 12 Workshops per page
-# paginator = Paginator(workshop_occurence_list, 12)
-# page = request.GET.get('page')
-# try:
-# workshop_occurences = paginator.page(page)
-# except PageNotAnInteger:
-# # If page is not an integer, deliver first page.
-# workshop_occurences = paginator.page(1)
-# except EmptyPage:
-# # If page is out of range(e.g 999999), deliver last page.
-# workshop_occurences = paginator.page(paginator.num_pages)
-#
-# return render(
-# request, "workshop_app/booking.html",
-# {"workshop_details": workshop_occurences}
-# )
-# else:
-# return redirect('/activate_user/')
-# else:
-# return redirect('/login/')
-#
-#
-# @login_required
-# def book_workshop(request):
-# '''
-# 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:]
-#
-# if client_data[-1] == '0':
-# queue = RequestedWorkshop.objects.filter(
-# requested_workshop_instructor=client_data[1],
-# requested_workshop_date=datetime.strptime(
-# client_data[0][2:], "%d-%m-%Y"
-# ),
-# requested_workshop_title=client_data[-2]
-# ).count() + 1
-#
-# return HttpResponse(str(queue))
-#
-# workshops_list = Workshop.objects.filter(
-# workshop_instructor=client_data[1],
-# workshop_title_id=client_data[2]
-# )
-# today = datetime.now() + dt.timedelta(days=3)
-# upto = datetime.now() + dt.timedelta(weeks=52)
-# for workshop in workshops_list:
-# workshop_recurrence_list = workshop.recurrences.between(
-# today,
-# upto,
-# 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(dedent("""You already have a booking
-# for this workshop please check the
-# instructors response in My Workshops tab and
-# also check your email."""))
-# else:
-# for w in workshop_recurrence_list:
-# if workshop_date == (w.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(
-# workshop_date,"%d-%m-%Y"
-# )
-# rW_obj.requested_workshop_title = workshop.workshop_title
-# rW_obj.save()
-#
-# queue = RequestedWorkshop.objects.filter(
-# requested_workshop_instructor=workshop.workshop_instructor,
-# requested_workshop_date=datetime.strptime(
-# workshop_date, "%d-%m-%Y",
-# ),
-# requested_workshop_title=client_data[-1]
-# ).count()
-#
-# # Mail to instructor
-# send_email(request, call_on='Booking',
-# user_position='instructor',
-# workshop_date=workshop_date,
-# workshop_title=workshop.workshop_title.workshoptype_name,
-# user_name=str(request.user.get_full_name()),
-# other_email=workshop.workshop_instructor.email
-# )
-# phone_number = workshop.workshop_instructor.profile.phone_number
-# #Mail to coordinator
-# send_email(request, call_on='Booking',
-# workshop_date=workshop_date,
-# workshop_title=workshop.workshop_title.workshoptype_name,
-# user_name=workshop.workshop_instructor.profile.user.get_full_name(),
-# other_email=workshop.workshop_instructor.email,
-# phone_number=phone_number)
-#
-# return HttpResponse(dedent("""\
-# Your request has been successful, Please check
-# your email for further information. Your request is number
-# {0} in the queue.""".format(str(queue))))
-# else:
-# logout(request)
-# return HttpResponse("Some Error Occurred.")
-#
-#
-# @login_required
-# def manage(request):
-# user = request.user
-#
-# if user.is_authenticated and is_email_checked(user):
-# #Move user to the group via admin
-# if user.groups.filter(name='instructor').count() > 0:
-# try:
-# #Can Handle Multiple Workshops
-# workshop_details = Workshop.objects.filter(
-# workshop_instructor=user.id
-# )
-#
-# workshop_occurence_list = []
-# today = datetime.now() + dt.timedelta(days=3)
-# upto = datetime.now() + dt.timedelta(weeks=52)
-# for workshop in workshop_details:
-# workshop_occurence = workshop.recurrences.between(
-# today,
-# upto,
-# 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
-# )
-#
-#
-# #Need to recheck logic
-# for j in range(len(requested_workshop)):
-# for i in workshop_occurence_list:
-# 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 12 Workshops per page
-# paginator = Paginator(workshop_occurence_list, 12)
-# page = request.GET.get('page')
-# try:
-# workshops = paginator.page(page)
-# except PageNotAnInteger:
-# #If page is not an integer, deliver first page.
-# workshops = paginator.page(1)
-# except EmptyPage:
-# #If page is out of range(e.g 999999), deliver last page.
-# workshops = paginator.page(paginator.num_pages)
-# except:
-# workshops = None
-#
-# return render(
-# request, "workshop_app/manage.html",
-# {"workshop_occurence_list": workshops}
-# )
-#
-# return redirect('/book/')
-# else:
-# return redirect('/activate_user/')
-#
-#
+@login_required
+def view_profile(request):
+ """ view instructor and coordinator profile """
+ user = request.user
+ if user.is_superuser:
+ return redirect('/admin')
+ return render(request, "workshop_app/view_profile.html")
+
+
+@login_required
+def edit_profile(request):
+ """ edit profile details facility for instructor and coordinator """
+
+ user = request.user
+ if user.is_superuser:
+ return redirect('/admin')
+
+ if request.method == 'POST':
+ form = ProfileForm(request.POST, user=user, instance=user.profile)
+ if form.is_valid():
+ form_data = form.save(commit=False)
+ form_data.user = user
+ form_data.user.first_name = request.POST['first_name']
+ form_data.user.last_name = request.POST['last_name']
+ form_data.user.save()
+ form_data.save()
+
+ return render(
+ request, 'workshop_app/profile_updated.html'
+ )
+ else:
+ return render(request, 'workshop_app/edit_profile.html')
+ else:
+ form = ProfileForm(user=user, instance=user.profile)
+ return render(request, 'workshop_app/edit_profile.html', {'form': form})
+
+
+# Workshop views
+
@login_required
def my_workshops(request):
user = request.user
- if user.is_authenticated and is_email_checked(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' or action == 'approve':
- workshop_status = Workshop.objects.get(id=client_data.get('workshop_id'))
+ if action == 'accept':
+ workshop = Workshop.objects.get(id=client_data.get('workshop_id'))
# Change Status of the selected workshop
- workshop_status.status = 1
- workshop_status.instructor = user
- workshop_status.save()
- ws = workshop_status
+ workshop.status = 1
+ workshop.instructor = user
+ workshop.save()
# Parameters for emails
- cmail = ws.coordinator.email
- cname = ws.coordinator.profile.user.get_full_name()
- cnum = ws.coordinator.profile.phone_number
- cinstitute = ws.coordinator.profile.institute
- inum = request.user.profile.phone_number
- wtitle = ws.workshop_type.name
- workshop_date = str(ws.date)
+ 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=wtitle,
- user_name=str(cname),
- other_email=cmail,
- phone_number=cnum,
- institute=cinstitute
+ 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=wtitle,
- other_email=cmail,
- phone_number=inum
+ 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")
- cemail = User.objects.get(id=cid)
+ coordinator_email = User.objects.get(id=cid)
today = datetime.today()
if today > new_workshop_date:
# Invalid date
@@ -490,21 +255,20 @@ def my_workshops(request):
workshop_date = workshop[0].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 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=cemail.email
- )
+ # 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
+ )
- workshops = []
today = datetime.today().date()
proposed_workshop = Workshop.objects.filter(
instructor=user.id,
@@ -516,31 +280,19 @@ def my_workshops(request):
).order_by('-date')
workshops = list(proposed_workshop) + list(proposed_workshop_pending)
- print(workshops)
-
- # team_members = list(set(user.profile.team_set.all().values_list('members', flat=True)))
- teams = Team.objects.filter(members=user.profile)
- team_workshops = []
- if teams:
- team_members = Profile.objects.filter(team__in=teams).exclude(id=user.profile.id).distinct()
- team_member_ids = team_members.values_list('user__id')
- team_workshops = Workshop.objects.filter(
- date__gte=today,
- instructor_id__in=team_member_ids,
- )
return render(request, 'workshop_app/my_workshops.html',
{"workshops": workshops,
- "team_workshops": team_workshops,
"today": today})
+ # Coordinator view
else:
workshops = Workshop.objects.filter(
coordinator=user.id
).order_by('-date')
- print(workshops)
return render(request, 'workshop_app/my_workshops.html',
{"workshops": workshops})
+ # Not logged in view
else:
return redirect('/login/')
@@ -550,570 +302,76 @@ def propose_workshop(request):
"""Coordinator proposed a workshop and date"""
user = request.user
- if is_superuser(user):
+ if user.is_superuser:
return redirect("/admin")
- if is_email_checked(user):
- if is_instructor(user):
- return redirect('/manage/')
- else:
- if request.method == 'POST':
- form = WorkshopForm(request.POST)
- if form.is_valid():
- form_data = form.save(commit=False)
- form_data.coordinator = user
- # Avoiding Duplicate workshop entries for same date and workshop_title
- if Workshop.objects.filter(
- date=form_data.date,
- workshop_type=form_data.workshop_type,
- coordinator=form_data.coordinator
- ).exists():
- return redirect('/my_workshops/')
- else:
- form_data.save()
- instructors = Profile.objects.filter(position='instructor')
- for i in instructors:
- send_email(request, call_on='Proposed Workshop',
- user_position='instructor',
- workshop_date=str(form_data.date),
- workshop_title=form_data.title,
- user_name=str(user.get_full_name()),
- other_email=i.user.email,
- phone_number=user.profile.phone_number,
- institute=user.profile.institute
- )
- return redirect('/my_workshops/')
- else:
- form = WorkshopForm()
- return render(
- request, 'workshop_app/propose_workshop.html',
- {"form": form}
- )
- else:
- return render(request, 'workshop_app/activation.html')
-
-
-@login_required
-def view_profile(request):
- """ view instructor and coordinator profile """
- user = request.user
- if is_superuser(user):
- return redirect('/admin')
- if is_email_checked(user) and user.is_authenticated:
- return render(request, "workshop_app/view_profile.html")
- else:
- if user.is_authenticated:
- return render(request, 'workshop_app/activation.html')
- else:
- try:
- logout(request)
- return redirect('/login/')
- except:
- return redirect('/register/')
-
-
-@login_required
-def edit_profile(request):
- """ edit profile details facility for instructor and coordinator """
-
- user = request.user
- if is_superuser(user):
- return redirect('/admin')
- if is_email_checked(user):
- if is_instructor(user):
- template = 'workshop_app/manage.html'
- else:
- template = 'workshop_app/booking.html'
- else:
- try:
- logout(request)
- return redirect('/login/')
- except:
- return redirect('/register/')
-
- context = {'template': template}
- if has_profile(user) and is_email_checked(user):
- profile = Profile.objects.get(user_id=user.id)
- else:
- profile = None
-
- if request.method == 'POST':
- form = ProfileForm(request.POST, user=user, instance=profile)
- if form.is_valid():
- form_data = form.save(commit=False)
- form_data.user = user
- form_data.user.first_name = request.POST['first_name']
- form_data.user.last_name = request.POST['last_name']
- form_data.user.save()
- form_data.save()
-
- return render(
- request, 'workshop_app/profile_updated.html'
- )
- else:
- context['form'] = form
- return render(request, 'workshop_app/edit_profile.html', context)
+ if is_instructor(user):
+ return redirect(get_landing_page(user))
else:
- form = ProfileForm(user=user, instance=profile)
- return render(request, 'workshop_app/edit_profile.html', {'form': form})
-
-
-@login_required
-def create_workshop(request):
- '''Instructor creates workshops'''
-
- user = request.user
- if is_superuser(user):
- return redirect("/admin")
- if is_instructor(user) and is_email_checked(user):
if request.method == 'POST':
- form = CreateWorkshop(request.POST)
+ form = WorkshopForm(request.POST)
if form.is_valid():
form_data = form.save(commit=False)
- # form_data.profile_id = profile.id
- form_data.workshop_instructor = user
- form_data.workshop_instructor.save()
- form_data.save()
- return redirect('/manage/')
- else:
- form = CreateWorkshop()
+ form_data.coordinator = user
+ # Avoiding Duplicate workshop entries for same date and workshop_title
+ if Workshop.objects.filter(
+ date=form_data.date,
+ workshop_type=form_data.workshop_type,
+ coordinator=form_data.coordinator
+ ).exists():
+ return redirect('/my_workshops/')
+ else:
+ form_data.save()
+ instructors = Profile.objects.filter(position='instructor')
+ for i in instructors:
+ send_email(request, call_on='Proposed Workshop',
+ user_position='instructor',
+ workshop_date=str(form_data.date),
+ workshop_title=form_data.workshop_type,
+ user_name=str(user.get_full_name()),
+ other_email=i.user.email,
+ phone_number=user.profile.phone_number,
+ institute=user.profile.institute
+ )
+ return redirect('/my_workshops/')
+ # GET request
+ form = WorkshopForm()
return render(
- request, 'workshop_app/create_workshop.html',
+ request, 'workshop_app/propose_workshop.html',
{"form": form}
)
- else:
- return redirect('/book/')
-def view_workshoptype_details(request, workshoptype_id):
- '''Gives the types of workshop details '''
+def workshop_type_details(request, workshop_type_id):
+ """Gives the types of workshop details """
user = request.user
- if is_superuser(user):
+ if user.is_superuser:
return redirect("/admin")
- view_workshoptype_details = WorkshopType.objects.get(id=workshoptype_id)
+ workshop_type = WorkshopType.objects.get(id=workshop_type_id)
return render(
- request, 'workshop_app/view_workshoptype_details.html', \
- {'workshoptype': view_workshoptype_details}
+ request, 'workshop_app/workshop_type_details.html', {'workshop_type': workshop_type}
)
-def view_workshoptype_list(request):
- '''Gives the details for types of workshops.'''
+def workshop_type_list(request):
+ """Gives the details for types of workshops."""
user = request.user
- if is_superuser(user):
+ if user.is_superuser:
return redirect("/admin")
- workshoptype_list = WorkshopType.objects.all()
+ workshop_types = WorkshopType.objects.all()
- paginator = Paginator(workshoptype_list, 12) # Show upto 12 workshops per page
+ paginator = Paginator(workshop_types, 12) # Show upto 12 workshops per page
page = request.GET.get('page')
try:
- workshoptype = paginator.page(page)
+ workshop_type = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
- workshoptype = paginator.page(1)
+ workshop_type = paginator.page(1)
except EmptyPage:
# If page is out of range(e.g 999999), deliver last page.
- workshoptype = paginator.page(paginator.num_pages)
-
- return render(
- request, 'workshop_app/view_workshoptype_list.html', \
- {'workshoptype': workshoptype}
- )
-
-
-def faq(request):
- return render(request, 'workshop_app/view_faq.html')
-
-
-def how_to_participate(request):
- return render(request, 'workshop_app/how_to_participate.html')
-
-
-def file_view(request, workshop_title):
- if workshop_title == 'flowchart':
- return render(request, 'workshop_app/how_to_participate.html')
- else:
- filename = WorkshopType.objects.get(id=workshop_title)
- attachment_path = path.dirname(filename.workshoptype_attachments.path)
- zipfile_name = string_io()
- zipfile = ZipFile(zipfile_name, "w")
- attachments = listdir(attachment_path)
- for file in attachments:
- file_path = sep.join((attachment_path, file))
- zipfile.write(file_path, path.basename(file_path))
- zipfile.close()
- zipfile_name.seek(0)
- response = HttpResponse(content_type='application/zip')
- response['Content-Disposition'] = 'attachment; filename={0}.zip'.format(
- filename.workshoptype_name.replace(" ", "_")
- )
- response.write(zipfile_name.read())
- return response
-
-
-def check_workshop_type(x):
- try:
- y = datetime.strftime(x.proposed_workshop_date, '%d-%m-%Y')
- except:
- y = datetime.strftime(x.requested_workshop_date, '%d-%m-%Y')
- return y
+ workshop_type = paginator.page(paginator.num_pages)
-# @login_required
-# def workshop_stats(request):
-# user = request.user
-# today = datetime.now()
-# upto = today + dt.timedelta(days=120)
-#
-# #For Monthly Chart
-# workshop_count = [0] * 12
-# for x in range(12):
-# workshop_count[x] +=RequestedWorkshop.objects.filter(
-# requested_workshop_date__year=str(today.year),
-# requested_workshop_date__month=str(x+1),
-# status='ACCEPTED').count()
-# workshop_count[x] +=ProposeWorkshopDate.objects.filter(
-# proposed_workshop_date__year=str(today.year),
-# proposed_workshop_date__month=str(x+1),
-# status='ACCEPTED').count()
-#
-# # Count Total Number of workshops for each type
-# workshop_titles = WorkshopType.objects.all()
-# workshoptype_dict = {}
-# for title in workshop_titles:
-# workshoptype_dict[title]=0
-#
-# for title in workshoptype_dict.keys():
-# workshoptype_dict[title] += RequestedWorkshop.objects.filter(
-# requested_workshop_title=title,
-# status='ACCEPTED').count()
-# workshoptype_dict[title] += ProposeWorkshopDate.objects.filter(
-# proposed_workshop_title=title,
-# status='ACCEPTED').count()
-# #For Pie Chart
-# workshoptype_num = []
-# workshoptype_title = []
-# for title in workshoptype_dict.keys():
-# workshoptype_title.append(str(title))
-#
-# for count in workshoptype_dict.values():
-# workshoptype_num.append(count)
-#
-# workshoptype_count = [workshoptype_title, workshoptype_num]
-# del workshoptype_title, workshoptype_num
-#
-# # For India Map
-# states = [
-# ['Code', 'State', 'Number'],
-# ["IN-AP", "Andhra Pradesh", 0],
-# ["IN-AR", "Arunachal Pradesh", 0],
-# ["IN-AS", "Assam", 0],
-# ["IN-BR", "Bihar", 0],
-# ["IN-CT", "Chhattisgarh", 0],
-# ["IN-GA", "Goa", 0],
-# ["IN-GJ", "Gujarat", 0],
-# ["IN-HR", "Haryana", 0],
-# ["IN-HP", "Himachal Pradesh", 0],
-# ["IN-JK", "Jammu and Kashmir", 0],
-# ["IN-JH", "Jharkhand", 0],
-# ["IN-KA", "Karnataka", 0],
-# ["IN-KL", "Kerala", 0],
-# ["IN-MP", "Madhya Pradesh", 0],
-# ["IN-MH", "Maharashtra", 0],
-# ["IN-MN", "Manipur", 0],
-# ["IN-ML", "Meghalaya", 0],
-# ["IN-MZ", "Mizoram", 0],
-# ["IN-NL", "Nagaland", 0],
-# ["IN-OR", "Odisha", 0],
-# ["IN-PB", "Punjab", 0],
-# ["IN-RJ", "Rajasthan", 0],
-# ["IN-SK", "Sikkim", 0],
-# ["IN-TN", "Tamil Nadu", 0],
-# ["IN-TG", "Telangana", 0],
-# ["IN-TR", "Tripura", 0],
-# ["IN-UT", "Uttarakhand", 0],
-# ["IN-UP", "Uttar Pradesh", 0],
-# ["IN-WB", "West Bengal", 0],
-# ["IN-AN", "Andaman and Nicobar Islands", 0],
-# ["IN-CH", "Chandigarh", 0],
-# ["IN-DN", "Dadra and Nagar Haveli", 0],
-# ["IN-DD", "Daman and Diu", 0],
-# ["IN-DL", "Delhi", 0],
-# ["IN-LD", "Lakshadweep", 0],
-# ["IN-PY", "Puducherry", 0]
-# ]
-#
-# workshop_state = []
-# requestedWorkshops = RequestedWorkshop.objects.filter(status='ACCEPTED')
-# proposedWorkshops = ProposeWorkshopDate.objects.filter(status='ACCEPTED')
-# for workshop in requestedWorkshops:
-# for s in states:
-# if s[0] == workshop.requested_workshop_coordinator.profile.state:
-# s[2] +=1
-#
-# for workshop in proposedWorkshops:
-# for s in states:
-# if s[0] == workshop.proposed_workshop_coordinator.profile.state:
-# s[2] +=1
-#
-# #For Data Downloading and Viewing
-# if request.method == 'POST':
-# try:
-# from_dates = request.POST.get('from')
-# to_dates = request.POST.get('to')
-#
-# #Fetches Accepted workshops which were proposed by Coordinators
-# proposed_workshops = ProposeWorkshopDate.objects.filter(
-# proposed_workshop_date__range=(from_dates, to_dates),
-# status='ACCEPTED'
-# )
-#
-# # Fetches Accepted workshops which were Accepted by
-# # Instructors based on their Availability
-# requested_workshops = RequestedWorkshop.objects.filter(
-# requested_workshop_date__range=(from_dates, to_dates),
-# status='ACCEPTED'
-# )
-#
-# upcoming_workshops = []
-#
-# for workshop in proposed_workshops:
-# upcoming_workshops.append(workshop)
-#
-# for workshop in requested_workshops:
-# upcoming_workshops.append(workshop)
-#
-# upcoming_workshops = sorted(upcoming_workshops,
-# key=lambda x: check_workshop_type(x))
-#
-# download = request.POST.get('Download')
-# if download:
-# response = HttpResponse(content_type='text/csv')
-#
-# response['Content-Disposition'] = 'attachment;\
-# filename="records_from_{0}_to_{1}.csv"'.format(
-# from_dates,to_dates
-# )
-#
-# writer = csv.writer(response)
-# header = [
-# 'coordinator name',
-# 'instructor name',
-# 'workshop',
-# 'date',
-# 'status',
-# 'institute name'
-# ]
-#
-# writer.writerow(header)
-#
-# for workshop in upcoming_workshops:
-# try:
-# row = [
-# workshop.proposed_workshop_coordinator,
-# workshop.proposed_workshop_instructor,
-# workshop.proposed_workshop_title,
-# workshop.proposed_workshop_date,
-# workshop.status,
-# workshop.proposed_workshop_coordinator.profile.institute
-# ]
-#
-# except:
-# row = [
-# workshop.requested_workshop_coordinator,
-# workshop.requested_workshop_instructor,
-# workshop.requested_workshop_title,
-# workshop.requested_workshop_date,
-# workshop.status,
-# workshop.requested_workshop_coordinator.profile.institute
-# ]
-#
-# writer.writerow(row)
-# return response
-# else:
-# return render(request, 'workshop_app/workshop_stats.html',
-# {
-# "upcoming_workshops": upcoming_workshops,
-# "show_workshop_stats": settings.SHOW_WORKSHOP_STATS,
-# "workshop_count": workshop_count,
-# "workshoptype_count": workshoptype_count,
-# "india_map": states
-# })
-# except:
-# messages.info(request, 'Please enter Valid Dates')
-#
-# if is_instructor(user) and is_email_checked(user):
-# try:
-# #Fetches Accepted workshops which were proposed by Coordinators
-# proposed_workshops = ProposeWorkshopDate.objects.filter(
-# proposed_workshop_date__range=(today, upto),
-# status='ACCEPTED'
-# )
-#
-# #Fetches Accepted workshops which were Accepted by
-# # Instructors based on their Availability
-# requested_workshops = RequestedWorkshop.objects.filter(
-# requested_workshop_date__range=(today, upto),
-# status='ACCEPTED'
-# )
-#
-# upcoming_workshops = []
-# for workshop in proposed_workshops:
-# upcoming_workshops.append(workshop)
-#
-# for workshop in requested_workshops:
-# upcoming_workshops.append(workshop)
-#
-# upcoming_workshops = sorted(upcoming_workshops,
-# key=lambda x: check_workshop_type(x))
-#
-# except:
-# upcoming_workshops = None
-#
-# paginator = Paginator(upcoming_workshops, 12)
-#
-# page = request.GET.get('page')
-# try:
-# upcoming_workshops = paginator.page(page)
-# except PageNotAnInteger:
-# #If page is not an integer, deliver first page.
-# upcoming_workshops = paginator.page(1)
-# except EmptyPage:
-# #If page is out of range(e.g 999999), deliver last page.
-# upcoming_workshops = paginator.page(paginator.num_pages)
-#
-#
-# return render(request, 'workshop_app/workshop_stats.html',
-# {
-# "upcoming_workshops": upcoming_workshops,
-# "show_workshop_stats": settings.SHOW_WORKSHOP_STATS,
-# "workshop_count": workshop_count,
-# "workshoptype_count": workshoptype_count,
-# "india_map": states
-# })
-# else:
-# return redirect('/manage/')
-#
-#
-# def self_workshop(request):
-# return render(request, "workshop_app/self_workshop.html")
-#
-#
-#
-# @login_required
-# def view_comment_profile(request, user_id):
-# '''instructor can view/post comments on coordinator profile '''
-# user = request.user
-# if is_instructor(user) and is_email_checked(user):
-# comment_form = ProfileCommentsForm()
-# coordinator_profile = Profile.objects.get(user_id=user_id)
-# requested_workshop = RequestedWorkshop.objects.filter(requested_workshop_coordinator=user_id).order_by(
-# 'requested_workshop_title')
-# propose_workshop = ProposeWorkshopDate.objects.filter(proposed_workshop_coordinator=user_id).order_by(
-# 'proposed_workshop_date')
-# workshops=[]
-# for workshop in propose_workshop:
-# workshops.append(workshop)
-#
-# for workshop in requested_workshop:
-# workshops.append(workshop)
-# try:
-# comments = ProfileComments.objects.filter(coordinator_profile_id=user_id).order_by('-created_date')
-# except:
-# comments = None
-# if request.method == 'POST':
-# comment_formpost = ProfileCommentsForm(request.POST)
-# if comment_formpost.is_valid():
-# form_data = comment_formpost.save(commit=False)
-# form_data.coordinator_profile_id = user_id
-# form_data.instructor_profile_id = user.id
-# form_data.save()
-#
-# return render(request, "workshop_app/view_comment_profile.html",
-# {"coordinator_profile": coordinator_profile,
-# "comments": comments,
-# "comment_form": comment_form
-# })
-# else:
-# if comments is not None:
-# #Show upto 12 Workshops per page
-# paginator = Paginator(comments, 12)
-# page = request.GET.get('page')
-# try:
-# comments = paginator.page(page)
-# except PageNotAnInteger:
-# #If page is not an integer, deliver first page.
-# comments = paginator.page(1)
-# except EmptyPage:
-# #If page is out of range(e.g 999999), deliver last page.
-# comments = paginator.page(paginator.num_pages)
-# workshop={}
-# return render(request, "workshop_app/view_comment_profile.html",
-# {"coordinator_profile": coordinator_profile,
-# "comments": comments,
-# "comment_form": comment_form,
-# "Workshops":workshops})
-# return redirect('/book/')
-#
-# @login_required
-# def download_csv_data(request):
-# user=request.user
-# if user.profile.position == 'instructor':
-# requested_workshop = RequestedWorkshop.objects.filter(requested_workshop_instructor=user.id).order_by(
-# 'requested_workshop_title')
-# propose_workshop = ProposeWorkshopDate.objects.filter(proposed_workshop_instructor=user.id).order_by(
-# 'proposed_workshop_date')
-# upcoming_workshops = []
-# for workshop in propose_workshop:
-# upcoming_workshops.append(workshop)
-#
-# for workshop in requested_workshop:
-# upcoming_workshops.append(workshop)
-#
-# response = HttpResponse(content_type='text/csv')
-#
-# response['Content-Disposition'] = 'attachment;\
-# filename="records_of_{0}.csv"'.format(
-# user.username
-# )
-#
-# writer = csv.writer(response)
-# header = [
-# 'coordinator name',
-# 'instructor name',
-# 'workshop',
-# 'date',
-# 'status',
-# 'institute name'
-# ]
-#
-# writer.writerow(header)
-#
-# for workshop in upcoming_workshops:
-# try:
-# row = [
-# workshop.proposed_workshop_coordinator,
-# workshop.proposed_workshop_instructor,
-# workshop.proposed_workshop_title,
-# workshop.proposed_workshop_date,
-# workshop.status,
-# workshop.proposed_workshop_coordinator.profile.institute
-# ]
-#
-# except:
-# row = [
-# workshop.requested_workshop_coordinator,
-# workshop.requested_workshop_instructor,
-# workshop.requested_workshop_title,
-# workshop.requested_workshop_date,
-# workshop.status,
-# workshop.requested_workshop_coordinator.profile.institute
-# ]
-#
-# writer.writerow(row)
-# return response
-#
-# else:
-# return redirect('/book/')
+ return render(request, 'workshop_app/workshop_type_list.html', {'workshop_type': workshop_type})