authbox-menu 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- authbox_menu-1.0.0.dist-info/LICENSE +29 -0
- authbox_menu-1.0.0.dist-info/METADATA +130 -0
- authbox_menu-1.0.0.dist-info/RECORD +39 -0
- authbox_menu-1.0.0.dist-info/WHEEL +5 -0
- authbox_menu-1.0.0.dist-info/top_level.txt +2 -0
- menu/__init__.py +0 -0
- menu/_version.py +12 -0
- menu/admin.py +30 -0
- menu/apps.py +6 -0
- menu/auto_insert_group.py +40 -0
- menu/menus.py +418 -0
- menu/migrations/0001_initial.py +109 -0
- menu/migrations/0002_menugroup_kind.py +18 -0
- menu/migrations/0003_menu_is_new_alter_menu_link.py +23 -0
- menu/migrations/0004_alter_menu_menu_group.py +18 -0
- menu/migrations/0005_remove_menugroup_site_menugroup_group_and_more.py +30 -0
- menu/migrations/0006_alter_menugrouptranslation_unique_together_and_more.py +40 -0
- menu/migrations/0007_auto_20230130_1141.py +21 -0
- menu/migrations/0008_menu_exclude_menu.py +18 -0
- menu/migrations/0009_menu_is_initial_data.py +18 -0
- menu/migrations/__init__.py +0 -0
- menu/models.py +335 -0
- menu/templates/admin/parler/change_form.html +6 -0
- menu/templates/admin/parler/deletion_not_allowed.html +6 -0
- menu/templates/admin/parler/edit_inline/stacked_tabs.html +2 -0
- menu/templates/admin/parler/edit_inline/tabular_tabs.html +2 -0
- menu/templates/admin/parler/language_tabs.html +20 -0
- menu/templates/index.html +53 -0
- menu/templates/test-menu.html +158 -0
- menu/templatetags/__init__.py +0 -0
- menu/templatetags/menu_tags.py +213 -0
- menu/tests.py +3 -0
- menu/urls.py +9 -0
- menu/views.py +30 -0
- proj_menu/__init__.py +0 -0
- proj_menu/asgi.py +16 -0
- proj_menu/settings.py +174 -0
- proj_menu/urls.py +27 -0
- proj_menu/wsgi.py +16 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022, Iwan Setiawan (ione03)
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: authbox-menu
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Auto create menu base on table values
|
|
5
|
+
Home-page: https://github.com/PROJECT-OUTBOX/authbox_menu.git
|
|
6
|
+
Author-email: suratiwan03@gmail.com
|
|
7
|
+
Keywords: menu,model base,environment,django
|
|
8
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: django-parler
|
|
14
|
+
Requires-Dist: authbox-setup-version
|
|
15
|
+
|
|
16
|
+
# DJANGO OUTBOX MENU
|
|
17
|
+
|
|
18
|
+
Menu is almost use in every web project.
|
|
19
|
+
|
|
20
|
+
With this library you can create menu for backend and frontend project without headache.
|
|
21
|
+
All you need to do is:
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## In your django Environment
|
|
25
|
+
|
|
26
|
+
### Install package to your environment
|
|
27
|
+
> pip install django-outbox-menu
|
|
28
|
+
|
|
29
|
+
### Add to INSTALLED_APPS
|
|
30
|
+
INSTALLED_APPS = [
|
|
31
|
+
'django.contrib.sites',
|
|
32
|
+
'menu',
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
### Add SITE_ID in user settings.py
|
|
36
|
+
SITE_ID = 1
|
|
37
|
+
|
|
38
|
+
### Include library URLS
|
|
39
|
+
urlpatterns += [
|
|
40
|
+
path('', include('menu.urls')),
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
### Install requirements
|
|
44
|
+
Activate your environment using
|
|
45
|
+
> mkvirtualenv env_menu
|
|
46
|
+
|
|
47
|
+
### Migrate to create table to your database
|
|
48
|
+
> python manage.py migrate
|
|
49
|
+
|
|
50
|
+
## In your django Templates
|
|
51
|
+
|
|
52
|
+
### Load menu tags
|
|
53
|
+
> {% load menu_tags %}
|
|
54
|
+
|
|
55
|
+
### Generate menu
|
|
56
|
+
> {% menu_create FRONTEND 0 as my_menu %}
|
|
57
|
+
syntax :
|
|
58
|
+
> menu_create <menu_kind> <menu_group> as var_name
|
|
59
|
+
> menu_kind : FRONTEND or BACKEND
|
|
60
|
+
> menu_group :
|
|
61
|
+
0 : None (use only for FRONTEND)
|
|
62
|
+
1 : Owner
|
|
63
|
+
2 : Manager
|
|
64
|
+
3 : Operator
|
|
65
|
+
4 : Cashier
|
|
66
|
+
etc ... (Update in admin page section [Menu Groups])
|
|
67
|
+
|
|
68
|
+
> {% for n in my_menu %}
|
|
69
|
+
n have all menu fields such as :
|
|
70
|
+
n.id
|
|
71
|
+
n.parent_id
|
|
72
|
+
n.name
|
|
73
|
+
n.link
|
|
74
|
+
n.icon
|
|
75
|
+
n.is_external
|
|
76
|
+
n.level
|
|
77
|
+
n.haveChild
|
|
78
|
+
n.haveChildEndTag
|
|
79
|
+
You can use it inside for loop
|
|
80
|
+
|
|
81
|
+
> example in you templates
|
|
82
|
+
<ul class="main-menu">
|
|
83
|
+
{% menu_create FRONTEND 0 as my_menu %}
|
|
84
|
+
{% for n in my_menu %}
|
|
85
|
+
|
|
86
|
+
{% if forloop.first %}
|
|
87
|
+
<li class="main-menu-active">
|
|
88
|
+
{% else %}
|
|
89
|
+
<li>
|
|
90
|
+
{% endif %}
|
|
91
|
+
|
|
92
|
+
{% if n.haveChild %}
|
|
93
|
+
<a href="#"> {{n.name}}
|
|
94
|
+
{% if n.parent_id %}
|
|
95
|
+
<i class="zmdi zmdi-chevron-right text-to-right"></i>
|
|
96
|
+
{% endif %}
|
|
97
|
+
</a>
|
|
98
|
+
<ul class="sub-menu">
|
|
99
|
+
{% else %}
|
|
100
|
+
<a class="clear-content-right" href="#"> {{n.name}} </a>
|
|
101
|
+
{% endif %}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
{% for i in n.haveChildEndTag %}
|
|
105
|
+
<!-- Count = {{forloop.counter}} -->
|
|
106
|
+
{% if forloop.last %}
|
|
107
|
+
{% if n.parent_id %}
|
|
108
|
+
</li></ul>
|
|
109
|
+
{% if not n.haveChild %}
|
|
110
|
+
</li> <!-- li -->
|
|
111
|
+
{% endif %}
|
|
112
|
+
{% else %}
|
|
113
|
+
</li> <!-- Root -->
|
|
114
|
+
{% endif %}
|
|
115
|
+
|
|
116
|
+
{% else %}
|
|
117
|
+
</li></ul>
|
|
118
|
+
{% endif %}
|
|
119
|
+
|
|
120
|
+
{% endfor %}
|
|
121
|
+
|
|
122
|
+
{% endfor %}
|
|
123
|
+
</ul>
|
|
124
|
+
|
|
125
|
+
### Run project
|
|
126
|
+
> python manage.py runserver
|
|
127
|
+
on you browser :
|
|
128
|
+
127.0.0.1:8000
|
|
129
|
+
127.0.0.1:8000/menu
|
|
130
|
+
127.0.0.1:8000/admin
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
menu/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
menu/_version.py,sha256=TVTfZIeDeBJ3EGUthTO43XPZ4FM4NgJJbQvsOzFbMaM,251
|
|
3
|
+
menu/admin.py,sha256=9WBBGk5ZLXW2Bf5qmp9OTGXMSHvSpGHl53ImEw8D1Vs,1016
|
|
4
|
+
menu/apps.py,sha256=qTWgIeeOF8NFGTJmUicsPq07sv7oxU54cTc0GR9a0Vk,140
|
|
5
|
+
menu/auto_insert_group.py,sha256=2k7lIjbBpBUdgEZiG9-pisRi3gAigEMZqwHPkeRT2Ok,1101
|
|
6
|
+
menu/menus.py,sha256=B5XxPDnsh8qbGw80Mfbzt_hjG7YfNfhGSuic0QNmf6A,17981
|
|
7
|
+
menu/models.py,sha256=Bn7-pOThTx7Ef6-diWqnWrb3XOQSwTp6mcIUMUkdywo,12990
|
|
8
|
+
menu/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
|
9
|
+
menu/urls.py,sha256=FriLY67Iw9Rt8Qver6tSgAyGpZF6Hon4vvSj5U5MKjU,324
|
|
10
|
+
menu/views.py,sha256=FxEqNdeYgJ62GzKU0At8G5YYmXU358ZgfmsoFqDgPao,1140
|
|
11
|
+
menu/migrations/0001_initial.py,sha256=Et_jSlyHglOeA1-DV0jkiMxroM1QYfZSUN_vIXJ0-Ls,5212
|
|
12
|
+
menu/migrations/0002_menugroup_kind.py,sha256=b3ybzgaKuOUBzPAOXEBBvpUF9SMnXz1RwE2t4-yqLsw,418
|
|
13
|
+
menu/migrations/0003_menu_is_new_alter_menu_link.py,sha256=rF0He8H_iF9vBQpi14ggkuAW85W-1Vwc2PkmXxEvC1k,553
|
|
14
|
+
menu/migrations/0004_alter_menu_menu_group.py,sha256=4OwNl1UekduAkKusUEPug3cCdmmWImKKAbusq2c2kqo,450
|
|
15
|
+
menu/migrations/0005_remove_menugroup_site_menugroup_group_and_more.py,sha256=NAvH_MeX-Fw3C14STkpAKEyeJlFYBMMaPXsGJZZcojQ,840
|
|
16
|
+
menu/migrations/0006_alter_menugrouptranslation_unique_together_and_more.py,sha256=kWeuFXtl57xxsDuG7Oh5V_N96VRjjY4eJnNtrCMntIk,1250
|
|
17
|
+
menu/migrations/0007_auto_20230130_1141.py,sha256=Fx1eYcDY-Jw9oTPsUpygBaYW5DKAlsWI_2Beu5Uym9Q,564
|
|
18
|
+
menu/migrations/0008_menu_exclude_menu.py,sha256=IM50NZMV9VGpPMTu6-r5RXSnW1G8D7z9hiIYvhH1W3w,388
|
|
19
|
+
menu/migrations/0009_menu_is_initial_data.py,sha256=sJysoXqxefl2nNhCnqPdCFareLgiSTQNFzMgRE1Qf_w,390
|
|
20
|
+
menu/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
+
menu/templates/index.html,sha256=YAI4dsBbD1JHPgX3MwuCLRHvZX4hDkfhkmpMzmUCQmA,1107
|
|
22
|
+
menu/templates/test-menu.html,sha256=qR2KeXEmKRT7Uuztjurpcun88uo-nIYXtMTBdJ3119U,7261
|
|
23
|
+
menu/templates/admin/parler/change_form.html,sha256=PuDJKdftNMpoF0Vqyw1uFP15jXX3839gJBy8l7Q4UTw,214
|
|
24
|
+
menu/templates/admin/parler/deletion_not_allowed.html,sha256=dSYJcQZADL-Z7sZku_h-nIrixN-jFzhu9YXDSdsDEbg,342
|
|
25
|
+
menu/templates/admin/parler/language_tabs.html,sha256=BrzNJk4j6pbjSK702aa7V7bQcmiUARKY1qtbtUkdaQI,1132
|
|
26
|
+
menu/templates/admin/parler/edit_inline/stacked_tabs.html,sha256=QlrtQvrT5snFqAcXeU58snyGkWoZIWAggWzl76fP3PU,157
|
|
27
|
+
menu/templates/admin/parler/edit_inline/tabular_tabs.html,sha256=of_ktbuTTGQ1ndaLJPSFj1E2lVkeXMIovXqbeXZVlWM,157
|
|
28
|
+
menu/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
+
menu/templatetags/menu_tags.py,sha256=lFiktaFrzeA6VtW3rl4RtPYMPHYYPrr-UOCdqNZ0TxI,7848
|
|
30
|
+
proj_menu/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
+
proj_menu/asgi.py,sha256=AW51Q9f5-3c0LsRaatTmlTw4zbcaLmEZSH14Gi_4nKo,395
|
|
32
|
+
proj_menu/settings.py,sha256=C3DHWCHryUGalyUQyan3an7xjTYlRaxw8IH89yXeGzM,4333
|
|
33
|
+
proj_menu/urls.py,sha256=7gsqMFv6D1HfExwWZ1nmRqKUFsEpqOIN_Qzh-RS5Tb0,915
|
|
34
|
+
proj_menu/wsgi.py,sha256=WUwjDmEEl47nHp1kTb5GLwEtUUjhNUZWOOinGbKK4_w,395
|
|
35
|
+
authbox_menu-1.0.0.dist-info/LICENSE,sha256=VS72RLpF0_CZQa08XEPACUKN5HseArVR_GIrCIzD-I0,1521
|
|
36
|
+
authbox_menu-1.0.0.dist-info/METADATA,sha256=BBhlHAiHyK_HFUBo40fe4fQQIeQA_UptfRvNz9jOOjY,3984
|
|
37
|
+
authbox_menu-1.0.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
38
|
+
authbox_menu-1.0.0.dist-info/top_level.txt,sha256=gBZFfxKnuYiPA9Wk6sHpPkmTXIsyKWafzpbMt8zHRmU,15
|
|
39
|
+
authbox_menu-1.0.0.dist-info/RECORD,,
|
menu/__init__.py
ADDED
|
File without changes
|
menu/_version.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Provides menu version information.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# This file is auto-generated! Do not edit!
|
|
6
|
+
# Use `python -m incremental.update menu` to change this file.
|
|
7
|
+
|
|
8
|
+
from incremental import Version
|
|
9
|
+
|
|
10
|
+
__version__ = Version("menu", 1, 0, 0)
|
|
11
|
+
__all__ = ["__version__"]
|
|
12
|
+
|
menu/admin.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
from parler.admin import TranslatableAdmin
|
|
3
|
+
|
|
4
|
+
from .models import Menu, MenuGroup # , MenuCustom
|
|
5
|
+
|
|
6
|
+
class MenuAdmin(TranslatableAdmin): # admin.ModelAdmin
|
|
7
|
+
#list_filter = ('name',)
|
|
8
|
+
list_display = ['name', 'parent', 'link', 'order_menu', 'kind', 'exclude_menu', 'is_initial_data', 'updated_at']
|
|
9
|
+
search_fields = ('name', 'parent')
|
|
10
|
+
ordering = ('-updated_at',)
|
|
11
|
+
# .order_by('parent_id','order_menu')
|
|
12
|
+
|
|
13
|
+
admin.site.register(Menu, MenuAdmin)
|
|
14
|
+
|
|
15
|
+
class MenuGroupAdmin(admin.ModelAdmin):
|
|
16
|
+
list_filter = ('kind',)
|
|
17
|
+
list_display = ['group', 'site_domain', 'level', 'kind', 'updated_at']
|
|
18
|
+
search_fields = ('group',)
|
|
19
|
+
ordering = ('-level',)
|
|
20
|
+
|
|
21
|
+
admin.site.register(MenuGroup, MenuGroupAdmin)
|
|
22
|
+
|
|
23
|
+
# tidak di update model yg ini
|
|
24
|
+
# class MenuCustomAdmin(admin.ModelAdmin):
|
|
25
|
+
# list_filter = ('menu',)
|
|
26
|
+
# list_display = ['menu', 'menu_group', 'updated_at']
|
|
27
|
+
# search_fields = ('menu',)
|
|
28
|
+
# ordering = ('-updated_at',)
|
|
29
|
+
|
|
30
|
+
# admin.site.register(MenuCustom, MenuCustomAdmin)
|
menu/apps.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from .models import MenuGroup
|
|
2
|
+
from django.contrib.auth.models import Group
|
|
3
|
+
|
|
4
|
+
def create_groups(apps, schema_monitor):
|
|
5
|
+
'''
|
|
6
|
+
# auth_group = apps.get_model('django.contrib.auth', 'Group')
|
|
7
|
+
'''
|
|
8
|
+
|
|
9
|
+
# For backend
|
|
10
|
+
# -----------
|
|
11
|
+
mlist = [
|
|
12
|
+
'Super Admin', # lvl 9
|
|
13
|
+
'Developer', # lvl 8
|
|
14
|
+
'Admin', # lvl 7
|
|
15
|
+
'Owner', # lvl 6
|
|
16
|
+
'Manager', # lvl 5
|
|
17
|
+
'Operator' # lvl 4
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
mlevel = 9
|
|
21
|
+
for i in mlist:
|
|
22
|
+
group, created = Group.objects.get_or_create(name=i)
|
|
23
|
+
if created:
|
|
24
|
+
MenuGroup.objects.create(group=group, kind=2, level=mlevel)
|
|
25
|
+
mlevel -= 1
|
|
26
|
+
|
|
27
|
+
# for frontend
|
|
28
|
+
# ------------
|
|
29
|
+
mlevel = 0
|
|
30
|
+
mlist = [
|
|
31
|
+
'Anonymous', # lvl 0
|
|
32
|
+
]
|
|
33
|
+
for i in mlist:
|
|
34
|
+
group, created = Group.objects.get_or_create(name=i)
|
|
35
|
+
if created:
|
|
36
|
+
MenuGroup.objects.create(group=group, kind=1, level=mlevel)
|
|
37
|
+
mlevel -= 1
|
|
38
|
+
|
|
39
|
+
# end (run on migrate)
|
|
40
|
+
|