2 Commits
v1.13 ... v1.15

Author SHA1 Message Date
RobbieHan
4570252f6d role create&update&list 2018-11-14 13:44:27 +08:00
RobbieHan
0f6bd53883 menu update 2018-11-12 22:05:32 +08:00
17 changed files with 621 additions and 137 deletions

232
.idea/workspace.xml generated
View File

@@ -2,10 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="80da5b45-7eca-459a-bbe3-5443bc141768" name="Default" comment="">
<change beforePath="" afterPath="$PROJECT_DIR$/templates/system/menu_list.html" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/apps/system/urls.py" afterPath="$PROJECT_DIR$/apps/system/urls.py" />
<change beforePath="$PROJECT_DIR$/apps/system/views_menu.py" afterPath="$PROJECT_DIR$/apps/system/views_menu.py" />
<change beforePath="$PROJECT_DIR$/db.sqlite3" afterPath="$PROJECT_DIR$/db.sqlite3" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@@ -18,58 +16,13 @@
<option name="myCustomStartScript" value="import sys; print('Python %s on %s' % (sys.version, sys.platform))&#10;import django; print('Django %s' % django.get_version())&#10;sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])&#10;if 'setup' in dir(django): django.setup()&#10;import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="urls.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/apps/system/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="28" lean-forward="false" selection-start-line="0" selection-start-column="28" selection-end-line="0" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="views_menu.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/apps/system/views_menu.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="19" column="36" lean-forward="false" selection-start-line="19" selection-start-column="36" selection-end-line="19" selection-end-column="36" />
<folding>
<element signature="e#77#130#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="views_structure.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/apps/system/views_structure.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="5" lean-forward="false" selection-start-line="14" selection-start-column="5" selection-end-line="14" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="custom.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/apps/custom.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
<folding>
<element signature="e#73#84#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="HTML File" />
<option value="Python Script" />
<option value="HTML File" />
</list>
</option>
</component>
@@ -107,14 +60,19 @@
<option value="$PROJECT_DIR$/apps/system/views_user.py" />
<option value="$PROJECT_DIR$/apps/system/forms.py" />
<option value="$PROJECT_DIR$/apps/system/views.menu.py" />
<option value="$PROJECT_DIR$/apps/custom.py" />
<option value="$PROJECT_DIR$/templates/system/menu_form.html" />
<option value="$PROJECT_DIR$/templates/system/menu_list.html" />
<option value="$PROJECT_DIR$/apps/system/apps.py" />
<option value="$PROJECT_DIR$/sandboxMP/settings.py" />
<option value="$PROJECT_DIR$/apps/system/views_structure.py" />
<option value="$PROJECT_DIR$/templates/system/menu_update.html" />
<option value="$PROJECT_DIR$/templates/system/menu_list.html" />
<option value="$PROJECT_DIR$/apps/custom.py" />
<option value="$PROJECT_DIR$/templates/system/role_create.html" />
<option value="$PROJECT_DIR$/apps/system/views_menu.py" />
<option value="$PROJECT_DIR$/templates/system/role_update.html" />
<option value="$PROJECT_DIR$/apps/system/urls.py" />
<option value="$PROJECT_DIR$/apps/system/views_role.py" />
<option value="$PROJECT_DIR$/templates/system/role.html" />
</list>
</option>
</component>
@@ -124,11 +82,11 @@
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="-1379" />
<option name="y" value="113" />
<option name="width" value="1456" />
<option name="height" value="876" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="1936" />
<option name="height" value="1056" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
@@ -162,6 +120,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<expand>
@@ -177,20 +136,24 @@
<path>
<item name="sandboxMP" type="b2602c69:ProjectViewProjectNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
<item name="apps" type="462c0819:PsiDirectoryNode" />
<item name="system" type="462c0819:PsiDirectoryNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sandboxMP" type="b2602c69:ProjectViewProjectNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
<item name="templates" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sandboxMP" type="b2602c69:ProjectViewProjectNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
<item name="templates" type="462c0819:PsiDirectoryNode" />
<item name="system" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
@@ -283,16 +246,16 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-1448" y="-8" width="1456" height="876" extended-state="7" />
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24156693" sideWeight="0.5042644" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23274696" sideWeight="0.49573562" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.1936888" sideWeight="0.49573562" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Mongo Explorer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2012894" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.14978679" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="SciView" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@@ -300,13 +263,27 @@
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.21650879" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24156693" sideWeight="0.5042644" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23274696" sideWeight="0.49573562" order="2" side_tool="false" content_ui="tabs" />
<window_info id="manage.py@sandboxMP" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.28073993" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Mongo Explorer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2012894" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="SciView" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.18656716" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.21650879" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -322,41 +299,6 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/sandboxMP/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="374">
<caret line="29" column="63" lean-forward="false" selection-start-line="29" selection-start-column="63" selection-end-line="29" selection-end-column="63" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views_user.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221">
<caret line="20" column="6" lean-forward="false" selection-start-line="20" selection-start-column="6" selection-end-line="20" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="0" lean-forward="true" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sandboxMP/settings.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/static/bootstrap/js/npm.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="12" column="28" lean-forward="true" selection-start-line="12" selection-start-column="28" selection-end-line="12" selection-end-column="28" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
@@ -545,9 +487,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="230">
<caret line="472" column="4" lean-forward="false" selection-start-line="472" selection-start-column="4" selection-end-line="472" selection-end-column="4" />
<folding>
<element signature="e#99#134#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@@ -608,7 +547,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" column="0" lean-forward="true" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
@@ -638,14 +576,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/menu_list.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2177">
<caret line="149" column="14" lean-forward="false" selection-start-line="149" selection-start-column="14" selection-end-line="149" selection-end-column="14" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/Envs/sandboxMP/Lib/site-packages/django/views/generic/base.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="197">
@@ -699,16 +629,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views_menu.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="19" column="36" lean-forward="false" selection-start-line="19" selection-start-column="36" selection-end-line="19" selection-end-column="36" />
<folding>
<element signature="e#77#130#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views_structure.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
@@ -717,21 +637,83 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/menu_update.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="623">
<caret line="100" column="0" lean-forward="true" selection-start-line="100" selection-start-column="0" selection-end-line="100" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/menu_list.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="606">
<caret line="160" column="11" lean-forward="true" selection-start-line="160" selection-start-column="11" selection-end-line="160" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/custom.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
<state relative-caret-position="691">
<caret line="55" column="53" lean-forward="true" selection-start-line="55" selection-start-column="53" selection-end-line="55" selection-end-column="53" />
<folding>
<element signature="e#73#84#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/role_update.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="657">
<caret line="80" column="14" lean-forward="false" selection-start-line="80" selection-start-column="14" selection-end-line="80" selection-end-column="14" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views_role.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="595">
<caret line="35" column="28" lean-forward="false" selection-start-line="35" selection-start-column="28" selection-end-line="35" selection-end-column="28" />
<folding>
<element signature="e#78#89#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views_menu.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="16" lean-forward="true" selection-start-line="8" selection-start-column="16" selection-end-line="9" selection-end-column="22" />
<folding>
<element signature="e#0#41#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/role.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="657">
<caret line="145" column="1" lean-forward="true" selection-start-line="145" selection-start-column="1" selection-end-line="145" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/role_form.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="504">
<caret line="70" column="11" lean-forward="true" selection-start-line="70" selection-start-column="11" selection-end-line="70" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="28" lean-forward="false" selection-start-line="0" selection-start-column="28" selection-end-line="0" selection-end-column="28" />
<folding />
<state relative-caret-position="578">
<caret line="34" column="0" lean-forward="true" selection-start-line="34" selection-start-column="0" selection-end-line="34" selection-end-column="0" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
</state>
</provider>
</entry>

