Unstashing the previous changes

This commit is contained in:
Corey Oordt 2010-12-12 13:15:03 -05:00
parent b9e54d45f3
commit 4fbed625c4
39 changed files with 33 additions and 28 deletions

View file

@ -76,7 +76,7 @@ class CategoryAdminForm(forms.ModelForm):
class CategoryAdmin(TreeEditor, admin.ModelAdmin):
form = CategoryAdminForm
list_display = ('__unicode__',)
list_display = ('name',)
search_fields = (('name',))
prepopulated_fields = {'slug': ('name',)}
fieldsets = (

View file

@ -38,6 +38,10 @@ class Category(MPTTModel):
default="",
help_text="(Advanced) Any additional HTML to be placed verbatim in the <head>")
@property
def short_title(self):
return self.name
def get_absolute_url(self):
"""Return a path"""
prefix = reverse('categories_tree_list')

View file

@ -4,18 +4,16 @@ from django import forms, template
from django.contrib import admin
from django.contrib.admin import helpers
from django.contrib.admin.util import unquote
from django.db import models
from django.db.models import loading
from django.forms.formsets import all_valid
from django.forms.models import modelform_factory, inlineformset_factory
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render_to_response
from django.utils.encoding import force_unicode
from django.utils.functional import curry
from django.utils.translation import ugettext as _
from feincms import settings
from feincms.models import Region
import settings
FRONTEND_EDITING_MATCHER = re.compile(r'(\d+)/(\w+)/(\d+)')
@ -46,9 +44,6 @@ class ItemEditor(admin.ModelAdmin):
"""
This view is used strictly for frontend editing -- it is not used inside the
standard administration interface.
The code in feincms/templates/admin/feincms/fe_tools.html knows how to call
this view correctly.
"""
try:
@ -57,7 +52,7 @@ class ItemEditor(admin.ModelAdmin):
except:
raise Http404
form_class_base = getattr(model_cls, 'feincms_item_editor_form', ItemEditorForm)
form_class_base = getattr(model_cls, 'item_editor_form', ItemEditorForm)
ModelForm = modelform_factory(model_cls,
exclude=('parent', 'region', 'ordering'),
@ -81,7 +76,7 @@ class ItemEditor(admin.ModelAdmin):
if form.is_valid():
obj = form.save()
return render_to_response('admin/feincms/fe_editor_done.html', {
return render_to_response('admin/editor/editor_done.html', {
'content': obj.render(request=request),
'identifier': obj.fe_identifier(),
'MEDIA_PATH': settings.MEDIA_PATH,
@ -90,7 +85,7 @@ class ItemEditor(admin.ModelAdmin):
else:
form = ModelForm(instance=obj, prefix=content_type)
return render_to_response('admin/feincms/fe_editor.html', {
return render_to_response('admin/editor/editor.html', {
'frontend_editing': True,
'title': _('Change %s') % force_unicode(model_cls._meta.verbose_name),
'object': obj,
@ -100,7 +95,7 @@ class ItemEditor(admin.ModelAdmin):
'MEDIA_PATH': settings.MEDIA_PATH,
'MEDIA_HOTLINKING': settings.MEDIA_HOTLINKING,
}, context_instance=template.RequestContext(request,
processors=self.model.feincms_item_editor_context_processors))
processors=self.model.item_editor_context_processors))
def change_view(self, request, object_id, extra_context=None):
self.model._needs_content_types()
@ -121,9 +116,9 @@ class ItemEditor(admin.ModelAdmin):
inline_formset_types = [(
content_type,
inlineformset_factory(self.model, content_type, extra=1,
form=getattr(content_type, 'feincms_item_editor_form', ItemEditorForm),
form=getattr(content_type, 'item_editor_form', ItemEditorForm),
formfield_callback=self._formfield_callback(request=request))
) for content_type in self.model._feincms_content_types]
) for content_type in self.model._editor_content_types]
opts = self.model._meta
try:
@ -165,17 +160,17 @@ class ItemEditor(admin.ModelAdmin):
# Prepare mapping of content types to their prettified names
content_types = []
for content_type in self.model._feincms_content_types:
for content_type in self.model._editor_content_types:
content_name = content_type._meta.verbose_name
content_types.append((content_name, content_type.__name__.lower()))
context = {}
if hasattr(self.model, '_feincms_templates'):
if hasattr(self.model, '_editor_templates'):
if 'template_key' not in self.show_on_top:
self.show_on_top = ['template_key'] + list(self.show_on_top)
context['available_templates'] = self.model._feincms_templates
context['available_templates'] = self.model._editor_templates
context.update({
'title': _('Change %s') % force_unicode(opts.verbose_name),
@ -197,9 +192,9 @@ class ItemEditor(admin.ModelAdmin):
def render_item_editor(self, request, object, context):
opts = self.model._meta
return render_to_response([
'admin/feincms/%s/%s/item_editor.html' % (opts.app_label, opts.object_name.lower()),
'admin/feincms/%s/item_editor.html' % opts.app_label,
'admin/feincms/item_editor.html',
'admin/editor/%s/%s/item_editor.html' % (opts.app_label, opts.object_name.lower()),
'admin/editor/%s/item_editor.html' % opts.app_label,
'admin/editor/item_editor.html',
], context, context_instance=template.RequestContext(request,
processors=self.model.feincms_item_editor_context_processors))
processors=self.model.item_editor_context_processors))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,004 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

View file

@ -11,7 +11,7 @@ from django.utils.encoding import force_unicode, smart_unicode
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
from feincms import settings
import settings
class SplitPaneEditor(admin.ModelAdmin):

View file

@ -8,7 +8,6 @@ from django.utils.translation import ugettext_lazy as _
import settings
def django_boolean_icon(field_val, alt_text=None, title=None):
"""
Return HTML code for a nice representation of true/false.
@ -146,12 +145,19 @@ class TreeEditor(admin.ModelAdmin):
Generate a short title for a page, indent it depending on
the page's depth in the hierarchy.
"""
r = '''<span onclick="return page_tree_handler('%d')" id="page_marker-%d"
class="page_marker" style="width: %dpx;">&nbsp;</span>&nbsp;''' % (
item.id, item.id, 14+item.level*14)
if not item.is_leaf_node():
prefix = u"%s\u25bc" % ("&emsp;" * (item.level+1))
else:
prefix = u"%s&emsp;" % ("&emsp;" * (item.level+1))
r = u'<span id="page_marker-%d" style="width: %dpx;">%s</span>&nbsp;' % (
item.id, 14+item.level*14, prefix)
if hasattr(item, 'short_title'):
return mark_safe(r + item.short_title())
if callable(item.short_title):
short_title = item.short_title()
else:
short_title = item.short_title
return mark_safe(r + short_title)
return mark_safe(r + unicode(item))
indented_short_title.short_description = _('title')
indented_short_title.allow_tags = True