django_fhadmin 1.0__tar.gz
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.
- django-fhadmin-1.0/PKG-INFO +10 -0
- django-fhadmin-1.0/django_fhadmin.egg-info/PKG-INFO +10 -0
- django-fhadmin-1.0/django_fhadmin.egg-info/SOURCES.txt +9 -0
- django-fhadmin-1.0/django_fhadmin.egg-info/dependency_links.txt +1 -0
- django-fhadmin-1.0/django_fhadmin.egg-info/top_level.txt +1 -0
- django-fhadmin-1.0/fhadmin/__init__.py +1 -0
- django-fhadmin-1.0/fhadmin/models.py +0 -0
- django-fhadmin-1.0/fhadmin/templatetags/__init__.py +0 -0
- django-fhadmin-1.0/fhadmin/templatetags/fhadmin_module_groups.py +115 -0
- django-fhadmin-1.0/setup.cfg +5 -0
- django-fhadmin-1.0/setup.py +16 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 1.0
|
|
2
|
+
Name: django-fhadmin
|
|
3
|
+
Version: 1.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 License
|
|
9
|
+
Description: UNKNOWN
|
|
10
|
+
Platform: OS Independent
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 1.0
|
|
2
|
+
Name: django-fhadmin
|
|
3
|
+
Version: 1.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 License
|
|
9
|
+
Description: UNKNOWN
|
|
10
|
+
Platform: OS Independent
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
setup.py
|
|
2
|
+
django_fhadmin.egg-info/PKG-INFO
|
|
3
|
+
django_fhadmin.egg-info/SOURCES.txt
|
|
4
|
+
django_fhadmin.egg-info/dependency_links.txt
|
|
5
|
+
django_fhadmin.egg-info/top_level.txt
|
|
6
|
+
fhadmin/__init__.py
|
|
7
|
+
fhadmin/models.py
|
|
8
|
+
fhadmin/templatetags/__init__.py
|
|
9
|
+
fhadmin/templatetags/fhadmin_module_groups.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fhadmin
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
FHADMIN_GROUPS_REMAINING = 'REMAINING'
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import operator
|
|
2
|
+
|
|
3
|
+
from django import template
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.contrib import admin
|
|
6
|
+
from django.core.urlresolvers import reverse
|
|
7
|
+
from django.template.loader import render_to_string
|
|
8
|
+
from django.utils.safestring import mark_safe
|
|
9
|
+
from django.utils.text import capfirst
|
|
10
|
+
from django.utils.translation import ugettext as _, ugettext_lazy
|
|
11
|
+
|
|
12
|
+
from fhadmin import FHADMIN_GROUPS_REMAINING
|
|
13
|
+
|
|
14
|
+
register = template.Library()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
FHADMIN_GROUPS_CONFIG = [
|
|
18
|
+
(ugettext_lazy('Main content'), {
|
|
19
|
+
'apps': ('page', 'medialibrary', 'elephantblog'),
|
|
20
|
+
}),
|
|
21
|
+
(ugettext_lazy('Modules'), {
|
|
22
|
+
'apps': ('gallery', 'agenda', 'links', FHADMIN_GROUPS_REMAINING),
|
|
23
|
+
}),
|
|
24
|
+
(ugettext_lazy('Preferences'), {
|
|
25
|
+
'apps': ('auth', 'sites', 'pinging'),
|
|
26
|
+
}),
|
|
27
|
+
(ugettext_lazy('Collections'), {
|
|
28
|
+
'apps': ('external', 'sharing', 'newsletter', 'form_designer'),
|
|
29
|
+
}),
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
FHADMIN_GROUPS_CONFIG = getattr(settings, 'FHADMIN_GROUPS_CONFIG',
|
|
33
|
+
FHADMIN_GROUPS_CONFIG)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def fhadmin_group_list(admin_site, request):
|
|
37
|
+
base_url = reverse('admin:index')
|
|
38
|
+
|
|
39
|
+
# -- 8< -- copied from django.contrib.admin.sites.AdminSite.index
|
|
40
|
+
app_dict = {}
|
|
41
|
+
user = request.user
|
|
42
|
+
for model, model_admin in admin_site._registry.items():
|
|
43
|
+
app_label = model._meta.app_label
|
|
44
|
+
has_module_perms = user.has_module_perms(app_label)
|
|
45
|
+
|
|
46
|
+
if has_module_perms:
|
|
47
|
+
perms = model_admin.get_model_perms(request)
|
|
48
|
+
|
|
49
|
+
# Check whether user has any perm for this module.
|
|
50
|
+
# If so, add the module to the model_list.
|
|
51
|
+
if True in perms.values():
|
|
52
|
+
model_dict = {
|
|
53
|
+
'name': capfirst(model._meta.verbose_name_plural),
|
|
54
|
+
'admin_url': base_url + mark_safe('%s/%s/' % (app_label, model.__name__.lower())),
|
|
55
|
+
'perms': perms,
|
|
56
|
+
}
|
|
57
|
+
if app_label in app_dict:
|
|
58
|
+
app_dict[app_label]['models'].append(model_dict)
|
|
59
|
+
else:
|
|
60
|
+
app_dict[app_label] = {
|
|
61
|
+
'name': app_label.title(),
|
|
62
|
+
'app_url': base_url + app_label + '/',
|
|
63
|
+
'has_module_perms': has_module_perms,
|
|
64
|
+
'models': [model_dict],
|
|
65
|
+
'app_label': app_label, # MK added this
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# Sort the apps alphabetically.
|
|
69
|
+
app_list = app_dict.values()
|
|
70
|
+
app_list.sort(lambda x, y: cmp(x['name'], y['name']))
|
|
71
|
+
|
|
72
|
+
# Sort the models alphabetically within each app.
|
|
73
|
+
for app in app_list:
|
|
74
|
+
app['models'].sort(lambda x, y: cmp(x['name'], y['name']))
|
|
75
|
+
# -- 8< -- copied from django.contrib.admin.sites.AdminSite.index
|
|
76
|
+
|
|
77
|
+
all_available = [app['app_label'] for app in app_list]
|
|
78
|
+
all_configured = reduce(operator.add, (list(v['apps']) for k, v in FHADMIN_GROUPS_CONFIG), [])
|
|
79
|
+
|
|
80
|
+
all_remains = [a for a in all_available if a not in all_configured]
|
|
81
|
+
|
|
82
|
+
for group_title, group in FHADMIN_GROUPS_CONFIG:
|
|
83
|
+
apps = []
|
|
84
|
+
for app in group['apps']:
|
|
85
|
+
if app == FHADMIN_GROUPS_REMAINING:
|
|
86
|
+
apps.extend(app_dict[a] for a in all_remains if a in app_dict)
|
|
87
|
+
elif app in app_dict:
|
|
88
|
+
apps.append(app_dict[app])
|
|
89
|
+
# else: Do nothing, ignore
|
|
90
|
+
|
|
91
|
+
if apps:
|
|
92
|
+
yield group_title, apps
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class FHAdminGroupListNode(template.Node):
|
|
96
|
+
def __init__(self, request):
|
|
97
|
+
self.request = template.Variable(request)
|
|
98
|
+
|
|
99
|
+
def render(self, context):
|
|
100
|
+
request = self.request.resolve(context)
|
|
101
|
+
context['group_list'] = fhadmin_group_list(admin.sites.site, request)
|
|
102
|
+
return u''
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def do_fhadmin_group_list(parser, token):
|
|
106
|
+
"""
|
|
107
|
+
{% fhadmin_group_list request %}
|
|
108
|
+
|
|
109
|
+
Creates a ``group_list`` variable in the current context.
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
tag_name, request = token.split_contents()
|
|
113
|
+
return FHAdminGroupListNode(request)
|
|
114
|
+
|
|
115
|
+
register.tag('fhadmin_group_list', do_fhadmin_group_list)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from setuptools import setup, find_packages
|
|
5
|
+
|
|
6
|
+
setup(name='django-fhadmin',
|
|
7
|
+
version='1.0',
|
|
8
|
+
description='Modifies the stock Django-Administration interface to fit our ideas a little bit better.',
|
|
9
|
+
author='Matthias Kestenholz',
|
|
10
|
+
author_email='mk@feinheit.ch',
|
|
11
|
+
url='http://github.com/feinheit/django-fhadmin/',
|
|
12
|
+
license='BSD License',
|
|
13
|
+
platforms=['OS Independent'],
|
|
14
|
+
packages=find_packages(),
|
|
15
|
+
include_package_data=True,
|
|
16
|
+
)
|