From 6f5c9b165702111644ceaf62cb8ae3826cfc15bb Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Sun, 9 Aug 2015 12:58:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=85=B3=E7=9A=84?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E7=9A=84=E5=AE=9A=E4=B9=89=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?url=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account/models.py | 5 +++++ oj/settings.py | 2 ++ oj/urls.py | 9 ++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/account/models.py b/account/models.py index a724f5a..df25329 100644 --- a/account/models.py +++ b/account/models.py @@ -14,6 +14,11 @@ class UserManager(models.Manager): return self.get(**{self.model.USERNAME_FIELD: username}) +REGULAR_USER = 0 +ADMIN = 1 +SUPER_ADMIN = 2 + + class User(AbstractBaseUser): # 用户名 username = models.CharField(max_length=30, unique=True) diff --git a/oj/settings.py b/oj/settings.py index 910914c..c8a07ec 100644 --- a/oj/settings.py +++ b/oj/settings.py @@ -49,6 +49,7 @@ INSTALLED_APPS = ( 'account', 'announcement', 'utils', + 'group', 'rest_framework', 'rest_framework_swagger', @@ -63,6 +64,7 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', + 'admin.middleware.AdminRequiredMiddleware' ) ROOT_URLCONF = 'oj.urls' diff --git a/oj/urls.py b/oj/urls.py index a69c8ee..b2eecb9 100644 --- a/oj/urls.py +++ b/oj/urls.py @@ -3,9 +3,11 @@ from django.conf.urls import include, url from django.contrib import admin from django.views.generic import TemplateView -from account.views import UserLoginAPIView, UsernameCheckAPIView, UserRegisterAPIView, UserChangePasswordAPIView, \ - EmailCheckAPIView, UserAPIView, UserAdminAPIView +from account.views import (UserLoginAPIView, UsernameCheckAPIView, UserRegisterAPIView, + UserChangePasswordAPIView, EmailCheckAPIView, + UserAPIView, UserAdminAPIView) from announcement.views import AnnouncementAPIView, AnnouncementAdminAPIView +from group.views import GroupAdminAPIView from admin.views import AdminTemplateView urlpatterns = [ @@ -29,5 +31,6 @@ urlpatterns = [ url(r'^admin/contest/$', TemplateView.as_view(template_name="admin/contest/add_contest.html"), name="add_contest_page"), url(r'^problems/$', TemplateView.as_view(template_name="oj/problem/problem_list.html"), name="problem_list_page"), - url(r'^admin/template/(?P\w+)/(?P\w+).html', AdminTemplateView.as_view(), name="admin_template") + url(r'^admin/template/(?P\w+)/(?P\w+).html', AdminTemplateView.as_view(), name="admin_template"), + url(r'^api/admin/group/$', GroupAdminAPIView.as_view(), name="group_admin_api"), ]