Skip to content

Commit

Permalink
got example working again and relocated initial data
Browse files Browse the repository at this point in the history
  • Loading branch information
justquick authored and bartTC committed Nov 2, 2009
1 parent 53b8630 commit e2a092c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
9 changes: 7 additions & 2 deletions example_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,17 @@
# Put frontendadmin before your applications, so that they can overwrite
# the frontendadmin templates.
'frontendadmin',
'template_utils',
'example_project.weblog',
)

# Define custom forms to handle any model
FRONTEND_FORMS = {
# ``app_label.model_name`` : ``form_class``,
'weblog.entry': 'weblog.forms.EntryForm',
'flatpages.flatpage': 'weblog.forms.FlatPageForm'
}

# Define which fields to exclude on a particular model
FRONTEND_EXCLUDES = {
# ``app_label.model_name`` : ``tuple``,
'weblog.entry': ('public',),
}
3 changes: 2 additions & 1 deletion example_project/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ <h1><a href="{% url weblog_index %}">my shiny weblog</a></h1>
</p>
<p class="thx">Thank you for testing
<a href="https://github.com/bartTC/django-frontendadmin/">django-frontendadmin</a></p>
<p>django-frontendadmin &copy; 2008 <a href="http://www.mahner.org/">Martin Mahner</a><br/>
<p>django-frontendadmin &copy; 2009 <a href="http://www.mahner.org/">Martin Mahner</a>,
<a href="http://serotoninstorm.com/">Justin Quick</a><br/>
licensed under the New BSD License</p>
</div>

Expand Down
3 changes: 2 additions & 1 deletion example_project/templates/weblog_overview.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "base.html" %}

{% load frontendadmin_tags %}
{% load comments %}

{% block content %}
Expand All @@ -12,7 +13,7 @@
------------------------------------------------------
{% endcomment %}

{% frontendadmin_add object_list label='Add a new weblog entry' %}
{% frontendadmin_add object_list 'Add a new weblog entry' %}

{% for entry in object_list %}
<div class="entry">
Expand Down
4 changes: 2 additions & 2 deletions example_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

url(r'^$',
'django.views.generic.list_detail.object_list', {
'queryset': Entry.objects.order_by('-published'),
'queryset': Entry.objects.filter(public=True).order_by('-published'),
'template_name': 'weblog_overview.html',
}, name='weblog_index'
),

url(r'^entry-(?P<object_id>[\d]+)/$',
'django.views.generic.list_detail.object_detail', {
'queryset': Entry.objects.order_by('-published'),
'queryset': Entry.objects.filter(public=True).order_by('-published'),
'template_name': 'weblog_details.html',
}, name='weblog_details'
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"pk": 1,
"model": "weblog.entry",
"fields": {
"public": true,
"content": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.",
"published": "2008-10-04 05:28:08",
"title": "My first Weblog entry"
Expand All @@ -27,6 +28,7 @@
"pk": 2,
"model": "weblog.entry",
"fields": {
"public": true,
"content": "Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.",
"published": "2008-10-04 05:28:08",
"title": "My second Weblog entry"
Expand All @@ -36,6 +38,7 @@
"pk": 3,
"model": "weblog.entry",
"fields": {
"public": true,
"content": "Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.",
"published": "2008-10-04 05:28:08",
"title": "Just another weblog entry"
Expand Down
17 changes: 17 additions & 0 deletions example_project/weblog/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django import forms
from models import Entry
from django.contrib.admin import widgets


class EntryForm(forms.ModelForm):
published = forms.CharField(widget=widgets.AdminSplitDateTime())

def clean_published(self):
"""
Join the split admin format into a single DateTime stamp
turn "[u'2008-10-04', u'05:28:08']" into 2008-10-04 05:28:08
"""
return filter(lambda c: not c in "u[],\'", self.cleaned_data['published'])

class Meta:
model = Entry
3 changes: 2 additions & 1 deletion example_project/weblog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class Entry(models.Model):
title = models.CharField(max_length=50)
content = models.TextField()
published = models.DateTimeField(default=datetime.datetime.now)

public = models.BooleanField(default=True)

class Meta:
verbose_name = u'Weblog Entry'
verbose_name_plural = u'Weblog Entries'
Expand Down

0 comments on commit e2a092c

Please sign in to comment.