3
3
from handball .models import *
4
4
from django .contrib .auth .models import User
5
5
from tastypie .authorization import DjangoAuthorization , Authorization
6
- from tastypie .authentication import BasicAuthentication , Authentication
6
+ from tastypie .authentication import BasicAuthentication , Authentication , ApiKeyAuthentication
7
+ from handball .authorization import ManagerAuthorization
7
8
8
9
9
10
class UnionResource (ModelResource ):
@@ -14,7 +15,7 @@ class Meta:
14
15
queryset = Union .objects .all ()
15
16
allowed_methods = ['get' , 'post' , 'put' , 'patch' ]
16
17
authorization = Authorization ()
17
- authentication = BasicAuthentication ()
18
+ authentication = ApiKeyAuthentication ()
18
19
filtering = {
19
20
'name' : ('exact' )
20
21
}
@@ -29,7 +30,7 @@ class LeagueResource(ModelResource):
29
30
class Meta :
30
31
queryset = Team .objects .all ()
31
32
allowed_methods = ['get' , 'post' , 'put' ]
32
- authentication = Authentication ()
33
+ authentication = ApiKeyAuthentication ()
33
34
authorization = Authorization ()
34
35
35
36
@@ -41,7 +42,7 @@ class Meta:
41
42
queryset = Club .objects .all ()
42
43
allowed_methods = ['get' , 'post' , 'put' ]
43
44
authorization = Authorization ()
44
- authentication = Authentication ()
45
+ authentication = ApiKeyAuthentication ()
45
46
filtering = {
46
47
'union' : ALL_WITH_RELATIONS
47
48
}
@@ -60,7 +61,7 @@ class Meta:
60
61
queryset = Team .objects .all ()
61
62
allowed_methods = ['get' , 'post' , 'put' ]
62
63
authorization = Authorization ()
63
- authentication = Authentication ()
64
+ authentication = ApiKeyAuthentication ()
64
65
65
66
def obj_create (self , bundle , request = None , ** kwargs ):
66
67
# The user to create a team becomes its first manager (for lack of other people)
@@ -73,7 +74,7 @@ class UserResource(ModelResource):
73
74
74
75
class Meta :
75
76
queryset = User .objects .all ()
76
- excludes = [" email" , " password" ]
77
+ excludes = [' email' , ' password' ]
77
78
78
79
79
80
class PersonResource (ModelResource ):
@@ -82,22 +83,25 @@ class PersonResource(ModelResource):
82
83
83
84
class Meta :
84
85
queryset = Person .objects .all ()
85
- authorization = DjangoAuthorization ()
86
+ authorization = Authorization ()
87
+ authentication = ApiKeyAuthentication ()
86
88
excludes = ['activation_key' , 'key_expires' ]
87
89
88
90
89
91
class GameTypeResource (ModelResource ):
90
92
class Meta :
91
93
queryset = GameType .objects .all ()
92
94
include_resource_uri = False
93
- authorization = DjangoAuthorization ()
95
+ authorization = Authorization ()
96
+ authentication = ApiKeyAuthentication ()
94
97
95
98
96
99
class SiteResource (ModelResource ):
97
100
class Meta :
98
101
queryset = Site .objects .all ()
99
102
include_resource_uri = False
100
- authorization = DjangoAuthorization ()
103
+ authorization = Authorization ()
104
+ authentication = ApiKeyAuthentication ()
101
105
102
106
103
107
class GameResource (ModelResource ):
@@ -116,7 +120,8 @@ class GameResource(ModelResource):
116
120
117
121
class Meta :
118
122
queryset = Game .objects .all ()
119
- authorization = DjangoAuthorization ()
123
+ authorization = Authorization ()
124
+ authentication = ApiKeyAuthentication ()
120
125
121
126
122
127
class EventTypeResource (ModelResource ):
@@ -125,7 +130,8 @@ class EventTypeResource(ModelResource):
125
130
class Meta :
126
131
queryset = EventType .objects .all ()
127
132
include_resource_uri = False
128
- authorization = DjangoAuthorization ()
133
+ authorization = Authorization ()
134
+ authentication = ApiKeyAuthentication ()
129
135
130
136
131
137
class EventResource (ModelResource ):
@@ -134,5 +140,6 @@ class EventResource(ModelResource):
134
140
135
141
class Meta :
136
142
queryset = Event .objects .all ()
137
- authorization = DjangoAuthorization ()
143
+ authorization = Authorization ()
144
+ authentication = ApiKeyAuthentication ()
138
145
include_resource_uri = False
0 commit comments