changing can_coahc
This commit is contained in:
@@ -1117,6 +1117,17 @@ class Rower(models.Model):
|
|||||||
|
|
||||||
return coaches
|
return coaches
|
||||||
|
|
||||||
|
def can_coach(self):
|
||||||
|
if self.rowerplan not in ['coach','freecoach']:
|
||||||
|
return False
|
||||||
|
|
||||||
|
rs = Rower.objects.filter(coachinggroups__in=[self.mycoachgroup])
|
||||||
|
rekwests = CoachOffer.objects.filter(coach=self)
|
||||||
|
if len(rs)+len(rekwests) < self.clubsize and self.offercoaching:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ispaid(self):
|
def ispaid(self):
|
||||||
return self.rowerplan in ['pro','plan','coach']
|
return self.rowerplan in ['pro','plan','coach']
|
||||||
|
|||||||
@@ -225,12 +225,10 @@ def rower_teams_view(request):
|
|||||||
|
|
||||||
potentialcoaches = [t.manager for t in memberteams if t.manager not in coaches and 'coach' in t.manager.rower.rowerplan]
|
potentialcoaches = [t.manager for t in memberteams if t.manager not in coaches and 'coach' in t.manager.rower.rowerplan]
|
||||||
offercoaches = [
|
offercoaches = [
|
||||||
r.user for r in Rower.objects.filter(
|
r.user for r in Rower.objects.all().exclude(user=request.user) if r.can_coach()
|
||||||
offercoaching=True,rowerplan__in='coach').exclude(user=request.user)
|
|
||||||
]
|
]
|
||||||
potentialcoaches = list(set(potentialcoaches+offercoaches))
|
potentialcoaches = list(set(potentialcoaches+offercoaches))
|
||||||
potentialcoaches = [c for c in potentialcoaches if c.rower not in invitedcoaches+coaches]
|
potentialcoaches = [c for c in potentialcoaches if c.rower not in invitedcoaches+coaches]
|
||||||
potentialcoaches = [c for c in potentialcoaches if teams.get_coach_club_size(c.rower)<c.rower.clubsize]
|
|
||||||
|
|
||||||
|
|
||||||
coachees = teams.coach_getcoachees(request.user.rower)
|
coachees = teams.coach_getcoachees(request.user.rower)
|
||||||
|
|||||||
@@ -252,7 +252,6 @@ def rower_favoritecharts_view(request,userid=0):
|
|||||||
r.usersmooth = staticchartform.cleaned_data.get('usersmooth')
|
r.usersmooth = staticchartform.cleaned_data.get('usersmooth')
|
||||||
r.save()
|
r.save()
|
||||||
|
|
||||||
print(request.POST)
|
|
||||||
if request.method == 'POST' and 'save_data' in request.POST:
|
if request.method == 'POST' and 'save_data' in request.POST:
|
||||||
datasettingsform = DataRowerForm(request.POST,instance=r)
|
datasettingsform = DataRowerForm(request.POST,instance=r)
|
||||||
if datasettingsform.is_valid():
|
if datasettingsform.is_valid():
|
||||||
|
|||||||
Reference in New Issue
Block a user