summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--workshop_app/templates/workshop_app/my_workshops.html36
-rw-r--r--workshop_app/templates/workshop_app/propose_workshop.html10
-rw-r--r--workshop_app/templates/workshop_app/view_profile.html124
-rw-r--r--workshop_app/urls.py1
-rw-r--r--workshop_app/views.py22
5 files changed, 104 insertions, 89 deletions
diff --git a/workshop_app/templates/workshop_app/my_workshops.html b/workshop_app/templates/workshop_app/my_workshops.html
index f39c8e8..b6e3731 100644
--- a/workshop_app/templates/workshop_app/my_workshops.html
+++ b/workshop_app/templates/workshop_app/my_workshops.html
@@ -101,13 +101,13 @@
{% 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 }}">
+ <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.title |capfirst }}</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"
@@ -132,38 +132,6 @@
{% endif %}
<td><span class="badge badge-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="badge badge-success">{{ workshop.status }}</span></td>
- {% endif %}
</tr>
</tbody>
diff --git a/workshop_app/templates/workshop_app/propose_workshop.html b/workshop_app/templates/workshop_app/propose_workshop.html
index 0f02c34..678d11e 100644
--- a/workshop_app/templates/workshop_app/propose_workshop.html
+++ b/workshop_app/templates/workshop_app/propose_workshop.html
@@ -60,7 +60,15 @@
{{ form.date }}
<br>
{{ form.tnc_accepted }} I accept the <a href="/tnc">terms and conditions</a>
- <br><br>
+ <br>
+ {% if form.errors %}
+ <br>
+ <div style="text-align: left; border: 1px solid red; padding-top: 5px">
+ <h5 style="text-align: center; color: red; font-weight: bolder">Errors</h5>
+ {{ form.errors }}
+ </div>
+ {% endif %}
+ <br>
<button class="btn btn-success" type="submit">Submit</button>
</form>
</div>
diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html
index 6be4b7e..9330cb0 100644
--- a/workshop_app/templates/workshop_app/view_profile.html
+++ b/workshop_app/templates/workshop_app/view_profile.html
@@ -1,62 +1,84 @@
{% extends 'workshop_app/base.html' %}
{% block title %}
- View Profile
+ Coordinator Profile
{% endblock %}
- {% block extra %}
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
- <script src="{{URL_ROOT}}/static/workshop_app/js/bootstrap-3.3.7.min.js"></script>
- {% endblock %}
+{% block extra %}
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
+ <script src="{{ URL_ROOT }}/static/workshop_app/js/bootstrap-3.3.7.min.js"></script>
+{% endblock %}
{% csrf_token %}
{% block content %}
- <div class="container">
- <table class="table table-bordered">
- <tr>
- <th><label for="id_first_name"><h5>First name:</h5></label></th>
- <th><label for="id_first_name"><h5>{{ user.first_name }}</h5></label></th>
- </tr>
- <tr>
- <th><label for="id_last_name"><h5>Last name:</h5></label></th>
- <th><label for="id_last_name"><h5>{{ user.last_name }}</h5></label></th>
- </tr>
- <tr>
- <th><label for="id_email"><h5>Email:</h5></label></th>
- <th><label for="id_email"><h5>{{ user.email }}</h5></label></th>
- </tr>
- <tr>
- <th><label for="id_institute"><h5>Institute:</h5></label></th>
- <th><label for="id_institute"><h5>{{ user.profile.institute }}</h5></label></th>
- </tr>
- <tr>
- <th><label for="id_phone_number"><h5>Phone Number:</h5></label></th>
- <th><label for="id_phone_number"><h5>{{ user.profile.phone_number }}</h5></label></th>
- </tr>
- <tr>
- <th><label for="id_department"><h5>Department:</h5></label></th>
- <th><label for="id_department"><h5>{{ user.profile.department }}</h5></label></th>
- </tr>
- <tr>
- <th><label for="id_location"><h5>Location:</h5></label></th>
- <th><label for="id_location"><h5>{{ user.profile.location }}</h5></label></th>
- </tr>
- <tr>
- <th><label for="id_position"><h5>Position:</h5></label></th>
- <th><label for="id_position"><h5>{{ user.profile.position }}</h5></label></th>
- </tr>
- </table>
- <br>
- <a class="btn btn-primary" href="{{ URL_ROOT }}/edit_profile/">Edit Profile</a>
- {% if user.profile.position == 'instructor' %}
- <a class="btn btn-primary " href="{{ URL_ROOT }}/download/">Download Workshop</a>
- {% endif %}
-
-
- </div>
-
-
-
+ <div class="container">
+ <table class="table table-bordered">
+ <tr>
+ <th><label for="id_first_name"><h5>First name:</h5></label></th>
+ <th><label for="id_first_name"><h5>{{ coordinator_profile.user.first_name }}</h5></label></th>
+ </tr>
+ <tr>
+ <th><label for="id_last_name"><h5>Last name:</h5></label></th>
+ <th><label for="id_last_name"><h5>{{ coordinator_profile.user.last_name }}</h5></label></th>
+ </tr>
+ <tr>
+ <th><label for="id_email"><h5>Email:</h5></label></th>
+ <th><label for="id_email"><h5>{{ coordinator_profile.user.email }}</h5></label></th>
+ </tr>
+ <tr>
+ <th><label for="id_institute"><h5>Institute:</h5></label></th>
+ <th><label for="id_institute"><h5>{{ coordinator_profile.user.profile.institute }}</h5></label></th>
+ </tr>
+ <tr>
+ <th><label for="id_phone_number"><h5>Phone Number:</h5></label></th>
+ <th><label for="id_phone_number"><h5>{{ coordinator_profile.user.profile.phone_number }}</h5></label>
+ </th>
+ </tr>
+ <tr>
+ <th><label for="id_department"><h5>Department:</h5></label></th>
+ <th><label for="id_department"><h5>{{ coordinator_profile.user.profile.department }}</h5></label></th>
+ </tr>
+ <tr>
+ <th><label for="id_location"><h5>Location:</h5></label></th>
+ <th><label for="id_location"><h5>{{ coordinator_profile.user.profile.location }}</h5></label></th>
+ </tr>
+ <tr>
+ <th><label for="id_position"><h5>Position:</h5></label></th>
+ <th><label for="id_position"><h5>{{ coordinator_profile.user.profile.position }}</h5></label></th>
+ </tr>
+ </table>
+ <br>
+ <div class="container">
+ <h2>Workshop Details</h2>
+ <table class="table table-bordered">
+ <tr>
+ <th><label for="id_instructor_name">Instructor name</label></th>
+ <th><label for="id_workshop_date">Workshop date</label></th>
+ <th><label for="id_workshop_type">Workshop type</label></th>
+ </tr>
+ {% for workshop in Workshops %}
+ {% if workshop.instructor %}
+ <tr>
+ <td><label for="id_instructor_name">{{ workshop.instructor }}
+ </label></td>
+ <td><label for="id_workshop_date">{{ workshop.date }}</label>
+ </td>
+ <td><label for="id_workshop_type">{{ workshop.workshop_type }}</label>
+ </td>
+ </tr>
+ {% else %}
+ <tr>
+ <td><span class="badge badge-warning">Pending</span></td>
+ <td><label for="id_workshop_date">{{ workshop.date }}</label>
+ </td>
+ <td><label for="id_workshop_type">{{ workshop.workshop_type }}</label>
+ </td>
+ </tr>
+ {% endif %}
+ {% endfor %}
+ </table>
+ </div>
+ </div>
{% endblock %}
diff --git a/workshop_app/urls.py b/workshop_app/urls.py
index 68884f3..4bb140c 100644
--- a/workshop_app/urls.py
+++ b/workshop_app/urls.py
@@ -33,4 +33,5 @@ urlpatterns = [
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 5c82d9d..c823db7 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -36,7 +36,7 @@ def is_email_checked(user):
def is_instructor(user):
"""Check if the user is having instructor rights"""
- user.groups.filter(name='instructor').exists()
+ return user.groups.filter(name='instructor').exists()
def get_landing_page(user):
@@ -194,7 +194,6 @@ def edit_profile(request):
# Workshop views
-# TODO: View and comment profile view for instructors
@login_required
def my_workshops(request):
user = request.user
@@ -202,6 +201,7 @@ def my_workshops(request):
if user.is_authenticated:
# View for instructor
if is_instructor(user):
+ print('inst')
if request.method == 'POST':
client_data = request.POST
action = request.POST.get('action')
@@ -305,6 +305,7 @@ def propose_workshop(request):
if is_instructor(user):
return redirect(get_landing_page(user))
else:
+ form = WorkshopForm()
if request.method == 'POST':
form = WorkshopForm(request.POST)
if form.is_valid():
@@ -332,7 +333,7 @@ def propose_workshop(request):
)
return redirect('/my_workshops/')
# GET request
- form = WorkshopForm()
+ print(form.errorlist_css_class)
return render(
request, 'workshop_app/propose_workshop.html',
{"form": form}
@@ -373,3 +374,18 @@ def workshop_type_list(request):
workshop_type = paginator.get_page(paginator.num_pages)
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 """
+ user = request.user
+ if is_instructor(user) and is_email_checked(user):
+ coordinator_profile = Profile.objects.get(user_id=user_id)
+ workshops = Workshop.objects.filter(coordinator=user_id).order_by(
+ 'date')
+
+ return render(request, "workshop_app/view_profile.html",
+ {"coordinator_profile": coordinator_profile,
+ "Workshops": workshops})
+ return redirect(get_landing_page(user))