Browse Source

Added timestamp to exported history filename (#57)

master
Kevin Mok 6 years ago
parent
commit
db29bc9f67
  1. 3
      api/views.py
  2. 9
      graphs/views.py

3
api/views.py

@ -265,6 +265,9 @@ def import_history(request, upload_id):
# }}} setup # # }}} setup #
history_obj_info_lst.append(history_obj_info) 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 rows_read += 1
if (rows_read % TRACKS_LIMIT == 0) or last_row: if (rows_read % TRACKS_LIMIT == 0) or last_row:
# get tracks_response {{{ # # get tracks_response {{{ #

9
graphs/views.py

@ -6,10 +6,11 @@ import requests
import os import os
import urllib import urllib
import secrets import secrets
from pprint import pprint
import string 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 django.shortcuts import render, redirect
from .utils import * from .utils import *
from django_tables2 import RequestConfig, SingleTableView from django_tables2 import RequestConfig, SingleTableView
@ -69,7 +70,9 @@ class HistoryList(ExportMixin, SingleTableView):
return context return context
def get_export_filename(self, export_format): 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): def create_export(self, export_format):
export_exclude = ('id', 'user', 'track', 'track_name', 'artists', export_exclude = ('id', 'user', 'track', 'track_name', 'artists',

Loading…
Cancel
Save