Permalink
Browse files

got example working again and relocated initial data

  • Loading branch information...
1 parent 53b8630 commit e2a092c8e7839f9dd766b89da61d787ff1d1884b @justquick justquick committed with bartTC Oct 30, 2009
View
9 example_project/settings.py
@@ -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',),
+}
View
3 example_project/templates/base.html
@@ -154,7 +154,8 @@
</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>
View
3 example_project/templates/weblog_overview.html
@@ -1,5 +1,6 @@
{% extends "base.html" %}
+{% load frontendadmin_tags %}
{% load comments %}
{% block content %}
@@ -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">
View
4 example_project/urls.py
@@ -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'
),
View
3 example_project/testdata.json → ...project/weblog/fixtures/initial_data.json
@@ -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"
@@ -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"
@@ -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"
View
17 example_project/weblog/forms.py
@@ -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
View
3 example_project/weblog/models.py
@@ -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'

0 comments on commit e2a092c

Please sign in to comment.