@@ -55,6 +55,10 @@ class Meta:
55
55
authentication = Authentication ()
56
56
authorization = Authorization ()
57
57
58
+ def dehydrate (self , bundle ):
59
+ bundle .data ['display_name' ] = str (bundle .obj )
60
+ return bundle
61
+
58
62
59
63
class ClubResource (ModelResource ):
60
64
district = fields .ForeignKey (DistrictResource , 'district' , full = True )
@@ -68,7 +72,7 @@ class Meta:
68
72
authorization = Authorization ()
69
73
authentication = Authentication ()
70
74
filtering = {
71
- 'union ' : ALL_WITH_RELATIONS
75
+ 'district ' : ALL_WITH_RELATIONS
72
76
}
73
77
74
78
def obj_create (self , bundle , request = None , ** kwargs ):
@@ -92,6 +96,9 @@ class Meta:
92
96
allowed_methods = ['get' , 'post' , 'put' ]
93
97
authorization = Authorization ()
94
98
authentication = Authentication ()
99
+ filtering = {
100
+ 'club' : ALL_WITH_RELATIONS
101
+ }
95
102
96
103
def obj_create (self , bundle , request = None , ** kwargs ):
97
104
# The user to create a team becomes its first manager (for lack of other people)
@@ -100,6 +107,12 @@ def obj_create(self, bundle, request=None, **kwargs):
100
107
101
108
def dehydrate (self , bundle ):
102
109
bundle .data ['display_name' ] = str (bundle .obj )
110
+
111
+ bundle .data ['players' ] = []
112
+ resource = PersonResource ()
113
+ for membership in TeamPlayerRelation .objects .filter (player = bundle .obj , manager_confirmed = True ):
114
+ playerBundle = resource .build_bundle (obj = membership .player , request = bundle .request )
115
+ bundle .data ['players' ].append (resource .full_dehydrate (playerBundle ))
103
116
return bundle
104
117
105
118
@@ -212,6 +225,26 @@ class Meta:
212
225
authentication = Authentication ()
213
226
always_return_data = True
214
227
228
+
229
+ class SiteResource (ModelResource ):
230
+ class Meta :
231
+ queryset = Site .objects .all ()
232
+ authorization = Authorization ()
233
+ authentication = Authentication ()
234
+ always_return_data = True
235
+
236
+ def dehydrate (self , bundle ):
237
+ bundle .data ['display_name' ] = str (bundle .obj )
238
+ return bundle
239
+
240
+
241
+ class GroupResource (ModelResource ):
242
+ class Meta :
243
+ queryset = Group .objects .all ()
244
+ authorization = Authorization ()
245
+ authentication = Authentication ()
246
+
247
+
215
248
"""
216
249
Non-resource api endpoints
217
250
"""
0 commit comments