Private
Public Access
1
0

added default time zone setting

This commit is contained in:
Sander Roosendaal
2017-09-21 09:21:33 +02:00
parent 36249ab4aa
commit 43300cc28d
3 changed files with 17 additions and 4 deletions

View File

@@ -592,7 +592,7 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
timezone_str = tf.closest_timezone_at(lng=lonavg,
lat=latavg)
if timezone_str == None:
timezone_str = 'UTC'
timezone_str = r.defaulttimezone
try:
workoutstartdatetime = pytz.timezone(timezone_str).localize(
row.rowdatetime
@@ -602,7 +602,7 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
pytz.timezone(timezone_str)
)
except KeyError:
timezone_str = 'UTC'
timezone_str = r.defaulttimezone

View File

@@ -54,6 +54,10 @@ database_url = 'mysql://{user}:{password}@{host}:{port}/{database_name}'.format(
if settings.DEBUG or user=='':
database_url = 'sqlite:///db.sqlite3'
timezones = (
(x,x) for x in pytz.common_timezones
)
class UserFullnameChoiceField(forms.ModelChoiceField):
def label_from_instance(self,obj):
return obj.get_full_name()
@@ -290,6 +294,11 @@ class Rower(models.Model):
team = models.ManyToManyField(Team,blank=True)
# Export and Time Zone Settings
defaulttimezone = models.CharField(default='UTC',max_length=100,
choices=timezones,
verbose_name='Default Time Zone')
def __str__(self):
return self.user.username
@@ -389,11 +398,11 @@ def checkworkoutuser(user,workout):
except Rower.DoesNotExist:
return False
timezones = (
(x,x) for x in pytz.common_timezones
)
# Workout
class Workout(models.Model):
workouttypes = types.workouttypes
@@ -809,7 +818,7 @@ class RowerPowerZonesForm(ModelForm):
class AccountRowerForm(ModelForm):
class Meta:
model = Rower
fields = ['weightcategory','getemailnotifications']
fields = ['weightcategory','getemailnotifications','defaulttimezone']
class UserForm(ModelForm):
class Meta:

View File

@@ -8916,14 +8916,18 @@ def rower_edit_view(request,message=""):
email = ucd['email']
weightcategory = cd['weightcategory']
getemailnotifications = cd['getemailnotifications']
defaulttimezone=cd['defaulttimezone']
u = request.user
if len(first_name):
u.first_name = first_name
u.last_name = last_name
if len(email):
u.email = email
u.save()
r = getrower(u)
r.defaulttimezone=defaulttimezone
r.weightcategory = weightcategory
r.getemailnotifications = getemailnotifications
r.save()