From: Joseph Spiros Date: Wed, 16 Jun 2010 15:31:37 +0000 (-0400) Subject: Merge branch 'master' into penfield X-Git-Tag: philo-0.9~67^2~13 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/cf2b9630938e8c74f7037adacd2f5f0a4b6f2faa?hp=993f653fa30459f1c9e186f9b945826dba1dcf59 Merge branch 'master' into penfield --- diff --git a/README b/README index 82333d6..4170400 100644 --- a/README +++ b/README @@ -2,7 +2,6 @@ Philo is a foundation for developing web content management systems. Prerequisites: * Python 2.5.4+ - * simplejson (Not required with Python 2.6+) * Django 1.1.1+ * (Optional) django-grappelli 2.0+ diff --git a/__init__.py b/__init__.py index 8ad7212..9fc18ae 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,4 @@ -from models import Template +from philo.models import Template load_template_source = Template.loader diff --git a/admin.py b/admin.py index fa62647..178a904 100644 --- a/admin.py +++ b/admin.py @@ -7,7 +7,7 @@ from django.utils.translation import ugettext as _ from django.utils.safestring import mark_safe from django.utils.html import escape from django.utils.text import truncate_words -from models import * +from philo.models import * class AttributeInline(generic.GenericTabularInline): @@ -15,7 +15,7 @@ class AttributeInline(generic.GenericTabularInline): ct_fk_field = 'entity_object_id' model = Attribute extra = 1 - classes = ('collapse-closed',) + template = 'admin/philo/edit_inline/tabular_collapse.html' allow_add = True @@ -24,7 +24,7 @@ class RelationshipInline(generic.GenericTabularInline): ct_fk_field = 'entity_object_id' model = Relationship extra = 1 - classes = ('collapse-closed',) + template = 'admin/philo/edit_inline/tabular_collapse.html' allow_add = True @@ -45,26 +45,8 @@ class CollectionAdmin(admin.ModelAdmin): inlines = [CollectionMemberInline] -class TemplateAdmin(admin.ModelAdmin): - prepopulated_fields = {'slug': ('name',)} - fieldsets = ( - (None, { - 'fields': ('parent', 'name', 'slug') - }), - ('Documentation', { - 'classes': ('collapse', 'collapse-closed'), - 'fields': ('documentation',) - }), - (None, { - 'fields': ('code',) - }), - ('Advanced', { - 'classes': ('collapse','collapse-closed'), - 'fields': ('mimetype',) - }), - ) - save_on_top = True - save_as = True +class NodeAdmin(EntityAdmin): + pass class ModelLookupWidget(forms.TextInput): @@ -94,15 +76,41 @@ class ModelLookupWidget(forms.TextInput): return mark_safe(output) -class PageAdmin(EntityAdmin): +class RedirectAdmin(NodeAdmin): + fieldsets = ( + (None, { + 'fields': ('slug', 'target', 'status_code') + }), + ('URL/Tree/Hierarchy', { + 'classes': ('collapse', 'collapse-closed'), + 'fields': ('parent',) + }), + ) + + +class FileAdmin(NodeAdmin): + prepopulated_fields = {'slug': ('file',)} + fieldsets = ( + (None, { + 'fields': ('file', 'slug', 'mimetype') + }), + ('URL/Tree/Hierarchy', { + 'classes': ('collapse', 'collapse-closed'), + 'fields': ('parent',) + }), + ) + + +class PageAdmin(NodeAdmin): + add_form_template = 'admin/philo/page/add_form.html' prepopulated_fields = {'slug': ('title',)} fieldsets = ( (None, { - 'fields': ('title', 'template') + 'fields': ('title', 'slug', 'template') }), ('URL/Tree/Hierarchy', { 'classes': ('collapse', 'collapse-closed'), - 'fields': ('parent', 'slug') + 'fields': ('parent',) }), ) list_display = ('title', 'path', 'template') @@ -112,8 +120,11 @@ class PageAdmin(EntityAdmin): def get_fieldsets(self, request, obj=None, **kwargs): fieldsets = list(self.fieldsets) if obj: # if no obj, creating a new page, thus no template set, thus no containers - page = obj - template = page.template + template = obj.template + if template.documentation: + fieldsets.append(('Template Documentation', { + 'description': template.documentation + })) contentlet_containers, contentreference_containers = template.containers for container_name in contentlet_containers: fieldsets.append((('Container: %s' % container_name), { @@ -173,8 +184,30 @@ class PageAdmin(EntityAdmin): contentreference.save() +class TemplateAdmin(admin.ModelAdmin): + prepopulated_fields = {'slug': ('name',)} + fieldsets = ( + (None, { + 'fields': ('parent', 'name', 'slug') + }), + ('Documentation', { + 'classes': ('collapse', 'collapse-closed'), + 'fields': ('documentation',) + }), + (None, { + 'fields': ('code',) + }), + ('Advanced', { + 'classes': ('collapse','collapse-closed'), + 'fields': ('mimetype',) + }), + ) + save_on_top = True + save_as = True + + admin.site.register(Collection, CollectionAdmin) -admin.site.register(Redirect) -admin.site.register(File) +admin.site.register(Redirect, RedirectAdmin) +admin.site.register(File, FileAdmin) admin.site.register(Page, PageAdmin) admin.site.register(Template, TemplateAdmin) diff --git a/models.py b/models.py index eb6ebc0..ecd1c1f 100644 --- a/models.py +++ b/models.py @@ -5,18 +5,15 @@ from django.contrib.contenttypes import generic from django.contrib.contenttypes.models import ContentType from django.db import models from django.contrib.sites.models import Site -from utils import fattr +from philo.utils import fattr from django.template import add_to_builtins as register_templatetags from django.template import Template as DjangoTemplate from django.template import TemplateDoesNotExist from django.template import Context, RequestContext from django.core.exceptions import ObjectDoesNotExist -try: - import json -except ImportError: - import simplejson as json +from django.utils import simplejson as json from UserDict import DictMixin -from templatetags.containers import ContainerNode +from philo.templatetags.containers import ContainerNode from django.template.loader_tags import ExtendsNode, ConstantIncludeNode, IncludeNode from django.template.loader import get_template from django.http import Http404, HttpResponse, HttpResponseServerError, HttpResponseRedirect diff --git a/templates/admin/philo/edit_inline/tabular_collapse.html b/templates/admin/philo/edit_inline/tabular_collapse.html new file mode 100644 index 0000000..c457297 --- /dev/null +++ b/templates/admin/philo/edit_inline/tabular_collapse.html @@ -0,0 +1,125 @@ +{% load i18n adminmedia %} +
+ +
+ + diff --git a/templates/admin/philo/page/add_form.html b/templates/admin/philo/page/add_form.html new file mode 100644 index 0000000..8937463 --- /dev/null +++ b/templates/admin/philo/page/add_form.html @@ -0,0 +1,13 @@ +{% extends "admin/change_form.html" %} +{% load i18n %} + +{% block form_top %} +

{% trans "First, choose a template. After saving, you'll be able to provide additional content for containers." %}

+ +{% endblock %} + +{% block content %} +{% with 0 as save_on_top %} +{{ block.super }} +{% endwith %} +{% endblock %} \ No newline at end of file diff --git a/views.py b/views.py index c03f687..f086bfd 100644 --- a/views.py +++ b/views.py @@ -1,7 +1,7 @@ from django.http import Http404, HttpResponse from django.template import RequestContext from django.contrib.sites.models import Site -from models import Node +from philo.models import Node def node_view(request, path=None, **kwargs):