View File

@@ -4,13 +4,34 @@
import json
from django.views.generic import CreateView
from django.views.generic import CreateView, UpdateView
from django.shortcuts import HttpResponse
from django.http import Http404
from system.mixin import LoginRequiredMixin
class SimpleInfoCreateView(LoginRequiredMixin, CreateView):
class SandboxGetObjectMixin:
def get_object(self, queryset=None):
if queryset is None:
queryset = self.get_queryset()
if 'id' in self.request.GET and self.request.GET['id']:
queryset = queryset.filter(id=int(self.request.GET['id']))
elif 'id' in self.request.POST and self.request.POST['id']:
queryset = queryset.filter(id=int(self.request.POST['id']))
else:
raise AttributeError("Generic detail view %s must be called with id. "
% self.__class__.__name__)
try:
obj = queryset.get()
except queryset.model.DoesNotExist:
raise Http404("No %(verbose_name)s found matching the query" %
{'verbose_name': queryset.model._meta.verbose_name})
return obj
class SandboxEditViewMixin:
def post(self, request, *args, **kwargs):
res = dict(result=False)
@@ -19,3 +40,17 @@ class SimpleInfoCreateView(LoginRequiredMixin, CreateView):
form.save()
res['result'] = True
return HttpResponse(json.dumps(res), content_type='application/json')
class SandboxCreateView(LoginRequiredMixin, SandboxEditViewMixin, CreateView):
""""
View for create an object, with a response rendered by a template.
Returns information with Json when the data is created successfully or fails.
"""
class SandboxUpdateView(LoginRequiredMixin, SandboxEditViewMixin, SandboxGetObjectMixin, UpdateView):
def post(self, request, *args, **kwargs):
self.object = self.get_object()
return super().post(request, *args, **kwargs)

