added privacy settings to workouts & users
This commit is contained in:
@@ -204,6 +204,11 @@ class Rower(models.Model):
|
|||||||
('coach','coach')
|
('coach','coach')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
privacychoices = (
|
||||||
|
('visible','Visible'),
|
||||||
|
('hidden','Hidden'),
|
||||||
|
)
|
||||||
|
|
||||||
rowerplan = models.CharField(default='basic',max_length=30,
|
rowerplan = models.CharField(default='basic',max_length=30,
|
||||||
choices=plans)
|
choices=plans)
|
||||||
|
|
||||||
@@ -211,8 +216,11 @@ class Rower(models.Model):
|
|||||||
teamplanexpires = models.DateField(default=timezone.now)
|
teamplanexpires = models.DateField(default=timezone.now)
|
||||||
clubsize = models.IntegerField(default=0)
|
clubsize = models.IntegerField(default=0)
|
||||||
|
|
||||||
|
|
||||||
# Friends/Team
|
# Friends/Team
|
||||||
friends = models.ManyToManyField("self",blank=True)
|
friends = models.ManyToManyField("self",blank=True)
|
||||||
|
privacy = models.CharField(default='visible',max_length=30,
|
||||||
|
choices=privacychoices)
|
||||||
|
|
||||||
team = models.ManyToManyField(Team,blank=True)
|
team = models.ManyToManyField(Team,blank=True)
|
||||||
|
|
||||||
@@ -360,6 +368,11 @@ class Workout(models.Model):
|
|||||||
('8+', '8+ (eight)'),
|
('8+', '8+ (eight)'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
privacychoices = (
|
||||||
|
('private','Private'),
|
||||||
|
('visible','Visible'),
|
||||||
|
)
|
||||||
|
|
||||||
user = models.ForeignKey(Rower)
|
user = models.ForeignKey(Rower)
|
||||||
team = models.ManyToManyField(Team,blank=True)
|
team = models.ManyToManyField(Team,blank=True)
|
||||||
name = models.CharField(max_length=150)
|
name = models.CharField(max_length=150)
|
||||||
@@ -382,6 +395,8 @@ class Workout(models.Model):
|
|||||||
uploadedtosporttracks = models.IntegerField(default=0)
|
uploadedtosporttracks = models.IntegerField(default=0)
|
||||||
notes = models.CharField(blank=True,null=True,max_length=200)
|
notes = models.CharField(blank=True,null=True,max_length=200)
|
||||||
summary = models.TextField(blank=True)
|
summary = models.TextField(blank=True)
|
||||||
|
privacy = models.CharField(default='visible',max_length=30,
|
||||||
|
choices=privacychoices)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
||||||
@@ -499,7 +514,7 @@ class WorkoutForm(ModelForm):
|
|||||||
duration = forms.TimeInput(format='%H:%M:%S.%f')
|
duration = forms.TimeInput(format='%H:%M:%S.%f')
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Workout
|
model = Workout
|
||||||
fields = ['name','date','starttime','duration','distance','workouttype','boattype','notes']
|
fields = ['name','date','starttime','duration','distance','workouttype','notes','privacy','boattype']
|
||||||
widgets = {
|
widgets = {
|
||||||
'date': DateInput(),
|
'date': DateInput(),
|
||||||
'notes': forms.Textarea,
|
'notes': forms.Textarea,
|
||||||
@@ -508,6 +523,9 @@ class WorkoutForm(ModelForm):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(WorkoutForm, self).__init__(*args, **kwargs)
|
super(WorkoutForm, self).__init__(*args, **kwargs)
|
||||||
|
# this line to be removed
|
||||||
|
del self.fields['privacy']
|
||||||
|
|
||||||
if self.instance.workouttype != 'water':
|
if self.instance.workouttype != 'water':
|
||||||
del self.fields['boattype']
|
del self.fields['boattype']
|
||||||
|
|
||||||
|
|||||||
@@ -3259,6 +3259,10 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
try:
|
try:
|
||||||
boattype = request.POST['boattype']
|
boattype = request.POST['boattype']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
boattype = Workout.objects.get(id=id).boattype
|
||||||
|
try:
|
||||||
|
privacy = request.POST['privacy']
|
||||||
|
except KeyError:
|
||||||
privacy = Workout.objects.get(id=id).privacy
|
privacy = Workout.objects.get(id=id).privacy
|
||||||
startdatetime = (str(date) + ' ' + str(starttime))
|
startdatetime = (str(date) + ' ' + str(starttime))
|
||||||
startdatetime = datetime.datetime.strptime(startdatetime,
|
startdatetime = datetime.datetime.strptime(startdatetime,
|
||||||
@@ -3277,6 +3281,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
row.notes = notes
|
row.notes = notes
|
||||||
row.duration = duration
|
row.duration = duration
|
||||||
row.distance = distance
|
row.distance = distance
|
||||||
|
row.boattype = boattype
|
||||||
row.privacy = privacy
|
row.privacy = privacy
|
||||||
row.save()
|
row.save()
|
||||||
# change data in csv file
|
# change data in csv file
|
||||||
|
|||||||
Reference in New Issue
Block a user