added default time zone setting
This commit is contained in:
@@ -592,7 +592,7 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
|||||||
timezone_str = tf.closest_timezone_at(lng=lonavg,
|
timezone_str = tf.closest_timezone_at(lng=lonavg,
|
||||||
lat=latavg)
|
lat=latavg)
|
||||||
if timezone_str == None:
|
if timezone_str == None:
|
||||||
timezone_str = 'UTC'
|
timezone_str = r.defaulttimezone
|
||||||
try:
|
try:
|
||||||
workoutstartdatetime = pytz.timezone(timezone_str).localize(
|
workoutstartdatetime = pytz.timezone(timezone_str).localize(
|
||||||
row.rowdatetime
|
row.rowdatetime
|
||||||
@@ -602,7 +602,7 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
|||||||
pytz.timezone(timezone_str)
|
pytz.timezone(timezone_str)
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
timezone_str = 'UTC'
|
timezone_str = r.defaulttimezone
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ database_url = 'mysql://{user}:{password}@{host}:{port}/{database_name}'.format(
|
|||||||
if settings.DEBUG or user=='':
|
if settings.DEBUG or user=='':
|
||||||
database_url = 'sqlite:///db.sqlite3'
|
database_url = 'sqlite:///db.sqlite3'
|
||||||
|
|
||||||
|
timezones = (
|
||||||
|
(x,x) for x in pytz.common_timezones
|
||||||
|
)
|
||||||
|
|
||||||
class UserFullnameChoiceField(forms.ModelChoiceField):
|
class UserFullnameChoiceField(forms.ModelChoiceField):
|
||||||
def label_from_instance(self,obj):
|
def label_from_instance(self,obj):
|
||||||
return obj.get_full_name()
|
return obj.get_full_name()
|
||||||
@@ -290,6 +294,11 @@ class Rower(models.Model):
|
|||||||
|
|
||||||
team = models.ManyToManyField(Team,blank=True)
|
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):
|
def __str__(self):
|
||||||
return self.user.username
|
return self.user.username
|
||||||
|
|
||||||
@@ -389,11 +398,11 @@ def checkworkoutuser(user,workout):
|
|||||||
except Rower.DoesNotExist:
|
except Rower.DoesNotExist:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
timezones = (
|
timezones = (
|
||||||
(x,x) for x in pytz.common_timezones
|
(x,x) for x in pytz.common_timezones
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Workout
|
# Workout
|
||||||
class Workout(models.Model):
|
class Workout(models.Model):
|
||||||
workouttypes = types.workouttypes
|
workouttypes = types.workouttypes
|
||||||
@@ -809,7 +818,7 @@ class RowerPowerZonesForm(ModelForm):
|
|||||||
class AccountRowerForm(ModelForm):
|
class AccountRowerForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Rower
|
model = Rower
|
||||||
fields = ['weightcategory','getemailnotifications']
|
fields = ['weightcategory','getemailnotifications','defaulttimezone']
|
||||||
|
|
||||||
class UserForm(ModelForm):
|
class UserForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -8916,14 +8916,18 @@ def rower_edit_view(request,message=""):
|
|||||||
email = ucd['email']
|
email = ucd['email']
|
||||||
weightcategory = cd['weightcategory']
|
weightcategory = cd['weightcategory']
|
||||||
getemailnotifications = cd['getemailnotifications']
|
getemailnotifications = cd['getemailnotifications']
|
||||||
|
defaulttimezone=cd['defaulttimezone']
|
||||||
u = request.user
|
u = request.user
|
||||||
if len(first_name):
|
if len(first_name):
|
||||||
u.first_name = first_name
|
u.first_name = first_name
|
||||||
u.last_name = last_name
|
u.last_name = last_name
|
||||||
if len(email):
|
if len(email):
|
||||||
u.email = email
|
u.email = email
|
||||||
|
|
||||||
|
|
||||||
u.save()
|
u.save()
|
||||||
r = getrower(u)
|
r = getrower(u)
|
||||||
|
r.defaulttimezone=defaulttimezone
|
||||||
r.weightcategory = weightcategory
|
r.weightcategory = weightcategory
|
||||||
r.getemailnotifications = getemailnotifications
|
r.getemailnotifications = getemailnotifications
|
||||||
r.save()
|
r.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user