Binary file not shown.

View File

@@ -1,7 +1,7 @@
from django.urls import path
from .views import SystemView
from . import views_structure, views_user, views_menu
from . import views_structure, views_user, views_menu, views_role
app_name = 'system'
@@ -25,6 +25,10 @@ urlpatterns = [
path('rbac/menu/', views_menu.MenuListView.as_view(), name='rbac-menu'),
path('rbac/menu/create/', views_menu.MenuCreateView.as_view(), name='rbac-menu-create'),
path('rbac/menu/update/', views_menu.MenuUpdateView.as_view(), name='rbac-menu-update'),
path('rbac/role/', views_role.RoleView.as_view(), name='rbac-role'),
path('rbac/role/create/', views_role.RoleCreateView.as_view(), name='rbac-role-create'),
path('rbac/role/list/', views_role.RoleListView.as_view(), name='rbac-role-list'),
path('rbac/role/update/', views_role.RoleUpdateView.as_view(), name='rbac-role-update'),
]

View File

@@ -1,15 +1,11 @@
# @Time : 2018/11/9 12:24
# @Author : RobbieHan
# @File : views.menu.py
from django.views.generic import ListView, UpdateView
from django.views.generic import ListView
from .mixin import LoginRequiredMixin
from apps.custom import SimpleInfoCreateView
from apps.custom import SandboxCreateView, SandboxUpdateView
from .models import Menu
class MenuCreateView(SimpleInfoCreateView):
class MenuCreateView(SandboxCreateView):
model = Menu
fields = '__all__'
extra_context = dict(menu_all=Menu.objects.all())
@@ -18,3 +14,10 @@ class MenuCreateView(SimpleInfoCreateView):
class MenuListView(LoginRequiredMixin, ListView):
model = Menu
context_object_name = 'menu_all'
class MenuUpdateView(SandboxUpdateView):
model = Menu
fields = '__all__'
template_name_suffix = '_update'
extra_context = dict(menu_all=Menu.objects.all())

36
apps/system/views_role.py Normal file
View File

