mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-03-16 22:20:24 +00:00
Work on stuff
This commit is contained in:
parent
b3485503d2
commit
0d9681f2fc
7 changed files with 91 additions and 15 deletions
|
|
@ -1,4 +1,4 @@
|
|||
include README.rst
|
||||
include LICENSE
|
||||
include CONTRIBUTORS.txt
|
||||
recursive-include admin2 *.py
|
||||
include MANIFEST.in
|
||||
|
|
@ -9,4 +9,4 @@ def get_version():
|
|||
version = '%s.%s' % (version, VERSION[2])
|
||||
return version
|
||||
|
||||
__version__ = get_version()
|
||||
__version__ = get_version()
|
||||
|
|
|
|||
|
|
@ -1 +1,67 @@
|
|||
""" Here because Django requires this as boilerplate. """
|
||||
try:
|
||||
import floppyforms as forms
|
||||
except ImportError:
|
||||
from django import forms
|
||||
|
||||
|
||||
class BaseAdmin2(object):
|
||||
|
||||
search_fields = []
|
||||
|
||||
# Show the fields to be displayed as columns
|
||||
# TODO: Confirm that this is what the Django admin uses
|
||||
list_fields = []
|
||||
|
||||
#This shows up on the DocumentListView of the Posts
|
||||
list_actions = []
|
||||
|
||||
# This shows up in the DocumentDetailView of the Posts.
|
||||
document_actions = []
|
||||
|
||||
# shows up on a particular field
|
||||
field_actions = {}
|
||||
|
||||
fields = None
|
||||
exclude = None
|
||||
fieldsets = None
|
||||
form = forms.ModelForm
|
||||
filter_vertical = ()
|
||||
filter_horizontal = ()
|
||||
radio_fields = {}
|
||||
prepopulated_fields = {}
|
||||
formfield_overrides = {}
|
||||
readonly_fields = ()
|
||||
ordering = None
|
||||
|
||||
def has_view_permission(self, request):
|
||||
"""
|
||||
Returns True if the given HttpRequest has permission to view
|
||||
*at least one* page in the mongonaut site.
|
||||
"""
|
||||
return request.user.is_authenticated() and request.user.is_active
|
||||
|
||||
def has_edit_permission(self, request):
|
||||
""" Can edit this object """
|
||||
return request.user.is_authenticated() and request.user.is_active and request.user.is_staff
|
||||
|
||||
def has_add_permission(self, request):
|
||||
""" Can add this object """
|
||||
return request.user.is_authenticated() and request.user.is_active and request.user.is_staff
|
||||
|
||||
def has_delete_permission(self, request):
|
||||
""" Can delete this object """
|
||||
return request.user.is_authenticated() and request.user.is_active and request.user.is_superuser
|
||||
|
||||
|
||||
class Admin2(BaseAdmin2):
|
||||
|
||||
list_display = ('__str__',)
|
||||
list_display_links = ()
|
||||
list_filter = ()
|
||||
list_select_related = False
|
||||
list_per_page = 100
|
||||
list_max_show_all = 200
|
||||
list_editable = ()
|
||||
search_fields = ()
|
||||
save_as = False
|
||||
save_on_top = False
|
||||
|
|
|
|||
9
admin2/templates/admin2/bootstrap/index.html
Normal file
9
admin2/templates/admin2/bootstrap/index.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<body>
|
||||
<h1>Index</h1>
|
||||
|
||||
{% for obj in object_list %}
|
||||
{{ obj }}
|
||||
{% endfor %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -16,16 +16,17 @@ class AppStore(object):
|
|||
self.models.append(model)
|
||||
|
||||
|
||||
def get_admin2s(self):
|
||||
def get_admin2s():
|
||||
""" Returns a list of all admin2 implementations for the site """
|
||||
apps = []
|
||||
for app_name in settings.INSTALLED_APPS:
|
||||
admin2 = "{0}.admin2".format(app_name)
|
||||
for app_name in [x for x in settings.INSTALLED_APPS if x != 'admin2']:
|
||||
name = "{0}.admin2".format(app_name)
|
||||
try:
|
||||
module = import_module(admin2)
|
||||
module = import_module(name)
|
||||
except ImportError as e:
|
||||
if str(e) == "No module named admin2":
|
||||
continue
|
||||
print name
|
||||
raise e
|
||||
|
||||
app_store = AppStore(module)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from os import join
|
||||
from os.path import join
|
||||
|
||||
from django.conf import settings
|
||||
from django.views.generic import ListView
|
||||
|
|
@ -6,13 +6,13 @@ from django.views.generic import ListView
|
|||
from braces.views import LoginRequiredMixin, StaffuserRequiredMixin
|
||||
from .utils import get_admin2s
|
||||
|
||||
ADMIN2_THEME_DIRECTORY = settings.get("ADMIN2_THEME_DIRECTORY", "admin2/bootstrap")
|
||||
ADMIN2_THEME_DIRECTORY = getattr(settings, "ADMIN2_THEME_DIRECTORY", "admin2/bootstrap")
|
||||
|
||||
|
||||
class IndexView(LoginRequiredMixin, StaffuserRequiredMixin, ListView):
|
||||
class IndexView(ListView):#LoginRequiredMixin, StaffuserRequiredMixin, ListView):
|
||||
|
||||
def get_template_name(self):
|
||||
return join(ADMIN2_THEME_DIRECTORY, "index.html")
|
||||
def get_template_names(self):
|
||||
return [join(ADMIN2_THEME_DIRECTORY, "index.html")]
|
||||
|
||||
def get_queryset(self):
|
||||
return get_admin2s()
|
||||
|
|
|
|||
6
setup.py
6
setup.py
|
|
@ -27,8 +27,8 @@ setup(
|
|||
author_email='pydanny@gmail.com',
|
||||
url='http://github.com/pydanny/django-admin2',
|
||||
license='MIT',
|
||||
packages=find_packages(exclude=['examples']),
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
install_requires=['django>=1.5.0', 'django-braces=='],
|
||||
install_requires=['django>=1.5.0', 'django-braces==1.0.0'],
|
||||
zip_safe=False,
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue