用户调查
This commit is contained in:
@@ -4,7 +4,7 @@ from ..views.oj import (
|
|||||||
ApplyResetPasswordAPI,
|
ApplyResetPasswordAPI,
|
||||||
ResetPasswordAPI,
|
ResetPasswordAPI,
|
||||||
UserChangePasswordAPI,
|
UserChangePasswordAPI,
|
||||||
UserProfileAnalyse,
|
Metrics,
|
||||||
UserRegisterAPI,
|
UserRegisterAPI,
|
||||||
UserChangeEmailAPI,
|
UserChangeEmailAPI,
|
||||||
UserLoginAPI,
|
UserLoginAPI,
|
||||||
@@ -35,8 +35,8 @@ urlpatterns = [
|
|||||||
path("captcha", CaptchaAPIView.as_view()),
|
path("captcha", CaptchaAPIView.as_view()),
|
||||||
path("check_username_or_email", UsernameOrEmailCheck.as_view()),
|
path("check_username_or_email", UsernameOrEmailCheck.as_view()),
|
||||||
path("profile", UserProfileAPI.as_view(), name="user_profile_api"),
|
path("profile", UserProfileAPI.as_view(), name="user_profile_api"),
|
||||||
path("profile/analyse", UserProfileAnalyse.as_view()),
|
|
||||||
path("profile/fresh_display_id", ProfileProblemDisplayIDRefreshAPI.as_view()),
|
path("profile/fresh_display_id", ProfileProblemDisplayIDRefreshAPI.as_view()),
|
||||||
|
path("metrics", Metrics.as_view()),
|
||||||
path("upload_avatar", AvatarUploadAPI.as_view()),
|
path("upload_avatar", AvatarUploadAPI.as_view()),
|
||||||
path("tfa_required", CheckTFARequiredAPI.as_view()),
|
path("tfa_required", CheckTFARequiredAPI.as_view()),
|
||||||
path(
|
path(
|
||||||
|
|||||||
@@ -80,14 +80,22 @@ class UserProfileAPI(APIView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class UserProfileAnalyse(APIView):
|
class Metrics(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
userid = request.GET.get("userid")
|
userid = request.GET.get("userid")
|
||||||
submission = Submission.objects.filter(user_id=userid).latest("create_time")
|
submissions = Submission.objects.filter(user_id=userid)
|
||||||
if not submission:
|
if len(submissions) == 0:
|
||||||
return self.error("暂无提交")
|
return self.error("暂无提交")
|
||||||
else:
|
else:
|
||||||
return self.success({"now": timezone.now(), "last": submission.create_time})
|
latest_submission = submissions.first()
|
||||||
|
last_submission = submissions.last()
|
||||||
|
return self.success(
|
||||||
|
{
|
||||||
|
"now": timezone.now(),
|
||||||
|
"latest": latest_submission.create_time,
|
||||||
|
"first": last_submission.create_time,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AvatarUploadAPI(APIView):
|
class AvatarUploadAPI(APIView):
|
||||||
|
|||||||
Reference in New Issue
Block a user