Private
Public Access
1
0

reinstalling club size

This commit is contained in:
Sander Roosendaal
2019-02-21 20:26:44 +01:00
parent fe59ead06b
commit 2c3d9532b0
4 changed files with 14 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ class RowerInline(admin.StackedInline):
('Billing Details',
{'fields':('street_address','city','postal_code','country','paymentprocessor','customer_id')}),
('Rower Plan',
{'fields':('paidplan','rowerplan','paymenttype','planexpires','teamplanexpires','protrialexpires','plantrialexpires',)}),
{'fields':('paidplan','rowerplan','paymenttype','planexpires','teamplanexpires','protrialexpires','plantrialexpires','clubsize','offercoaching')}),
('Rower Settings',
{'fields':
('gdproptin','gdproptindate','weightcategory','sex','adaptiveclass','birthdate','getemailnotifications',
@@ -60,7 +60,7 @@ class RowerInline(admin.StackedInline):
#class UserAdmin(UserAdmin):
class UserAdmin(admin.ModelAdmin):
inlines = (RowerInline,)
list_display = ('username','email','first_name','last_name','rowerplan')
list_display = ('username','email','first_name','last_name','rowerplan','clubsize')
fieldsets = (
('Personal info',
@@ -75,6 +75,9 @@ class UserAdmin(admin.ModelAdmin):
def rowerplan(self, obj):
return obj.rower.rowerplan
def clubsize(self, obj):
return obj.rower.clubsize
class WorkoutAdmin(admin.ModelAdmin):
list_display = ('date','user','name','workouttype','boattype')

View File

@@ -119,7 +119,7 @@ def add_coach(coach,rower):
coach.mycoachgroup = coachgroup
coach.save()
if get_coach_club_size(coach)<=coach.clubsize:
if get_coach_club_size(coach)<coach.clubsize:
rower.coachinggroups.add(coach.mycoachgroup)
return (1,"Added Coach")
@@ -312,13 +312,15 @@ def create_coaching_offer(coach,user):
while code in codes:
code = uuid.uuid4().hex[:10].upper()
if coach.rowerplan == 'coach' and get_coach_club_size(coach)<=coach.clubsize:
if coach.rowerplan == 'coach' and get_coach_club_size(coach)<coach.clubsize:
rekwest = CoachOffer(coach=coach,user=user,code=code)
rekwest.save()
send_coacheerequest_email(rekwest)
return (rekwest.id,'The request was created')
elif get_coach_club_size(coach)>=coach.clubsize:
return(0,'You have reached the maximum number of athletes')
else:
return (0,'You are not a coach')

Binary file not shown.

View File

@@ -189,7 +189,9 @@ def rower_teams_view(request,message='',successmessage=''):
coachrequests = CoachRequest.objects.filter(coach=r)
invitedathletes = [rekwest.user for rekwest in mycoachoffers]
invitedcoaches = [rekwest.coach for rekwest in mycoachrequests]
invitedcoaches = [rekwest.coach for rekwest in mycoachrequests ]
invitedcoaches += [rekwest.coach for rekwest in coachoffers]
invitingathletes = [rekwest.user for rekwest in coachrequests]
coaches = teams.rower_get_coaches(r)
@@ -200,6 +202,7 @@ def rower_teams_view(request,message='',successmessage=''):
]
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 teams.get_coach_club_size(c.rower)<c.rower.clubsize]
coachees = teams.coach_getcoachees(r)
@@ -213,6 +216,7 @@ def rower_teams_view(request,message='',successmessage=''):
else:
potentialathletes = []
potentialathletes = [a for a in potentialathletes if a.user not in invitingathletes]
# clubsize = teams.count_invites(request.user)+teams.count_club_members(request.user)
# max_clubsize = r.clubsize