diff --git a/README.md b/README.md index 925508e..29ac949 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # 海豹 - +![版本](https://img.shields.io/badge/release-0.1-blue.svg) +![语言](https://img.shields.io/badge/language-python3.6-blue.svg) +![语言](https://img.shields.io/badge/env-django2.1-red.svg) +![bootstrap4](https://img.shields.io/badge/model-bootstrap4-mauve.svg) > django-base-templastes > 因本项目开始时间为3月1日,是 国际海豹日,故项目起名为 海豹 seal @@ -7,13 +10,12 @@ > 主要为 django 基础开发平台, MVC 模式 开发.(非前后端分离) ,可以拿来直接开发 django项目。作者会在周末进行开发、更新。 -## 版本 -* v0.1 - ## 介绍 -* 基于bootstrap4+django2.1+python3.7(兼容3.6)+celery异步任务 +* 基于bootstrap4+django2.1+python3.6+celery异步任务 +* 前端模板 inspinia 2.9 * 会尽量多加一些注释 * 采用cbv开发方式,提高开发效率 +* python3.7 兼容性未做测试 ## DEMO @@ -23,13 +25,18 @@ ## templates -* base 网页基本模板 -* system 平台基本网页(首页/登录/修改密码) -* assets 资产管理 (增删改查例子) +* base 网页基本模板 +* system 平台基本网页(首页/登录/修改密码) +* assets 资产管理 (增删改查例子) +* document 代码规范 + + ## 部署 ```bash +yum install python-devel mysql-devel -y + git clone https://github.com/hequan2017/seal cd seal python install -r requirements.txt @@ -65,8 +72,6 @@ for i in Users.objects.all(): ``` - - ### 售后服务 * 有问题 可以加QQ群: 620176501 django开发讨论群 diff --git a/assets/views.py b/assets/views.py index 31acab5..0dc889c 100644 --- a/assets/views.py +++ b/assets/views.py @@ -26,6 +26,7 @@ class EcsCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView): template_name = 'assets/ecs-create.html' success_url = reverse_lazy('assets:ecs-list') + def get_context_data(self, **kwargs): context = {} if '__next__' in self.request.POST: # 为了获取 点击本页之前的 浏览网页 @@ -53,6 +54,7 @@ class EcsCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView): + class EcsListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): permission_required = ('assets.view_ecs',) template_name = 'assets/ecs-list.html' diff --git a/document/代码规范.md b/document/代码规范.md index 75826fa..4da28b2 100644 --- a/document/代码规范.md +++ b/document/代码规范.md @@ -157,13 +157,13 @@ def bar(): ### 注释(Comment)类 函数 注释 ``` -def AvailableZones(self, instance_charge_type, region_id): +def index(request): """ - 功能: 可用区 - :param instance_charge_type: 计费方式 - :param region_id: 地域 - :return: ['cn-huhehaote-a', 'cn-huhehaote-b'] + 首页 + :param request: + :return: """ + ``` diff --git a/requirements.txt b/requirements.txt index 1e53c77..5f16a27 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,13 +16,13 @@ ipython==6.4.0 ipython-genutils==0.2.0 jedi==0.12.0 kombu==4.4.0 +mysqlclient==1.4.2.post1 parso==0.2.1 pexpect==4.6.0 pickleshare==0.7.4 prompt-toolkit==1.0.15 ptyprocess==0.5.2 Pygments==2.2.0 -PyMySQL==0.9.3 python-crontab==2.3.6 python-dateutil==2.8.0 pytz==2018.4 @@ -33,4 +33,4 @@ six==1.11.0 traitlets==4.3.2 urllib3==1.24.1 vine==1.2.0 -wcwidth==0.1.7 +wcwidth==0.1.7 \ No newline at end of file diff --git a/seal/__init__.py b/seal/__init__.py index c11e35e..3e7bf86 100644 --- a/seal/__init__.py +++ b/seal/__init__.py @@ -2,5 +2,3 @@ from .celery import app as celery_app __all__ = ['celery_app'] -import pymysql -pymysql.install_as_MySQLdb() \ No newline at end of file diff --git a/seal/settings.py b/seal/settings.py index bdace14..5abaa59 100644 --- a/seal/settings.py +++ b/seal/settings.py @@ -75,7 +75,7 @@ TEMPLATES = [ WSGI_APPLICATION = 'seal.wsgi.application' AUTH_USER_MODEL = 'system.users' -AUTHENTICATION_BACKENDS = ('system.views.CustomBackend',) +AUTHENTICATION_BACKENDS = ('system.views.CustomBackend',) ## 重新登录验证,增加邮箱名字也可以用作登录 # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases @@ -121,6 +121,8 @@ AUTH_PASSWORD_VALIDATORS = [ # https://docs.djangoproject.com/en/2.1/topics/i18n/ SESSION_ENGINE = 'django.contrib.sessions.backends.db' +SESSION_COOKIE_SAMESITE = 'Lax' +CSRF_COOKIE_SAMESITE = 'Lax' SESSION_COOKIE_AGE = 432000 LOGIN_URL = '/auth/login' LANGUAGE_CODE = 'zh-Hans' diff --git a/seal/urls.py b/seal/urls.py index 05d51f0..fd21f24 100644 --- a/seal/urls.py +++ b/seal/urls.py @@ -24,4 +24,5 @@ urlpatterns = [ path('system/', include('system.urls', namespace='system')), path('assets/', include('assets.urls', namespace='assets')), path('admin/', admin.site.urls,) + ] diff --git a/system/views.py b/system/views.py index 52b3383..d49ce91 100644 --- a/system/views.py +++ b/system/views.py @@ -61,6 +61,7 @@ def login_view(request): return render(request, 'system/login.html', {'error_msg': error_msg, }) + @login_required(login_url="/system/login") def index(request): """ @@ -71,6 +72,8 @@ def index(request): return render(request, 'system/index.html') + + class UserPasswordUpdateView(LoginRequiredMixin, UpdateView): """ 修改密码 diff --git a/templates/assets/ecs-list.html b/templates/assets/ecs-list.html index 852982b..5a56ae0 100644 --- a/templates/assets/ecs-list.html +++ b/templates/assets/ecs-list.html @@ -163,6 +163,7 @@
+