@@ -0,0 +1,36 @@
# @Time : 2018/11/13 23:25
# @Author : RobbieHan
# @File : views_role.py
import json
from django.views.generic.base import View
from django.shortcuts import HttpResponse
from django.views.generic import TemplateView
from .mixin import LoginRequiredMixin
from .models import Role
from custom import SandboxCreateView, SandboxUpdateView
class RoleView(LoginRequiredMixin, TemplateView):
template_name = 'system/role.html'
class RoleCreateView(SandboxCreateView):
model = Role
fields = '__all__'
class RoleListView(LoginRequiredMixin, View):
def get(self, reqeust):
fields = ['id', 'name', 'desc']
ret = dict(data=list(Role.objects.values(*fields)))
return HttpResponse(json.dumps(ret), content_type='application/json')
class RoleUpdateView(SandboxUpdateView):
model = Role
fields = '__all__'
template_name_suffix = '_update'

Binary file not shown.

View File

@@ -141,10 +141,24 @@
content: "{% url 'system:rbac-menu-create' %}",
end: function () {
//关闭时做的事情
oDataTable.data.reload();
window.location.reload();
}
});
});
function doUpdate(id) {
layer.open({
type: 2,
title: '编辑',
shadeClose: false,
maxmin: true,
area: ['800px', '400px'],
content: ["{% url 'system:rbac-menu-update' %}" + '?id=' + id, 'no'],
end: function () {
//关闭时做的事情
window.location.reload();
}
});
}
</script>
{% endblock %}

View File

@@ -0,0 +1,100 @@
{% extends 'base-layer.html' %}
{% load staticfiles %}
{% block css %}
<link rel="stylesheet" href="{% static 'plugins/select2/select2.min.css' %}">
{% endblock %}
{% block main %}
<div class="box box-danger">
<form class="form-horizontal" id="addForm" method="post">
{% csrf_token %}
<input type="hidden" name='id' value="{{ menu.id }}"/>
<div class="box-body">
<fieldset>
<legend>
<h4>修改菜单</h4>
</legend>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">名称</label>
<div class="col-sm-3">
<input class="form-control" name="name" type="text" value="{{ menu.name }}"/>
</div>
<label class="col-sm-2 control-label">代码</label>
<div class="col-sm-3">
<input class="form-control" name="code" type="text" value="{{ menu.code }}"/>
</div>
</div>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">图标</label>
<div class="col-sm-3">
<input class="form-control" name="icon" type="text" value="{{ menu.icon | default:'' }}"/>
</div>
<label class="col-sm-2 control-label">父菜单</label>
<div class="col-sm-3">
<select class="form-control select2" name="parent">
<option value="{{ menu.parent.id }}">{{ menu.parent.name }}</option>
{% for parent_menu in menu_all %}
<option value={{ parent_menu.id }}> {{ parent_menu.name }} </option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">URL</label>
<div class="col-sm-8">
<input class="form-control" name="url" type="text" value="{{ menu.url | default:'' }}"/>
</div>
</div>
</fieldset>
</div>
<div class="box-footer ">
<div class="row span7 text-center ">
<button type="button" id="btnCancel" class="btn btn-default margin-right ">重置</button>
<button type="button" id="btnSave" class="btn btn-info margin-right ">保存</button>
</div>
</div>
</form>
</div>
{% endblock %}
{% block javascripts %}
<script src="{% static 'plugins/select2/select2.full.min.js' %}"></script>
<script type="text/javascript">
$("#btnSave").click(function () {
var data = $("#addForm").serialize();
$.ajax({
type: $("#addForm").attr('method'),
url: "{% url 'system:rbac-menu-update' %}",
data: data,
cache: false,
success: function (msg) {
if (msg.result) {
layer.alert('数据保存成功!', {icon: 1}, function (index) {
parent.layer.closeAll(); //关闭所有弹窗
});
} else {
layer.alert('数据保存失败', {icon: 5});
//$('errorMessage').html(msg.message)
}
return;
}
});
});
/*点取消刷新新页面*/
$("#btnCancel").click(function () {
window.location.reload();
});
$(function () {
//Initialize Select2 Elements
$(".select2").select2();
});
</script>
{% endblock %}

