diff options
author | Akshen | 2019-03-04 14:13:33 +0530 |
---|---|---|
committer | GitHub | 2019-03-04 14:13:33 +0530 |
commit | 6c149dfbd2075d16a5a01ede8688e4c7afd99a31 (patch) | |
tree | 6d0fff8ae5707a3858b516fd333682a23bf0babf | |
parent | 52a37c1512b249f6f1820b49ac8e021c91bdb433 (diff) | |
parent | c980565c107d09b6d779d143e2ad23fc396c2d93 (diff) | |
download | workshop_booking-6c149dfbd2075d16a5a01ede8688e4c7afd99a31.tar.gz workshop_booking-6c149dfbd2075d16a5a01ede8688e4c7afd99a31.tar.bz2 workshop_booking-6c149dfbd2075d16a5a01ede8688e4c7afd99a31.zip |
Merge pull request #85 from HackNet1997/Download_csv
Download csv
-rw-r--r-- | local_settings.py | 10 | ||||
-rw-r--r-- | workshop_app/templates/workshop_app/view_comment_profile.html | 27 | ||||
-rw-r--r-- | workshop_app/templates/workshop_app/view_profile.html | 10 | ||||
-rw-r--r-- | workshop_app/urls.py | 1 | ||||
-rw-r--r-- | workshop_app/urls_password_reset.py | 2 | ||||
-rw-r--r-- | workshop_app/views.py | 75 |
6 files changed, 115 insertions, 10 deletions
diff --git a/local_settings.py b/local_settings.py index 940a33e..cebe07c 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 = 'YOUR HOST' +EMAIL_PORT = 'YOUR HOST PORT' +EMAIL_HOST_USER = 'Your mail' +EMAIL_HOST_PASSWORD = 'Your Password' EMAIL_USE_TLS = True -SENDER_EMAIL = 'your email address'
\ No newline at end of file +SENDER_EMAIL = 'YOUR PRODUCTION MAIL'
\ No newline at end of file diff --git a/workshop_app/templates/workshop_app/view_comment_profile.html b/workshop_app/templates/workshop_app/view_comment_profile.html index ed7e547..25596c7 100644 --- a/workshop_app/templates/workshop_app/view_comment_profile.html +++ b/workshop_app/templates/workshop_app/view_comment_profile.html @@ -48,7 +48,32 @@ <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 workshop in Workshops%} + {% if workshop.proposed_workshop_date %} + <tr> + <td><label for="id_instructor_name"><h5>{{ workshop.proposed_workshop_instructor }}</h5></label></td> + <td><label for="id_workshop_date"><h5>{{ workshop.proposed_workshop_date }}</h5></label></td> + <td><label for="id_workshop_type"><h5>{{ workshop.proposed_workshop_title }}</h5></label></td> + </tr> + {% else %} + <tr> + <td><label for="id_instructor_name"><h5>{{ workshop.requested_workshop_instructor }}</h5></label></td> + <td><label for="id_workshop_date"><h5>{{ workshop.requested_workshop_date }}</h5></label></td> + <td><label for="id_workshop_type"><h5>{{ workshop.requested_workshop_title }}</h5></label></td> + </tr> + {% endif %} + {% 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..6be4b7e 100644 --- a/workshop_app/templates/workshop_app/view_profile.html +++ b/workshop_app/templates/workshop_app/view_profile.html @@ -49,6 +49,14 @@ </tr> </table> <br> - <a class="btn btn-primary pull-right" href="{{ URL_ROOT }}/edit_profile/">Edit Profile</a> + <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> + + + {% endblock %} diff --git a/workshop_app/urls.py b/workshop_app/urls.py index 154915d..704ae58 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/urls_password_reset.py b/workshop_app/urls_password_reset.py index c1e36c6..4a7ddf3 100644 --- a/workshop_app/urls_password_reset.py +++ b/workshop_app/urls_password_reset.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, url +from django.conf.urls import url from django.contrib.auth.views import password_reset, password_reset_confirm,\ password_reset_done, password_reset_complete, password_change,\ password_change_done diff --git a/workshop_app/views.py b/workshop_app/views.py index 76edc95..961445a 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -1190,6 +1190,16 @@ 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') + 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: @@ -1220,10 +1230,71 @@ def view_comment_profile(request, user_id): 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}) + "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/') |