From db29bc9f67101295fcdc75d734ff1e42f92dadf5 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Wed, 14 Nov 2018 12:02:46 -0500 Subject: [PATCH] Added timestamp to exported history filename (#57) --- api/views.py | 3 +++ graphs/views.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api/views.py b/api/views.py index a792124..be455a0 100644 --- a/api/views.py +++ b/api/views.py @@ -265,6 +265,9 @@ def import_history(request, upload_id): # }}} setup # history_obj_info_lst.append(history_obj_info) + # PU: refactor saving History object right away if Track obj already + # exists + # PU: refactor below? rows_read += 1 if (rows_read % TRACKS_LIMIT == 0) or last_row: # get tracks_response {{{ # diff --git a/graphs/views.py b/graphs/views.py index 2c09239..8c410d6 100644 --- a/graphs/views.py +++ b/graphs/views.py @@ -6,10 +6,11 @@ import requests import os import urllib import secrets -from pprint import pprint import string -from datetime import datetime +from pprint import pprint +from datetime import datetime +from time import strftime from django.shortcuts import render, redirect from .utils import * from django_tables2 import RequestConfig, SingleTableView @@ -69,7 +70,9 @@ class HistoryList(ExportMixin, SingleTableView): return context def get_export_filename(self, export_format): - return "{}.{}".format(self.request.session['user_id'], export_format) + user_id = self.request.session['user_id'] + timestamp = strftime("%m%d%Y-%H%M") + return "{}.{}".format("-".join((user_id, timestamp)), export_format) def create_export(self, export_format): export_exclude = ('id', 'user', 'track', 'track_name', 'artists',