Skip to content

Commit 1affff9

Browse files
author
lijianguo
committed
feat(template): add user page
1 parent b940231 commit 1affff9

37 files changed

Lines changed: 20546 additions & 59 deletions

rootfs/api/serializers.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
import logging
55

66
from django.contrib.auth.models import User
7+
from django.contrib.admin.models import LogEntry
78
from django.contrib.auth.forms import UserCreationForm
89
from rest_framework import serializers
910
from oauth2_provider.oauth2_validators import OAuth2Validator
11+
from oauth2_provider.models import Grant, AccessToken
12+
13+
from api.utils import timestamp2datetime
1014

1115
logger = logging.getLogger(__name__)
1216

@@ -30,6 +34,51 @@ class Meta:
3034
fields = ('username', 'email')
3135

3236

37+
class ListSerializer(serializers.Serializer):
38+
section = serializers.CharField(max_length=500, required=False)
39+
40+
@staticmethod
41+
def validate_section(section):
42+
field = section.split(',') if section else None
43+
if field is None:
44+
return None
45+
return [timestamp2datetime(float(field[0])),
46+
timestamp2datetime(float(field[1]))]
47+
48+
49+
class UserGrantsSerializer(serializers.ModelSerializer):
50+
"""Serialize user status for a Grant model."""
51+
52+
class Meta:
53+
model = Grant
54+
fields = '__all__'
55+
read_only_fields = ['id', 'user', 'code', 'application', 'expires',
56+
'redirect_uri', 'scope', 'created', 'updated',
57+
'code_challenge', 'code_challenge_method', 'nonce',
58+
'claims']
59+
60+
61+
class UserTokensSerializer(serializers.ModelSerializer):
62+
"""Serialize user status for a AccessToken model."""
63+
64+
class Meta:
65+
model = AccessToken
66+
fields = '__all__'
67+
read_only_fields = ['id', 'user', 'source_refresh_token', 'token',
68+
'id_token', 'application', 'expires', 'scope',
69+
'created', 'updated']
70+
71+
72+
class UserLogsSerializer(serializers.ModelSerializer):
73+
"""Serialize user status for a AccessToken model."""
74+
75+
class Meta:
76+
model = LogEntry
77+
fields = '__all__'
78+
read_only_fields = ['action_time', 'user', 'content_type', 'object_id',
79+
'object_repr', 'action_flag', 'change_message']
80+
81+
3382
class CustomOAuth2Validator(OAuth2Validator):
3483

3584
def get_additional_claims(self, request):

rootfs/api/settings/production.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@
114114
)
115115

116116
ANONYMOUS_USER_ID = -1
117-
LOGIN_URL = '/accounts/login/'
118-
LOGIN_REDIRECT_URL = '/admin/'
117+
LOGIN_URL = '/user/login/'
118+
LOGIN_REDIRECT_URL = '/'
119119

120120
# Security settings
121121
CORS_ALLOW_CREDENTIALS = True
@@ -171,9 +171,6 @@
171171
'DEFAULT_PERMISSION_CLASSES': (
172172
'rest_framework.permissions.IsAuthenticated',
173173
),
174-
'DEFAULT_AUTHENTICATION_CLASSES': (
175-
'rest_framework.authentication.TokenAuthentication',
176-
),
177174
'DEFAULT_RENDERER_CLASSES': (
178175
'rest_framework.renderers.JSONRenderer',
179176
),
@@ -373,6 +370,8 @@
373370
}
374371
REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = (
375372
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
373+
'rest_framework.authentication.SessionAuthentication',
374+
'rest_framework.authentication.BasicAuthentication',
376375
)
377376

378377
EMAIL_HOST = os.environ.get('EMAIL_HOST', '')

rootfs/api/static/Heroku_Login_files/app-a26e92cde3afe8d5333ec54d0608aca2.css renamed to rootfs/api/static/css/app-a26e92cde3afe8d5333ec54d0608aca2.css

File renamed without changes.

0 commit comments

Comments
 (0)