149
templates/system/role.html Normal file
View File

@@ -0,0 +1,149 @@
{% extends "base-left.html" %}
{% load staticfiles %}
{% block css %}
<link rel="stylesheet" href="{% static 'plugins/datatables/jquery.dataTables.min.css' %}">
<link rel="stylesheet" href="{% static 'js/plugins/layer/skin/layer.css' %}">
{% endblock %}
{% block content %}
<!-- Main content -->
<section class="content">
<div id="devlist">
<div class="box box-primary" id="liebiao">
<div class="box-header">
<div class="btn-group pull-left">
<button type="button" id="btnRefresh" class="btn btn-default">
<i class="glyphicon glyphicon-repeat"></i>刷新
</button>
</div>
<div class="btn-group pull-left">&nbsp</div>
<div class="btn-group pull-left">
<button type="button" id="btnCreate" class="btn btn-default">
<i class="glyphicon glyphicon-plus"></i>新增
</button>
</div>
<div class="btn-group pull-left">&nbsp</div>
<div class="btn-group pull-left">
<button type="button" id="btnDelete" class="btn btn-default">
<i class="glyphicon glyphicon-trash"></i>删除
</button>
</div>
</div>
<div class="box-body">
<table id="dtbList" class="display" cellspacing="0" width="100%">
<thead>
<tr valign="middle">
<th><input type="checkbox" id="checkAll"></th>
<th>ID</th>
<th>名称</th>
<th>说明</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<br> <br>
</div>
</div>
</div>
</section>
<!-- /.content -->
{% endblock %}
{% block javascripts %}
<script src="{% static 'plugins/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'plugins/datatables/dataTables.const.js' %}"></script>
<script src="{% static 'js/plugins/layer/layer.js' %}"></script>
<script type="text/javascript">
var oDataTable = null;
$(function () {
oDataTable = initTable();
function initTable() {
var oTable = $('#dtbList').DataTable($.extend(true, {},
DATATABLES_CONSTANT.DATA_TABLES.DEFAULT_OPTION,
{
ajax: {
"url": "{% url 'system:rbac-role-list' %}",
},
columns: [
DATATABLES_CONSTANT.DATA_TABLES.COLUMN.CHECKBOX,
{
data: "id",
width: "5%",
},
{
data: "name",
//width : "20%",
},
{
data: "desc",
//width : "20%",
},
{
data: "id",
width: "16%",
bSortable: "false",
render: function (data, type, row, meta) {
var ret = "";
var ret = "<button title='详情-编辑' onclick='doUpdate("
+ data + ")'><i class='glyphicon glyphicon-pencil'></i></button>";
ret = ret + "<button title='关联用户' onclick='doUpdateUser("
+ data + ")'><i class='glyphicon glyphicon-user'></i></button>";
ret = ret + "<button title='关联菜单' onclick='doUpdateMenu("
+ data + ")'><i class='glyphicon glyphicon-tree-conifer'></i></button>";
ret = ret + "<button title='删除' onclick='doDelete("
+ data + ")'><i class='glyphicon glyphicon-trash'></i></button>";
return ret;
}
}],
}));
return oTable;
}
});
$("#btnCreate").click(function () {
layer.open({
type: 2,
title: '新增',
shadeClose: false,
maxmin: true,
area: ['800px', '300px'],
content: "{% url 'system:rbac-role-create' %}",
end: function () {
//关闭时做的事情
oDataTable.ajax.reload();
}
});
});
$("#btnRefresh").click(function () {
oDataTable.ajax.reload();
});
function doUpdate(id) {
layer.open({
type: 2,
title: '编辑',
shadeClose: false,
maxmin: true,
area: ['800px', '400px'],
content: ["{% url 'system:rbac-role-update' %}" + '?id=' + id, 'no'],
end: function () {
oDataTable.ajax.reload();
}
});
}
</script>
{% endblock %}

