diff options
-rw-r--r-- | local_settings.py | 10 | ||||
-rw-r--r-- | statistics_app/views.py | 1 | ||||
-rw-r--r-- | workshop_app/templates/workshop_app/view_comment_profile.html | 26 | ||||
-rw-r--r-- | workshop_app/templates/workshop_app/view_profile.html | 8 | ||||
-rw-r--r-- | workshop_app/urls.py | 1 | ||||
-rw-r--r-- | workshop_app/views.py | 68 |
6 files changed, 107 insertions, 7 deletions
diff --git a/local_settings.py b/local_settings.py index 940a33e..a6e8a51 100644 --- a/local_settings.py +++ b/local_settings.py @@ -2,9 +2,9 @@ # db etc. -EMAIL_HOST = 'your smtp host name' -EMAIL_PORT = 'PORT Number' -EMAIL_HOST_USER = 'your username' -EMAIL_HOST_PASSWORD = 'your password' +EMAIL_HOST = 'smtp.gmail.com' +EMAIL_PORT = '465' +EMAIL_HOST_USER = 'borajay33@gmail.com' +EMAIL_HOST_PASSWORD = '123J@ybora' EMAIL_USE_TLS = True -SENDER_EMAIL = 'your email address'
\ No newline at end of file +SENDER_EMAIL = 'borajay33@gmail.com'
\ No newline at end of file diff --git a/statistics_app/views.py b/statistics_app/views.py index 1507196..02135c4 100644 --- a/statistics_app/views.py +++ b/statistics_app/views.py @@ -527,6 +527,7 @@ def workshop_public_stats(request): @login_required def profile_stats(request): user = request.user + print is_instructor(user) if is_instructor(user) and is_email_checked(user): profiles = Profile.objects.all() diff --git a/workshop_app/templates/workshop_app/view_comment_profile.html b/workshop_app/templates/workshop_app/view_comment_profile.html index ed7e547..68855a2 100644 --- a/workshop_app/templates/workshop_app/view_comment_profile.html +++ b/workshop_app/templates/workshop_app/view_comment_profile.html @@ -48,7 +48,31 @@ <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"><h5>Instructor name</h5></label></th> + <th><label for="id_workshop_date"><h5>Workshop date</h5></label></th> + <th><label for="id_workshop_type"><h5>Workshop type</h5></label></th> + </tr> + {% for foo in Requested_Workshop %} + <tr> + <td><label for="id_instructor_name"><h5>{{ foo.requested_workshop_instructor }}</h5></label></td> + <td><label for="id_workshop_date"><h5>{{ foo.requested_workshop_date }}</h5></label></td> + <td><label for="id_workshop_type"><h5>{{ foo.requested_workshop_title }}</h5></label></td> + </tr> + {% endfor %} + {% for bar in Proposed_workshop %} + <tr> + <td><label for="id_instructor_name"><h5>{{ bar.proposed_workshop_instructor }}</h5></label></td> + <td><label for="id_workshop_date"><h5>{{ bar.proposed_workshop_date }}</h5></label></td> + <td><label for="id_workshop_type"><h5>{{ bar.proposed_workshop_title }}</h5></label></td> + </tr> + {% endfor %} + </table> + </div> <br> <h1 style="color:#2c5aa0">Comments</h1> <div> diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html index 6a35890..95547cb 100644 --- a/workshop_app/templates/workshop_app/view_profile.html +++ b/workshop_app/templates/workshop_app/view_profile.html @@ -50,5 +50,13 @@ </table> <br> <a class="btn btn-primary pull-right" href="{{ URL_ROOT }}/edit_profile/">Edit Profile</a> + {% if user.profile.position == 'instructor' %} + <a class="btn btn-primary pull-right" href="{{ URL_ROOT }}/Download/">Download Workshop</a> + {% endif %} + + </div> + + + {% endblock %} diff --git a/workshop_app/urls.py b/workshop_app/urls.py index 154915d..2c6c380 100644 --- a/workshop_app/urls.py +++ b/workshop_app/urls.py @@ -45,5 +45,6 @@ urlpatterns = [ 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), ] diff --git a/workshop_app/views.py b/workshop_app/views.py index 76edc95..ad02dc0 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -1190,6 +1190,10 @@ def view_comment_profile(request, user_id): 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') try: comments = ProfileComments.objects.filter(coordinator_profile_id=user_id).order_by('-created_date') except: @@ -1224,6 +1228,68 @@ def view_comment_profile(request, user_id): return render(request, "workshop_app/view_comment_profile.html", {"coordinator_profile": coordinator_profile, "comments": comments, - "comment_form": comment_form}) + "comment_form": comment_form, + "Proposed_workshop":propose_workshop, + "Requested_Workshop":requested_workshop}) 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/') |