diff options
author | Akshen | 2018-10-01 11:42:38 +0530 |
---|---|---|
committer | Akshen | 2018-10-01 11:42:38 +0530 |
commit | 7ee753d439735fcf8dc59fd411dc54291d2e7ba4 (patch) | |
tree | db09ce655ad40f6f9152c216e4354782c8e20860 | |
parent | 1e301177eba101f5aca97c08b97d9dac8ccc86cb (diff) | |
download | workshop_booking-7ee753d439735fcf8dc59fd411dc54291d2e7ba4.tar.gz workshop_booking-7ee753d439735fcf8dc59fd411dc54291d2e7ba4.tar.bz2 workshop_booking-7ee753d439735fcf8dc59fd411dc54291d2e7ba4.zip |
Download workshop statistics update
- This commit will add two more columns email and state while downloading workshop data
-rw-r--r-- | statistics_app/views.py | 40 | ||||
-rw-r--r-- | workshop_app/admin.py | 15 | ||||
-rw-r--r-- | workshop_portal/settings.py | 2 |
3 files changed, 31 insertions, 26 deletions
diff --git a/statistics_app/views.py b/statistics_app/views.py index 1c13d60..6a33f56 100644 --- a/statistics_app/views.py +++ b/statistics_app/views.py @@ -79,7 +79,6 @@ def pie_chart(): del workshoptype_title, workshoptype_num return workshoptype_count - def india_map(): @@ -164,7 +163,6 @@ def workshop_stats(request): # For India Map states = india_map() - # For Data Downloading and Viewing if request.method == 'POST': try: @@ -207,11 +205,13 @@ def workshop_stats(request): writer = csv.writer(response) header = [ 'coordinator name', + 'coordinator email', 'instructor name', 'workshop', 'date', 'status', - 'institute name' + 'institute name', + 'state' ] writer.writerow(header) @@ -219,21 +219,27 @@ def workshop_stats(request): 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] + workshop.proposed_workshop_coordinator, + str(workshop.propossed_workshop_coordinator.profile.user.email), + workshop.proposed_workshop_instructor, + workshop.proposed_workshop_title, + workshop.proposed_workshop_date, + workshop.status, + workshop.proposed_workshop_coordinator.profile.institute, + str(workshop.proposed_workshop_coordinator.profile.state) + ] except BaseException: 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] + workshop.requested_workshop_coordinator, + str(workshop.requested_workshop_coordinator.profile.user.email), + workshop.requested_workshop_instructor, + workshop.requested_workshop_title, + workshop.requested_workshop_date, + workshop.status, + workshop.requested_workshop_coordinator.profile.institute, + str(workshop.requested_workshop_coordinator.profile.state) + ] writer.writerow(row) return response @@ -304,12 +310,12 @@ def workshop_public_stats(request): user = request.user today = datetime.now() upto = today + dt.timedelta(days=15) - + #For Pie Chart workshoptype_count = pie_chart() # For India Map - states = india_map() + states = india_map() # Select By WorkshopType workshoptype_list = list(WorkshopType.objects.all()) diff --git a/workshop_app/admin.py b/workshop_app/admin.py index 5e7b82f..c1c706a 100644 --- a/workshop_app/admin.py +++ b/workshop_app/admin.py @@ -1,8 +1,8 @@ import csv from django.http import HttpResponse -from django.contrib import admin +from django.contrib import admin from .models import ( - Profile, WorkshopType, + Profile, WorkshopType, Workshop, ProposeWorkshopDate, RequestedWorkshop, BookedWorkshop, Testimonial, ProfileComments @@ -20,7 +20,7 @@ class ProfileAdmin(admin.ModelAdmin): actions = ['download_csv'] def download_csv(self, request, queryset): - openfile = string_io() + openfile = string_io() response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment;\ filename=profile_data.csv' @@ -29,7 +29,7 @@ class ProfileAdmin(admin.ModelAdmin): writer.writerow(['email_id', 'title','username', 'first_name', 'last_name', 'institute', 'location', 'department', 'phone_number', 'position']) - + for q in queryset: writer.writerow([q.user.email, q.title, q.user, q.user.first_name, q.user.last_name, q.institute, @@ -39,7 +39,7 @@ class ProfileAdmin(admin.ModelAdmin): openfile.seek(0) response.write(openfile.read()) return response - + download_csv.short_description = "Download CSV file for selected stats." @@ -58,9 +58,8 @@ class ProposeWorkshopDateAdmin(admin.ModelAdmin): writer = csv.writer(response) writer.writerow(['proposed_workshop_title', 'proposed_workshop_date', - 'proposed_workshop_coordinator', 'status', - 'proposed_workshop_instructor']) - + 'proposed_workshop_coordinator', 'status','proposed_workshop_instructor']) + for q in queryset: writer.writerow([q.proposed_workshop_title, q.proposed_workshop_date, q.proposed_workshop_coordinator, q.status, diff --git a/workshop_portal/settings.py b/workshop_portal/settings.py index 179d354..385a02a 100644 --- a/workshop_portal/settings.py +++ b/workshop_portal/settings.py @@ -159,7 +159,7 @@ PRODUCTION_URL = 'your_production_url' ADMIN_EMAIL = 'your admin email' #Set True or False to view/hide -SHOW_WORKSHOP_STATS = False +SHOW_WORKSHOP_STATS = False LOGIN_REDIRECT_URL = '/profile' SESSION_EXPIRE_AT_BROWSER_CLOSE = True |