1 Commits
v1.13 ... v1.14

Author SHA1 Message Date
RobbieHan
0f6bd53883 menu update 2018-11-12 22:05:32 +08:00
10 changed files with 257 additions and 82 deletions

165
.idea/workspace.xml generated
View File

@@ -2,10 +2,11 @@
<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/custom.py" afterPath="$PROJECT_DIR$/apps/custom.py" />
<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" />
<change beforePath="$PROJECT_DIR$/templates/system/menu_list.html" afterPath="$PROJECT_DIR$/templates/system/menu_list.html" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@@ -19,43 +20,55 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="urls.py" pinned="false" current-in-tab="true">
<file leaf-file-name="urls.py" pinned="false" current-in-tab="false">
<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" />
<state relative-caret-position="510">
<caret line="30" column="0" lean-forward="true" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" />
<folding>
<element signature="e#77#130#0" expanded="true" />
<element signature="e#0#28#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">
<file leaf-file-name="menu_update.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/templates/system/menu_update.html">
<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" />
<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>
</file>
<file leaf-file-name="menu_list.html" pinned="false" current-in-tab="false">
<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>
</file>
<file leaf-file-name="views_menu.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/apps/system/views_menu.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="391">
<caret line="23" column="0" lean-forward="true" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" />
<folding>
<element signature="e#0#41#0" expanded="true" />
</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" />
<state relative-caret-position="555">
<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>
@@ -68,8 +81,8 @@
<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 +120,15 @@
<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$/apps/system/views_menu.py" />
<option value="$PROJECT_DIR$/apps/system/urls.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$/apps/system/views_menu.py" />
</list>
</option>
</component>
@@ -162,6 +176,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
@@ -180,16 +195,10 @@
<item name="apps" type="462c0819:PsiDirectoryNode" />
<item name="system" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sandboxMP" type="b2602c69:ProjectViewProjectNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="Scratches" />
</panes>
</component>
@@ -283,30 +292,45 @@
</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" />
<editor active="true" />
<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="true" show_stripe_button="true" weight="0.23068553" 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="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1609808" 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" />
<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="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="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.26792964" 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,13 +346,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">
@@ -545,9 +562,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 +622,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 +651,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 +704,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 +712,49 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="30" column="0" lean-forward="true" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
</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="555">
<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$/apps/system/urls.py">
<entry file="file://$PROJECT_DIR$/apps/system/views_menu.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="391">
<caret line="23" column="0" lean-forward="true" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" />
<folding>
<element signature="e#0#41#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)

View File

@@ -25,6 +25,6 @@ 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'),
]

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())

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 %}