diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5737775..6224d59 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,9 +5,7 @@ - - @@ -24,8 +22,8 @@ - - + + @@ -36,8 +34,8 @@ - - + + @@ -45,47 +43,47 @@ - - + + - - + + - + - - + + - - + + + + + + + + + + + + + + - - - - - - - - - - - - - + @@ -120,11 +118,15 @@ - - - + + + + + + + @@ -134,7 +136,7 @@ true DEFINITION_ORDER - + @@ -172,7 +174,7 @@ - + @@ -188,32 +190,20 @@ - - - - - - + - - - - - - - - + - + @@ -225,15 +215,16 @@ - - - + - + + + + @@ -299,14 +290,14 @@ - + - + @@ -314,8 +305,8 @@ - + @@ -339,83 +330,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -473,13 +387,6 @@ - - - - - - - @@ -508,13 +415,6 @@ - - - - - - - @@ -565,13 +465,6 @@ - - - - - - - @@ -586,14 +479,6 @@ - - - - - - - - @@ -608,13 +493,6 @@ - - - - - - - @@ -661,50 +539,190 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/__pycache__/custom.cpython-36.pyc b/apps/__pycache__/custom.cpython-36.pyc new file mode 100644 index 0000000..4c1262f Binary files /dev/null and b/apps/__pycache__/custom.cpython-36.pyc differ diff --git a/apps/custom.py b/apps/custom.py new file mode 100644 index 0000000..67e2975 --- /dev/null +++ b/apps/custom.py @@ -0,0 +1,21 @@ +# @Time : 2018/11/9 22:06 +# @Author : RobbieHan +# @File : custom.py + +import json + +from django.views.generic import CreateView +from django.shortcuts import HttpResponse + +from system.mixin import LoginRequiredMixin + + +class SimpleInfoCreateView(LoginRequiredMixin, CreateView): + + def post(self, request, *args, **kwargs): + res = dict(result=False) + form = self.get_form() + if form.is_valid(): + form.save() + res['result'] = True + return HttpResponse(json.dumps(res), content_type='application/json') diff --git a/apps/system/__pycache__/forms.cpython-36.pyc b/apps/system/__pycache__/forms.cpython-36.pyc index a4f30b7..56b28e7 100644 Binary files a/apps/system/__pycache__/forms.cpython-36.pyc and b/apps/system/__pycache__/forms.cpython-36.pyc differ diff --git a/apps/system/__pycache__/models.cpython-36.pyc b/apps/system/__pycache__/models.cpython-36.pyc index e2c321e..5f4dd80 100644 Binary files a/apps/system/__pycache__/models.cpython-36.pyc and b/apps/system/__pycache__/models.cpython-36.pyc differ diff --git a/apps/system/__pycache__/urls.cpython-36.pyc b/apps/system/__pycache__/urls.cpython-36.pyc index c7b32f5..6bf5a5c 100644 Binary files a/apps/system/__pycache__/urls.cpython-36.pyc and b/apps/system/__pycache__/urls.cpython-36.pyc differ diff --git a/apps/system/__pycache__/views_menu.cpython-36.pyc b/apps/system/__pycache__/views_menu.cpython-36.pyc new file mode 100644 index 0000000..11b3e31 Binary files /dev/null and b/apps/system/__pycache__/views_menu.cpython-36.pyc differ diff --git a/apps/system/__pycache__/views_structure.cpython-36.pyc b/apps/system/__pycache__/views_structure.cpython-36.pyc index a931d6a..2b4d80b 100644 Binary files a/apps/system/__pycache__/views_structure.cpython-36.pyc and b/apps/system/__pycache__/views_structure.cpython-36.pyc differ diff --git a/apps/system/__pycache__/views_user.cpython-36.pyc b/apps/system/__pycache__/views_user.cpython-36.pyc index 9009685..4f7f5e7 100644 Binary files a/apps/system/__pycache__/views_user.cpython-36.pyc and b/apps/system/__pycache__/views_user.cpython-36.pyc differ diff --git a/apps/system/forms.py b/apps/system/forms.py index 58cb4c0..4f9761f 100644 --- a/apps/system/forms.py +++ b/apps/system/forms.py @@ -6,7 +6,7 @@ import re from django import forms from django.contrib.auth import get_user_model -from .models import Structure +from .models import Structure, Menu User = get_user_model() @@ -118,4 +118,10 @@ class PasswordChangeForm(forms.Form): password = cleaned_data.get("password") confirm_password = cleaned_data.get("confirm_password") if password != confirm_password: - raise forms.ValidationError("两次密码输入不一致") \ No newline at end of file + raise forms.ValidationError("两次密码输入不一致") + + +class MenuForm(forms.ModelForm): + class Meta: + model = Menu + fields = '__all__' diff --git a/apps/system/urls.py b/apps/system/urls.py index 7f45c89..47bfdb2 100644 --- a/apps/system/urls.py +++ b/apps/system/urls.py @@ -1,7 +1,7 @@ from django.urls import path, re_path from .views import SystemView -from . import views_structure, views_user +from . import views_structure, views_user, views_menu app_name = 'system' @@ -22,4 +22,6 @@ urlpatterns = [ path('basic/user/delete/', views_user.UserDeleteView.as_view(), name='basic-user-delete'), path('basic/user/enable/', views_user.UserEnableView.as_view(), name='basic-user-enable'), path('basic/user/disable/', views_user.UserDisableView.as_view(), name='basic-user-disable'), + + path('rbac/menu/create/', views_menu.MenuCreateView.as_view(), name='rbac-menu-create'), ] diff --git a/apps/system/views_menu.py b/apps/system/views_menu.py new file mode 100644 index 0000000..f522b10 --- /dev/null +++ b/apps/system/views_menu.py @@ -0,0 +1,17 @@ +# @Time : 2018/11/9 12:24 +# @Author : RobbieHan +# @File : views.menu.py + +from apps.custom import SimpleInfoCreateView +from .models import Menu + + +class MenuCreateView(SimpleInfoCreateView): + model = Menu + fields = '__all__' + extra_context = dict(menu_all=Menu.objects.all()) + + + + + diff --git a/db.sqlite3 b/db.sqlite3 index 1977f0d..4153a6b 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/sandboxMP/__pycache__/urls.cpython-36.pyc b/sandboxMP/__pycache__/urls.cpython-36.pyc index 4b44540..fb9f7a1 100644 Binary files a/sandboxMP/__pycache__/urls.cpython-36.pyc and b/sandboxMP/__pycache__/urls.cpython-36.pyc differ diff --git a/templates/system/menu_form.html b/templates/system/menu_form.html new file mode 100644 index 0000000..d681c13 --- /dev/null +++ b/templates/system/menu_form.html @@ -0,0 +1,101 @@ +{% extends 'base-layer.html' %} +{% load staticfiles %} +{% block css %} + + +{% endblock %} +{% block main %} + + + {% csrf_token %} + + + + 添加菜单 + + + 名称 + + + + 代码 + + + + + + 图标 + + + + 父菜单 + + + {{ menu.parent.name }} + {% for parent_menu in menu_all %} + {{ parent_menu.name }} + {% endfor %} + + + + + URL + + + + + + + + + + + + +{% endblock %} + +{% block javascripts %} + + + +{% endblock %}