1 | 1c1
|
---|
2 | < from django.contrib.auth.models import User, Permission
|
---|
3 | ---
|
---|
4 | > from django.contrib.auth.models import User, Permission, AnonymousUser
|
---|
5 | 8a9,15
|
---|
6 | >
|
---|
7 | > user_model = User
|
---|
8 | > permission_model = Permission
|
---|
9 | > anonymous_user_model = AnonymousUser
|
---|
10 | >
|
---|
11 | > def get_anonymous_user(self):
|
---|
12 | > return AnonymousUser()
|
---|
13 | 14c21
|
---|
14 | < user = User.objects.get(username=username)
|
---|
15 | ---
|
---|
16 | > user = self.user_model.objects.get(username=username)
|
---|
17 | 17c24
|
---|
18 | < except User.DoesNotExist:
|
---|
19 | ---
|
---|
20 | > except self.user_model.DoesNotExist:
|
---|
21 | 29c36
|
---|
22 | < perms = Permission.objects.all()
|
---|
23 | ---
|
---|
24 | > perms = self.permission_model.objects.all()
|
---|
25 | 31c38
|
---|
26 | < perms = Permission.objects.filter(group__user=user_obj)
|
---|
27 | ---
|
---|
28 | > perms = self.permission_model.objects.filter(group__user=user_obj)
|
---|
29 | 62,63c69,70
|
---|
30 | < return User.objects.get(pk=user_id)
|
---|
31 | < except User.DoesNotExist:
|
---|
32 | ---
|
---|
33 | > return self.user_model.objects.get(pk=user_id)
|
---|
34 | > except self.user_model.DoesNotExist:
|
---|
35 | 100c107
|
---|
36 | < user, created = User.objects.get_or_create(username=username)
|
---|
37 | ---
|
---|
38 | > user, created = self.user_model.objects.get_or_create(username=username)
|
---|
39 | 105,106c112,113
|
---|
40 | < user = User.objects.get(username=username)
|
---|
41 | < except User.DoesNotExist:
|
---|
42 | ---
|
---|
43 | > user = self.user_model.objects.get(username=username)
|
---|
44 | > except self.user_model.DoesNotExist:
|
---|