Add submission module

This commit is contained in:
Chiaki
2017-05-08 17:29:01 +08:00
parent 25dd57bb49
commit 65f9c7f52b
20 changed files with 410 additions and 3 deletions

View File

@@ -1,9 +1,10 @@
from django.conf.urls import url
from ..views.user import (SSOAPI, AvatarUploadAPI, TwoFactorAuthAPI,
UserInfoAPI, UserProfileAPI)
UserNameAPI, UserInfoAPI, UserProfileAPI)
urlpatterns = [
url(r"^username/?$", UserNameAPI.as_view(), name="user_name_api"),
url(r"^user/(?P<username>\w+)/?$", UserInfoAPI.as_view(), name="user_info_api"),
url(r"^profile/?$", UserProfileAPI.as_view(), name="user_profile_api"),
url(r"^avatar/upload/?$", AvatarUploadAPI.as_view(), name="avatar_upload_api"),

View File

@@ -19,6 +19,24 @@ from ..serializers import (SSOSerializer, TwoFactorAuthCodeSerializer,
EditUserProfileSerializer, AvatarUploadForm)
class UserNameAPI(APIView):
def get(self, request):
"""
Return Username to valid login status
"""
try:
user = User.objects.get(id=request.user.id)
except User.DoesNotExist:
return self.success({
"username": "User does not exist",
"isLogin": False
})
return self.success({
"username": user.username,
"isLogin": True
})
class UserInfoAPI(APIView):
# @login_required
@method_decorator(ensure_csrf_cookie)