django_fhadmin 2.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.
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2011-2012, FEINHEIT GmbH and individual contributors.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of FEINHEIT GmbH nor the names of its contributors
15
+ may be used to endorse or promote products derived from this software
16
+ without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.1
2
+ Name: django-fhadmin
3
+ Version: 2.0.0
4
+ Summary: Modifies the stock Django-Administration interface to fit our ideas a little bit better.
5
+ Home-page: http://github.com/feinheit/django-fhadmin/
6
+ Author: Matthias Kestenholz
7
+ Author-email: mk@feinheit.ch
8
+ License: BSD-3-Clause
9
+ Platform: OS Independent
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/x-rst
18
+ License-File: LICENSE
19
+ Requires-Dist: Django (>=3.2)
20
+
21
+ Django-FHAdmin
22
+ ==============
23
+
24
+ Modifies the stock Django-Administration interface to fit our ideas a little
25
+ bit better.
26
+
27
+
28
+ Dashboard and global navigation extension
29
+ -----------------------------------------
30
+
31
+ Allows grouping of apps on the dashboard and offers the same view on each
32
+ admin page by sliding down the bar on top after a small delay when hovered.
33
+
34
+ Configuration example::
35
+
36
+ from fhadmin import FHADMIN_GROUPS_REMAINING
37
+ _ = lambda x: x
38
+
39
+ FHADMIN_GROUPS_CONFIG = [
40
+ (_('Main content'), {
41
+ 'apps': ('page', 'medialibrary', 'blog'),
42
+ }),
43
+ (_('Modules'), {
44
+ 'apps': ('links', FHADMIN_GROUPS_REMAINING),
45
+ }),
46
+ (_('Preferences'), {
47
+ 'apps': ('auth', 'rosetta', 'external', 'sites'),
48
+ }),
49
+ ]
50
+
51
+
52
+ The extension is activated by inserting ``fhadmin`` before
53
+ ``django.contrib.admin`` in ``INSTALLED_APPS``.
54
+
55
+
@@ -0,0 +1,13 @@
1
+ fhadmin/__init__.py,sha256=8_1tBvX5j2-IE7ovYoovI5xJx8ncNXW_RYr9ck4CR9I,102
2
+ fhadmin/models.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ fhadmin/static/fhadmin/fhadmin.css,sha256=_LwHnwadApUx2P5jquyKUf78a8FP0xzDTFRhU--MsJU,1689
4
+ fhadmin/templates/admin/base_site.html,sha256=UzUtDBH4BJT_lPKPA5-CO6eyniSL1-WUB-lPG159qqY,496
5
+ fhadmin/templates/admin/group_list.html,sha256=kFDXntxU6uCn3k9yi09nrvvk0MS40TMxuSCMKE8amWQ,1796
6
+ fhadmin/templates/admin/index.html,sha256=5pQfTNjGqcWINvs-rqX8bWkzmhOo9SY0sUs3j7rjqCY,1730
7
+ fhadmin/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ fhadmin/templatetags/fhadmin_module_groups.py,sha256=Mzo9CJMBu-iOE4wirnk-HiH1G6XbsBMjatdvAhuWzHo,4328
9
+ django_fhadmin-2.0.0.dist-info/LICENSE,sha256=EeStXy_qBePVTsM8AHL7fnHdVlyfAmRdMDArwiUh84o,1557
10
+ django_fhadmin-2.0.0.dist-info/METADATA,sha256=WHQ5PtzqJEShS8XA2yLeac8Y5HNpoyjZuWLdhSkOch0,1642
11
+ django_fhadmin-2.0.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
12
+ django_fhadmin-2.0.0.dist-info/top_level.txt,sha256=K_aIxFl54EJbRhWz8-LdaWkS_Tfwd46pCxh1nn3kToU,8
13
+ django_fhadmin-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.37.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ fhadmin
fhadmin/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ VERSION = (2, 0, 0)
2
+ __version__ = ".".join(map(str, VERSION))
3
+
4
+ FHADMIN_GROUPS_REMAINING = "REMAINING"
fhadmin/models.py ADDED
File without changes
@@ -0,0 +1,110 @@
1
+ #toggle-nav-sidebar,
2
+ #nav-sidebar {
3
+ display: none;
4
+ }
5
+
6
+ @media (min-width: 1024px) {
7
+ #header {
8
+ flex-wrap: wrap;
9
+ }
10
+ }
11
+
12
+ .dashboard .content {
13
+ max-width: none !important; /* nav_sidebar override */
14
+ }
15
+
16
+ .dashboard #content {
17
+ width: auto;
18
+ }
19
+
20
+ .dashboard #content.colMS {
21
+ margin-right: 0 !important;
22
+ }
23
+
24
+ #content-related {
25
+ clear: both;
26
+ float: left;
27
+ width: 100%;
28
+ margin-top: 20px;
29
+ padding-bottom: 1px; /* contain the margin */
30
+ }
31
+
32
+ .qp-active #branding h1 {
33
+ cursor: pointer;
34
+ }
35
+
36
+ .qp-active #branding h1::after {
37
+ content: "▲";
38
+ font-size: 0.8em;
39
+ display: inline-block;
40
+ position: relative;
41
+ top: 0.1em;
42
+ left: 0.3em;
43
+ transform: rotate(180deg);
44
+ transition: 0.2s;
45
+ }
46
+
47
+ .qp-open #branding h1::after {
48
+ transform: none;
49
+ top: -0.1em;
50
+ }
51
+
52
+ .groups {
53
+ display: grid;
54
+ grid-template-columns: repeat(auto-fill, clamp(200px, 24vw, 500px));
55
+ gap: 20px;
56
+ }
57
+
58
+ .group h2 {
59
+ color: var(--body-quiet-color);
60
+ }
61
+
62
+ #quickpanel {
63
+ display: none;
64
+ line-height: normal;
65
+ flex-basis: 100%;
66
+ align-self: stretch;
67
+ }
68
+
69
+ #quickpanel .group h2 {
70
+ color: var(--body-bg);
71
+ }
72
+
73
+ #quickpanel .module {
74
+ background: inherit;
75
+ color: var(--body-bg);
76
+ }
77
+
78
+ #quickpanel a {
79
+ color: var(--secondary) !important;
80
+ }
81
+
82
+ #quickpanel a.section {
83
+ color: var(--body-bg) !important;
84
+ }
85
+
86
+ @media (prefers-color-scheme: dark) {
87
+ #quickpanel .group h2,
88
+ #quickpanel a,
89
+ #quickpanel a.section {
90
+ color: var(--body-fg) !important;
91
+ }
92
+ }
93
+
94
+ #quickpanel .module,
95
+ #quickpanel th,
96
+ #quickpanel td {
97
+ border-color: var(--border-color);
98
+ }
99
+
100
+ #quickpanel .module table th {
101
+ width: 100%;
102
+ }
103
+ #quickpanel tr:last-child td,
104
+ #quickpanel tr:last-child th {
105
+ border-bottom: none;
106
+ }
107
+
108
+ #quickpanel .caption {
109
+ color: #3b3b3b;
110
+ }
@@ -0,0 +1,19 @@
1
+ {% extends "admin/base.html" %}
2
+ {% load i18n static %}
3
+
4
+ {% block extrahead %}
5
+ <link rel="stylesheet" type="text/css" href="{% static 'fhadmin/fhadmin.css' %}" />
6
+ {% endblock %}
7
+
8
+ {% block title %}{{ title }} | {% trans 'Django administration' %}{% endblock %}
9
+
10
+ {% block branding %}
11
+ <h1 id="site-name">{% trans 'Django administration' %}</h1>
12
+ {% endblock %}
13
+
14
+ {% block nav-global %}
15
+ <div id="quickpanel">
16
+ {% include "admin/group_list.html" %}
17
+ <br style="clear:both" />
18
+ </div>
19
+ {% endblock %}
@@ -0,0 +1,51 @@
1
+ {% load fhadmin_module_groups i18n %}
2
+ {% fhadmin_group_list request %}
3
+
4
+ {% if group_list %}
5
+ <div class="groups">
6
+ {% for group, app_list in group_list %}
7
+ <div class="group">
8
+ <h2>{% trans group %}</h2>
9
+ {% for app in app_list %}
10
+ <div class="module">
11
+ <table summary="{% blocktrans with app.name as name %}Models available in the {{ name }} application.{% endblocktrans %}">
12
+ <caption class="caption {{ app.name|lower }}"><a href="{{ app.app_url }}" class="section">{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}</a></caption>
13
+ {% for model in app.models %}
14
+ <tr>
15
+ {% if model.perms.change %}
16
+ <th scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th>
17
+ {% else %}
18
+ <th scope="row">{{ model.name }}</th>
19
+ {% endif %}
20
+
21
+ {% if model.perms.add %}
22
+ <td><a href="{{ model.admin_url }}add/" class="addlink">&nbsp;</a></td>
23
+ {% else %}
24
+ <td>&nbsp;</td>
25
+ {% endif %}
26
+ </tr>
27
+ {% endfor %}
28
+ </table>
29
+ </div>
30
+ {% endfor %}
31
+ </div>
32
+ {% endfor %}
33
+ </div>
34
+ <script type="text/javascript">
35
+ if (window.django && window.django.jQuery) {
36
+ (function($){
37
+ $(function(){
38
+ $('head').append('<style type="text/css">#header h1:hover { cursor: pointer; }\x3C/style>');
39
+ var quickpanel = $('#quickpanel');
40
+ $('body').addClass('qp-active');
41
+ $('#header h1').bind('click', function() {
42
+ $('body').toggleClass('qp-open');
43
+ quickpanel.slideToggle();
44
+ });
45
+ });
46
+ })(django.jQuery);
47
+ }
48
+ </script>
49
+ {% else %}
50
+ <p>{% trans "You don't have permission to edit anything." %}</p>
51
+ {% endif %}
@@ -0,0 +1,49 @@
1
+ {% extends "admin/base_site.html" %}
2
+ {% load i18n static %}
3
+
4
+ {% block extrastyle %}{{ block.super }}
5
+ <link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}" />{% endblock %}
6
+
7
+ {% block coltype %}colMS{% endblock %}
8
+
9
+ {% block bodyclass %}dashboard{% endblock %}
10
+
11
+ {% block breadcrumbs %}{% endblock %}
12
+
13
+ {% block content %}
14
+ <div id="content-main">
15
+ {% include "admin/group_list.html" %}
16
+ </div>
17
+ {% endblock %}
18
+
19
+ {% block sidebar %}
20
+ <div id="content-related">
21
+ <div class="module" id="recent-actions-module">
22
+ <h2>{% trans 'Recent actions' %}</h2>
23
+ <h3>{% trans 'My actions' %}</h3>
24
+ {% load log %}
25
+ {% get_admin_log 10 as admin_log for_user user %}
26
+ {% if not admin_log %}
27
+ <p>{% trans 'None available' %}</p>
28
+ {% else %}
29
+ <ul class="actionlist">
30
+ {% for entry in admin_log %}
31
+ <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
32
+ {% if entry.is_deletion %}
33
+ {{ entry.object_repr }}
34
+ {% else %}
35
+ <a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
36
+ {% endif %}
37
+ <br/>
38
+ {% if entry.content_type %}
39
+ <span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span>
40
+ {% else %}
41
+ <span class="mini quiet">{% trans 'Unknown content' %}</span>
42
+ {% endif %}
43
+ </li>
44
+ {% endfor %}
45
+ </ul>
46
+ {% endif %}
47
+ </div>
48
+ </div>
49
+ {% endblock %}
File without changes
@@ -0,0 +1,145 @@
1
+ import operator
2
+ from functools import reduce
3
+
4
+ from django import template
5
+ from django.conf import settings
6
+ from django.contrib import admin
7
+ from django.utils.safestring import mark_safe
8
+ from django.utils.text import capfirst
9
+ from django.utils.translation import gettext_lazy
10
+
11
+ from fhadmin import FHADMIN_GROUPS_REMAINING
12
+
13
+
14
+ try:
15
+ from django.urls import reverse
16
+ except ImportError:
17
+ from django.core.urlresolvers import reverse
18
+
19
+
20
+ register = template.Library()
21
+
22
+
23
+ FHADMIN_GROUPS_CONFIG = [
24
+ (
25
+ gettext_lazy("Main content"),
26
+ {
27
+ "apps": ("page", "medialibrary", "elephantblog", "pages", "articles"),
28
+ },
29
+ ),
30
+ (
31
+ gettext_lazy("Modules"),
32
+ {
33
+ "apps": ("gallery", "agenda", "links", FHADMIN_GROUPS_REMAINING),
34
+ },
35
+ ),
36
+ (
37
+ gettext_lazy("Preferences"),
38
+ {
39
+ "apps": (
40
+ "auth",
41
+ "little_auth",
42
+ "accounts",
43
+ "sites",
44
+ "pinging",
45
+ "feincms3_cookiecontrol",
46
+ "feincms3_sites",
47
+ ),
48
+ },
49
+ ),
50
+ (
51
+ gettext_lazy("Collections"),
52
+ {
53
+ "apps": ("external", "sharing", "newsletter", "form_designer"),
54
+ },
55
+ ),
56
+ ]
57
+
58
+ FHADMIN_GROUPS_CONFIG = getattr(
59
+ settings, "FHADMIN_GROUPS_CONFIG", FHADMIN_GROUPS_CONFIG
60
+ )
61
+
62
+
63
+ def fhadmin_group_list(admin_site, request):
64
+ base_url = reverse("admin:index")
65
+
66
+ # -- 8< -- copied from django.contrib.admin.sites.AdminSite.index
67
+ app_dict = {}
68
+ user = request.user
69
+ for model, model_admin in admin_site._registry.items():
70
+ app_label = model._meta.app_label
71
+ has_module_perms = user.has_module_perms(app_label)
72
+
73
+ if has_module_perms:
74
+ perms = model_admin.get_model_perms(request)
75
+
76
+ # Check whether user has any perm for this module.
77
+ # If so, add the module to the model_list.
78
+ if True in perms.values():
79
+ model_dict = {
80
+ "name": capfirst(model._meta.verbose_name_plural),
81
+ "admin_url": base_url
82
+ + mark_safe(f"{app_label}/{model.__name__.lower()}/"),
83
+ "perms": perms,
84
+ }
85
+ if app_label in app_dict:
86
+ app_dict[app_label]["models"].append(model_dict)
87
+ else:
88
+ app_dict[app_label] = {
89
+ "name": app_label.title(),
90
+ "app_url": base_url + app_label + "/",
91
+ "has_module_perms": has_module_perms,
92
+ "models": [model_dict],
93
+ "app_label": app_label, # MK added this
94
+ }
95
+
96
+ # Sort the apps alphabetically.
97
+ app_list = sorted(app_dict.values(), key=lambda value: value["name"])
98
+
99
+ # Sort the models alphabetically within each app.
100
+ for app in app_list:
101
+ app["models"] = sorted(app["models"], key=lambda value: value["name"])
102
+ # -- 8< -- copied from django.contrib.admin.sites.AdminSite.index
103
+
104
+ all_available = [app["app_label"] for app in app_list]
105
+ all_configured = reduce(
106
+ operator.add, (list(v["apps"]) for k, v in FHADMIN_GROUPS_CONFIG), []
107
+ )
108
+
109
+ all_remains = [a for a in all_available if a not in all_configured]
110
+
111
+ for group_title, group in FHADMIN_GROUPS_CONFIG:
112
+ apps = []
113
+ for app in group["apps"]:
114
+ if app == FHADMIN_GROUPS_REMAINING:
115
+ apps.extend(app_dict[a] for a in all_remains if a in app_dict)
116
+ elif app in app_dict:
117
+ apps.append(app_dict[app])
118
+ # else: Do nothing, ignore
119
+
120
+ if apps:
121
+ yield group_title, apps
122
+
123
+
124
+ class FHAdminGroupListNode(template.Node):
125
+ def __init__(self, request):
126
+ self.request = template.Variable(request)
127
+
128
+ def render(self, context):
129
+ request = self.request.resolve(context)
130
+ context["group_list"] = fhadmin_group_list(admin.sites.site, request)
131
+ return ""
132
+
133
+
134
+ def do_fhadmin_group_list(parser, token):
135
+ """
136
+ {% fhadmin_group_list request %}
137
+
138
+ Creates a ``group_list`` variable in the current context.
139
+ """
140
+
141
+ tag_name, request = token.split_contents()
142
+ return FHAdminGroupListNode(request)
143
+
144
+
145
+ register.tag("fhadmin_group_list", do_fhadmin_group_list)