diff options
-rw-r--r-- | workshop_app/templates/workshop_app/view_profile.html | 57 | ||||
-rw-r--r-- | workshop_app/urls.py | 4 | ||||
-rw-r--r-- | workshop_app/views.py | 12 |
3 files changed, 43 insertions, 30 deletions
diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html index f597e65..31215fe 100644 --- a/workshop_app/templates/workshop_app/view_profile.html +++ b/workshop_app/templates/workshop_app/view_profile.html @@ -44,35 +44,38 @@ </tr> </table> <br> - <div class="container"> + + {% if Workshops %} + <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> + <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 %} + {% endif %} + </table> </div> </div> {% endblock %} diff --git a/workshop_app/urls.py b/workshop_app/urls.py index f9c7877..0acdf90 100644 --- a/workshop_app/urls.py +++ b/workshop_app/urls.py @@ -23,7 +23,6 @@ urlpatterns = [ url(r'^activate_user/$', views.activate_user), url(r'^login/$', views.user_login), url(r'^logout/$', views.user_logout), - url(r'^view_profile/$', views.view_profile), url(r'^edit_profile/$', views.edit_profile), url(r'^workshop_status$', views.workshop_status_coordinator, name='workshop_status_coordinator'), url(r'^dashboard$', views.workshop_status_instructor, name='workshop_status_instructor'), @@ -36,5 +35,6 @@ urlpatterns = [ url(r'^add_workshop_type$', views.add_workshop_type, name='add_workshop_type'), url(r'^delete_attachment_file/(?P<file_id>\d+)$', views.delete_attachment_file, name='delete_attachment_file'), url(r'^workshop_types/$', views.workshop_type_list, name='workshop_type_list'), - url(r'^view_profile/(?P<user_id>\d+)$', views.view_comment_profile, name='view_profile'), + url(r'^view_profile/$', views.view_own_profile, name='view_own_profile'), + url(r'^view_profile/(?P<user_id>\d+)$', views.view_profile, name='view_profile'), ] diff --git a/workshop_app/views.py b/workshop_app/views.py index 3f24a2f..6f063e7 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -457,7 +457,7 @@ def add_workshop_type(request): @login_required -def view_comment_profile(request, user_id): +def view_profile(request, user_id): """Instructor can view coordinator profile """ user = request.user if is_instructor(user) and is_email_checked(user): @@ -469,3 +469,13 @@ def view_comment_profile(request, user_id): {"coordinator_profile": coordinator_profile, "Workshops": workshops}) return redirect(get_landing_page(user)) + + +@login_required +def view_own_profile(request): + """User can view own profile """ + user = request.user + coordinator_profile = Profile.objects.get(user=user) + + return render(request, "workshop_app/view_profile.html", + {"coordinator_profile": coordinator_profile, "Workshops": None}) |