Private
Public Access
1
0

added timezone to workout model

This commit is contained in:
Sander Roosendaal
2017-09-03 14:47:20 +02:00
parent bd46c5bcd7
commit df9806a200
3 changed files with 49 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ import colorsys
import timestring
import zipfile
import bleach
import pytz
import operator
import warnings
import urllib
@@ -6255,6 +6256,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
duration = form.cleaned_data['duration']
distance = form.cleaned_data['distance']
notes = form.cleaned_data['notes']
thetimezone = form.cleaned_data['timezone']
try:
boattype = request.POST['boattype']
except KeyError:
@@ -6272,6 +6274,9 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
startdatetime = datetime.datetime.strptime(startdatetime,
"%Y-%m-%d %H:%M:%S")
startdatetime = timezone.make_aware(startdatetime)
startdatetime = startdatetime.astimezone(pytz.timezone(thetimezone))
print startdatetime
# check if user is owner of this workout
if checkworkoutuser(request.user,row):
row.name = name
@@ -6285,6 +6290,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
row.boattype = boattype
row.privacy = privacy
row.rankingpiece = rankingpiece
row.timezone = thetimezone
try:
row.save()
except IntegrityError: