Skip to content

Commit

Permalink
Initial import.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmcd committed Mar 11, 2011
0 parents commit a703b3a
Show file tree
Hide file tree
Showing 498 changed files with 51,298 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
syntax: glob
*.pyc
build/*
dist/*
grappelli_safe.egg-info/*
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include grappelli_safe/LICENSE
recursive-include grappelli_safe/media *
recursive-include grappelli_safe/templates *.html
recursive-include grappelli_safe/locale *.mo *.po
recursive-include grappelli_safe/models/fixtures *.json
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

Overview
========

grappelli_safe was created to provide a snapshot of the
`Grappelli admin skin <http://code.google.com/p/django-grappelli/>`_ for
`Django <http://www.djangoproject.com/>`_, to be referenced as a
dependency for the `Mezzanine CMS for Django <http://mezzanine.jupo.org/>`_.

At the time of grappelli_safe's creation, Grappelli was incorrectly
packaged on `PyPI <http://pypi.python.org/pypi>`_, and had also dropped
compatibility with Django 1.1 - grappelli_safe was therefore created to
address these specific issues.

This repository exists for bug fixes and minor enhancements, and
should some day become redundant, once the original Grappelli becomes
a feasibly stable dependency target.
24 changes: 24 additions & 0 deletions grappelli_safe/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2009, Patrick Kranzlmueller, Axel Swoboda (vonautomatisch werkstaetten),
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of FileBrowser nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions grappelli_safe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = '2.0'
189 changes: 189 additions & 0 deletions grappelli_safe/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# coding: utf-8

from django.contrib import admin
from django.utils.translation import ugettext as _
from django import forms
from django.conf import settings

from grappelli_safe.models.navigation import Navigation, NavigationItem
from grappelli_safe.models.bookmarks import Bookmark, BookmarkItem
from grappelli_safe.models.help import Help, HelpItem


class NavigationItemInline(admin.StackedInline):

model = NavigationItem
extra = 1
classes = ('collapse-open',)
fieldsets = (
('', {
'fields': ('title', 'link', 'category',)
}),
('', {
'fields': ('groups', 'users',),
}),
('', {
'fields': ('order',),
}),
)
filter_horizontal = ('users',)

# Grappelli Options
allow_add = True


class NavigationOptions(admin.ModelAdmin):

# List Options
list_display = ('order', 'title',)
list_display_links = ('title',)

# Fieldsets
fieldsets = (
('', {
'fields': ('title', 'order',)
}),
)

# Misc
save_as = True

# Inlines
inlines = [NavigationItemInline]

# Grappelli Options
order = 0


class BookmarkItemInline(admin.TabularInline):

model = BookmarkItem
extra = 1
classes = ('collapse-open',)
fieldsets = (
('', {
'fields': ('title', 'link', 'order',)
}),
)

# Grappelli Options
allow_add = True


class BookmarkOptions(admin.ModelAdmin):

# List Options
list_display = ('user',)
list_display_links = ('user',)

# Fieldsets
fieldsets = (
('', {
'fields': ('user',)
}),
)

# Misc
save_as = True

# Inlines
inlines = [BookmarkItemInline]

# Grappelli Options
order = 1

def has_change_permission(self, request, obj=None):
has_class_permission = super(BookmarkOptions, self).has_change_permission(request, obj)
if not has_class_permission:
return False
if obj is not None and not request.user.is_superuser and request.user.id != obj.user.id:
return False
return True

def save_model(self, request, obj, form, change):
if not request.user.is_superuser:
if not change:
obj.user = request.user
obj.save()

def queryset(self, request):
if request.user.is_superuser:
return Bookmark.objects.all()
return Bookmark.objects.filter(user=request.user)


class HelpItemInline(admin.StackedInline):

model = HelpItem
extra = 1
classes = ('collapse-open',)
fieldsets = (
('', {
'fields': ('title', 'link', 'body', 'order',)
}),
)

# Grappelli Options
allow_add = True


class HelpOptions(admin.ModelAdmin):

# List Options
list_display = ('order', 'title',)
list_display_links = ('title',)

# Fieldsets
fieldsets = (
('', {
'fields': ('title', 'order',)
}),
)

# Misc
save_as = True

# Inlines
inlines = [HelpItemInline]

# Grappelli Options
order = 2

# Media
class Media:
js = [
settings.ADMIN_MEDIA_PREFIX + 'tinymce/jscripts/tiny_mce/tiny_mce.js',
settings.ADMIN_MEDIA_PREFIX + 'tinymce_setup/tinymce_setup.js',
]


class HelpItemOptions(admin.ModelAdmin):

# List Options
list_display = ('order', 'title',)
list_display_links = ('title',)

# Fieldsets
fieldsets = (
('', {
'fields': ('help', 'title', 'link', 'body', 'order',)
}),
)

# Grappelli Options
order = 3

# Media
class Media:
js = [
settings.ADMIN_MEDIA_PREFIX + 'tinymce/jscripts/tiny_mce/tiny_mce.js',
settings.ADMIN_MEDIA_PREFIX + 'tinymce_setup/tinymce_setup.js',
]


#admin.site.register(Navigation, NavigationOptions)
#admin.site.register(Bookmark, BookmarkOptions)
#admin.site.register(Help, HelpOptions)
#admin.site.register(HelpItem, HelpItemOptions)


Loading

0 comments on commit a703b3a

Please sign in to comment.