View File

@@ -0,0 +1,80 @@
{% extends 'base-layer.html' %}
{% load staticfiles %}
{% block main %}
<div class="box box-danger">
<form class="form-horizontal" id="addForm" method="post">
{% csrf_token %}
<div class="box-body">
<fieldset>
<legend>
<h4>新建角色</h4>
</legend>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">名称</label>
<div class="col-sm-8">
<input class="form-control" name="name" type="text" />
</div>
</div>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">描述</label>
<div class="col-sm-8">
<input class="form-control" name="desc" type="text" />
</div>
</div>
</fieldset>
</div>
<div class="box-footer ">
<div class="row span7 text-center ">
<button type="button" id="btnCancel" class="btn btn-default margin-right ">重置</button>
<button type="button" id="btnSave" class="btn btn-info margin-right ">保存</button>
</div>
</div>
</form>
</div>
{% endblock %}
{% block javascripts %}
<script src="{% static 'plugins/combo-select/jquery.combo.select.js' %}"></script>
<script src="{% static 'bootstrap/js/bootstrap-datetimepicker.js' %}"></script>
<script type="text/javascript">
$("#btnSave").click(function () {
var data = $("#addForm").serialize();
$.ajax({
type: $("#addForm").attr('method'),
url: "{% url 'system:rbac-role-create' %}",
data: data,
cache: false,
success: function (msg) {
if (msg.result) {
layer.alert('数据保存成功!', {icon: 1}, function (index) {
parent.layer.closeAll(); //关闭所有弹窗
});
} else {
layer.alert('数据保存失败', {icon: 5});
//$('errorMessage').html(msg.message)
}
return;
}
});
});
/*点取消刷新新页面*/
$("#btnCancel").click(function () {
window.location.reload();
});
/*select 支持输入检索*/
$(function () {
$('select').comboSelect();
});
</script>
{% endblock %}

View File

@@ -0,0 +1,81 @@
{% extends 'base-layer.html' %}
{% load staticfiles %}
{% block main %}
<div class="box box-danger">
<form class="form-horizontal" id="addForm" method="post">
{% csrf_token %}
<input type="hidden" name='id' value="{{ role.id }}"/>
<div class="box-body">
<fieldset>
<legend>
<h4>修改角色</h4>
</legend>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">名称</label>
<div class="col-sm-8">
<input class="form-control" name="name" type="text" value="{{ role.name }}"/>
</div>
</div>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">描述</label>
<div class="col-sm-8">
<input class="form-control" name="desc" type="text" value="{{ role.desc }}"/>
</div>
</div>
</fieldset>
</div>
<div class="box-footer ">
<div class="row span7 text-center ">
<button type="button" id="btnCancel" class="btn btn-default margin-right ">重置</button>
<button type="button" id="btnSave" class="btn btn-info margin-right ">保存</button>
</div>
</div>
</form>
</div>
{% endblock %}
{% block javascripts %}
<script src="{% static 'plugins/combo-select/jquery.combo.select.js' %}"></script>
<script src="{% static 'bootstrap/js/bootstrap-datetimepicker.js' %}"></script>
<script type="text/javascript">
$("#btnSave").click(function () {
var data = $("#addForm").serialize();
$.ajax({
type: $("#addForm").attr('method'),
url: "{% url 'system:rbac-role-update' %}",
data: data,
cache: false,
success: function (msg) {
if (msg.result) {
layer.alert('数据保存成功!', {icon: 1}, function (index) {
parent.layer.closeAll(); //关闭所有弹窗
});
} else {
layer.alert('数据保存失败', {icon: 5});
//$('errorMessage').html(msg.message)
}
return;
}
});
});
/*点取消刷新新页面*/
$("#btnCancel").click(function () {
window.location.reload();
});
/*select 支持输入检索*/
$(function () {
$('select').comboSelect();
});
</script>
{% endblock %}