From 17dd049b947cb447628002bae3068581733565f1 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 25 Jan 2009 09:52:32 -0500 Subject: tweaked comments form, journal starting to work --- bn_django/journal/templates/journal/base.html | 5 ++ .../journal/templates/journal/entry_detail.html | 31 ++++++++++++ .../journal/templates/journal/entry_list.html | 23 +++++++++ bn_django/journal/urls.py | 4 +- bn_django/photos/models.py | 2 +- bn_django/photos/urls.py | 8 ++-- bn_django/photos/views.py | 56 +++++++++++----------- bn_django/templates/comments/form.html | 23 +++++++++ 8 files changed, 117 insertions(+), 35 deletions(-) create mode 100644 bn_django/journal/templates/journal/base.html create mode 100644 bn_django/journal/templates/journal/entry_detail.html create mode 100644 bn_django/journal/templates/journal/entry_list.html create mode 100644 bn_django/templates/comments/form.html (limited to 'bn_django') diff --git a/bn_django/journal/templates/journal/base.html b/bn_django/journal/templates/journal/base.html new file mode 100644 index 0000000..819b1f4 --- /dev/null +++ b/bn_django/journal/templates/journal/base.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block path %} + journal +{% endblock %} diff --git a/bn_django/journal/templates/journal/entry_detail.html b/bn_django/journal/templates/journal/entry_detail.html new file mode 100644 index 0000000..45edd4b --- /dev/null +++ b/bn_django/journal/templates/journal/entry_detail.html @@ -0,0 +1,31 @@ +{% extends "journal/base.html" %} +{# {% load markup %} #} +{% load comments %} +{% block path %}{{ block.super }} + » {{ object.title }} +{% endblock %} + +{% block title %} +{% if object.title %}{{ object.title }}{% else %}[Untitled Entry]{% endif %} +{% endblock %} + +{% block content %}
+{% if object %}
+

Entry dated {{ object.date }}, +{% if object.author %}
written by {{ object.author }},{% endif %} +{% if object.last_edited %}
last edited {{ object.last_edited }}.{% endif %} +

+

{{ object.html_content|safe }}

+{% else %} +

This is not the entry you are looking for.

+{% endif %} +{% endblock %} + +{% block commentary %} +
+

Post a comment

+{% render_comment_form for object %} +{% get_comment_list for object as comments %} +{% include "comment_list" %} +
+{% endblock %} diff --git a/bn_django/journal/templates/journal/entry_list.html b/bn_django/journal/templates/journal/entry_list.html new file mode 100644 index 0000000..f103c4e --- /dev/null +++ b/bn_django/journal/templates/journal/entry_list.html @@ -0,0 +1,23 @@ +{% extends "journal/base.html" %} +{# {% load markup %} #} + +{% block title %}Journal Entries{% endblock %} + +{% block content %} +
+{% if object_list %} + +{% else %} +

No entries have been entered yet.

+{% endif %} + +{% if is_paginated %} {% if has_previous %} +
« previous | +{% endif %} {% if has_next %} +next » +{% endif %} {% endif %} +{% endblock %} diff --git a/bn_django/journal/urls.py b/bn_django/journal/urls.py index d65d52a..1730ac7 100644 --- a/bn_django/journal/urls.py +++ b/bn_django/journal/urls.py @@ -7,6 +7,6 @@ urlpatterns = patterns('django.views.generic.list_detail', (r'^$', 'object_list', dict(queryset=Entry.objects.order_by('-date'), paginate_by=35, allow_empty=False)), - (r'^(?P)/$', 'object_detail', - dict(info_dict, queryset=Entry.objects.all(), slug_field='slug')), + (r'^(?P[\d\w-]+)/$', 'object_detail', + dict(queryset=Entry.objects.all(), slug_field='slug')), ) diff --git a/bn_django/photos/models.py b/bn_django/photos/models.py index 73d09e9..3d47cf0 100644 --- a/bn_django/photos/models.py +++ b/bn_django/photos/models.py @@ -82,7 +82,7 @@ class Photo(models.Model): title = models.CharField("title", max_length=80) desc = models.TextField("description", blank=True) gallery = models.ForeignKey(Gallery) - photographer = models.CharField("photographer"), max_length=80, + photographer = models.CharField("photographer", max_length=80, blank=True) date = models.DateField("date photographed", blank=True, null=True) extra = models.TextField("any extra information about the photo", diff --git a/bn_django/photos/urls.py b/bn_django/photos/urls.py index 6c7fc19..f50a97b 100644 --- a/bn_django/photos/urls.py +++ b/bn_django/photos/urls.py @@ -17,7 +17,7 @@ urlpatterns = patterns('django.views.generic.list_detail', (r'^detail/(?P\d+)/$', 'object_detail', dict(info_dict, queryset=Photo.objects.all())), ) -urlpatterns += patterns('bn_django.photos.views', - (r'^import/(\d+)/$', 'import_photos'), - (r'^export/(\d+)/$', 'export'), -) +#urlpatterns += patterns('bn_django.photos.views', + #(r'^import/(\d+)/$', 'import_photos'), + #(r'^export/(\d+)/$', 'export'), +#) diff --git a/bn_django/photos/views.py b/bn_django/photos/views.py index 7cc5332..bc8a3a4 100644 --- a/bn_django/photos/views.py +++ b/bn_django/photos/views.py @@ -126,31 +126,31 @@ def import_photos(request, thegallery): dict(form=form, gallery=gallery)) # request, -@login_required -def export(request, thegallery): - """Export a gallery to a zip file and send it to the user. - """ - # Check if the gallery is valid - gallery = get_object_or_404(Gallery, pk=thegallery) - - # gather up the photos into a new directory - tmpdir = mkdtemp() - for photo in gallery.photo_set.all(): - shutil.copy(photo.get_image_filename(), - tmpdir) - files = [ os.path.join(tmpdir, ff) for ff in os.listdir(tmpdir) ] - outfile = NamedTemporaryFile() - zf = zipfile.ZipFile(outfile, "w", - compression=zipfile.ZIP_DEFLATED) - for filename in files: - zf.write(filename, arcname=os.path.basename(filename)) - zf.close() - outfile.flush() - outfile.seek(0) - shutil.rmtree(tmpdir) - response = HttpResponse(outfile) - response['Content-Type'] = "application/zip" - response['Content-Length'] = str(os.stat(outfile.name)[stat.ST_SIZE]) - response['Content-Disposition'] = "attachment; filename=photos.zip" - return response - +#@login_required +#def export(request, thegallery): + #"""Export a gallery to a zip file and send it to the user. + #""" + ## Check if the gallery is valid + #gallery = get_object_or_404(Gallery, pk=thegallery) + # + ## gather up the photos into a new directory + #tmpdir = mkdtemp() + #for photo in gallery.photo_set.all(): + #shutil.copy(photo.get_image_filename(), + #tmpdir) + #files = [ os.path.join(tmpdir, ff) for ff in os.listdir(tmpdir) ] + #outfile = NamedTemporaryFile() + #zf = zipfile.ZipFile(outfile, "w", + #compression=zipfile.ZIP_DEFLATED) + #for filename in files: + #zf.write(filename, arcname=os.path.basename(filename)) + #zf.close() + ##outfile.flush() + #outfile.seek(0) + #shutil.rmtree(tmpdir) + #response = HttpResponse(outfile) + #response['Content-Type'] = "application/zip" + #response['Content-Length'] = str(os.stat(outfile.name)[stat.ST_SIZE]) + #response['Content-Disposition'] = "attachment; filename=photos.zip" + #return response + # diff --git a/bn_django/templates/comments/form.html b/bn_django/templates/comments/form.html new file mode 100644 index 0000000..67068e8 --- /dev/null +++ b/bn_django/templates/comments/form.html @@ -0,0 +1,23 @@ +{% load comments i18n %} +
+ + {% for field in form %} + {% if field.is_hidden %} {{ field }} {% else %} + {% ifequal field.name "honeypot" %} + {{ field.label_tag }}{{ field }} + {% else %} + + + {% endifequal %} + {% endif %} + {% endfor %} + +
+ + {% if field.errors %}{{ field.errors }}{% endif %} + {{ field.label_tag }}{{ field }} +
+ + +
+
-- cgit v1.2.3