Fixed safari download bug
This commit is contained in:
parent
f69c1e6318
commit
315e44adb1
1 changed files with 8 additions and 12 deletions
|
@ -28,8 +28,6 @@ def tofirstdayinisoweek(year, week):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
template = loader.get_template('index.html')
|
|
||||||
|
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
now = datetime.today()
|
now = datetime.today()
|
||||||
|
|
||||||
|
@ -57,19 +55,18 @@ def index(request):
|
||||||
now + timedelta(days=6-weekday))) \
|
now + timedelta(days=6-weekday))) \
|
||||||
.aggregate(s=Sum('count'))
|
.aggregate(s=Sum('count'))
|
||||||
|
|
||||||
return HttpResponse(template.render({
|
context = {
|
||||||
'yearArrows': yearArrows,
|
'yearArrows': yearArrows,
|
||||||
'monthArrows': 0 if monthArrows['s'] is None else monthArrows['s'],
|
'monthArrows': 0 if monthArrows['s'] is None else monthArrows['s'],
|
||||||
'weekArrows': 0 if weekArrows['s'] is None else weekArrows['s'],
|
'weekArrows': 0 if weekArrows['s'] is None else weekArrows['s'],
|
||||||
'diffTarget': diff_target
|
'diffTarget': diff_target
|
||||||
}, request))
|
}
|
||||||
|
return render(request, 'index.html', context)
|
||||||
else:
|
else:
|
||||||
return HttpResponse(template.render({}), request)
|
return render(request, 'index.html', {})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def count_stats(request):
|
def count_stats(request):
|
||||||
template = loader.get_template('stats.html')
|
|
||||||
|
|
||||||
# Group counts by week (extract isoyear works only on psql and DB2)
|
# Group counts by week (extract isoyear works only on psql and DB2)
|
||||||
weeklyArrows = ArrowCount.objects \
|
weeklyArrows = ArrowCount.objects \
|
||||||
.filter(user = request.user) \
|
.filter(user = request.user) \
|
||||||
|
@ -83,9 +80,9 @@ def count_stats(request):
|
||||||
w['weekStarts'] = tofirstdayinisoweek(w['isoyear'], w['week'])
|
w['weekStarts'] = tofirstdayinisoweek(w['isoyear'], w['week'])
|
||||||
w['weekEnds'] = w['weekStarts'] + timedelta(days=6)
|
w['weekEnds'] = w['weekStarts'] + timedelta(days=6)
|
||||||
|
|
||||||
return HttpResponse(template.render({
|
return render(request, 'counter/stats.html', {
|
||||||
'weeklyArrows': json.dumps(list(weeklyArrows), cls=DjangoJSONEncoder)
|
'weeklyArrows': json.dumps(list(weeklyArrows), cls=DjangoJSONEncoder)
|
||||||
}, request))
|
})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def arrow_count_export(request):
|
def arrow_count_export(request):
|
||||||
|
@ -125,12 +122,11 @@ def arrow_count_list(request):
|
||||||
|
|
||||||
pageCount = math.ceil(ArrowCount.objects.filter(user = request.user).count() / \
|
pageCount = math.ceil(ArrowCount.objects.filter(user = request.user).count() / \
|
||||||
settings.ITEMS_PER_PAGE)
|
settings.ITEMS_PER_PAGE)
|
||||||
template = loader.get_template('counter/list.html')
|
return render(request, 'counter/list.html', {
|
||||||
return HttpResponse(template.render({
|
|
||||||
'counts': counts,
|
'counts': counts,
|
||||||
'pageCount': pageCount,
|
'pageCount': pageCount,
|
||||||
'page': page
|
'page': page
|
||||||
}, request))
|
})
|
||||||
|
|
||||||
class NewArrowCount(generic.CreateView):
|
class NewArrowCount(generic.CreateView):
|
||||||
form_class = ArrowCountForm
|
form_class = ArrowCountForm
|
||||||
|
|
Loading…
Reference in a new issue