9
9
10
10
class Person (models .Model ):
11
11
user = models .OneToOneField (User , blank = True , null = True , related_name = 'handball_profile' )
12
- clubs = models .ManyToManyField ('Club' , related_name = 'members' , blank = False )
12
+ clubs = models .ManyToManyField ('Club' , related_name = 'members' , blank = False , through = 'MemberClubRelation' )
13
13
14
14
first_name = models .CharField (max_length = 50 )
15
15
last_name = models .CharField (max_length = 50 )
@@ -32,8 +32,8 @@ def __unicode__(self):
32
32
class Team (models .Model ):
33
33
name = models .CharField (max_length = 50 )
34
34
35
- players = models .ManyToManyField ('Person' , blank = True , related_name = 'teams' )
36
- coaches = models .ManyToManyField ('Person' , blank = True , related_name = 'teams_coached' )
35
+ players = models .ManyToManyField ('Person' , blank = True , related_name = 'teams' , through = 'TeamPlayerRelation' )
36
+ coaches = models .ManyToManyField ('Person' , blank = True , related_name = 'teams_coached' , through = 'TeamCoachRelation' )
37
37
# league = models.ForeignKey('League', related_name='league', blank=True)
38
38
club = models .ForeignKey ('Club' , related_name = 'teams' )
39
39
managers = models .ManyToManyField ('Person' , blank = True , related_name = 'teams_managed' )
@@ -158,6 +158,31 @@ class PlayerGameRelation(models.Model):
158
158
penalty_shots_miss = models .IntegerField ()
159
159
160
160
161
+ class MemberClubRelation (models .Model ):
162
+ member = models .ForeignKey ('Person' )
163
+ club = models .ForeignKey ('Club' )
164
+
165
+ primary = models .BooleanField ()
166
+ member_confirmed = models .BooleanField (default = False )
167
+ manager_confirmed = models .BooleanField (default = False )
168
+
169
+
170
+ class TeamPlayerRelation (models .Model ):
171
+ player = models .ForeignKey ('Person' )
172
+ team = models .ForeignKey ('Team' )
173
+
174
+ player_confirmed = models .BooleanField (default = False )
175
+ manager_confirmed = models .BooleanField (default = False )
176
+
177
+
178
+ class TeamCoachRelation (models .Model ):
179
+ coach = models .ForeignKey ('Person' )
180
+ team = models .ForeignKey ('Team' )
181
+
182
+ member_confirmed = models .BooleanField (default = False )
183
+ manager_confirmed = models .BooleanField (default = False )
184
+
185
+
161
186
class Event (models .Model ):
162
187
time = models .IntegerField ()
163
188
0 commit comments