Mercurial > public > sg101
changeset 28:04377c5bf912
Added bulletins template tag.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 22 Apr 2009 00:34:42 +0000 |
parents | 03144b0d470d |
children | 74f04122295e |
files | gpp/bulletins/templatetags/__init__.py gpp/bulletins/templatetags/bulletin_tags.py gpp/settings.py gpp/templates/bulletins/bulletins.html gpp/templates/home.html media/css/base.css media/icons/asterisk_orange.png |
diffstat | 6 files changed, 47 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/bulletins/templatetags/bulletin_tags.py Wed Apr 22 00:34:42 2009 +0000 @@ -0,0 +1,17 @@ +""" +Template tags for the bulletins application. +""" +from django import template + +from bulletins.models import Bulletin + + +register = template.Library() + + +@register.inclusion_tag('bulletins/bulletins.html') +def current_bulletins(): + bulletins = Bulletin.objects.get_current() + return { + 'bulletins': bulletins, + }
--- a/gpp/settings.py Tue Apr 21 23:25:05 2009 +0000 +++ b/gpp/settings.py Wed Apr 22 00:34:42 2009 +0000 @@ -93,6 +93,7 @@ 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', + 'django.contrib.humanize', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.markup',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/bulletins/bulletins.html Wed Apr 22 00:34:42 2009 +0000 @@ -0,0 +1,11 @@ +{% load humanize %} +{% for bulletin in bulletins %} +<div class="bulletin" id="bulletin-{{ bulletin.id }}"> + <h3>{{ bulletin.title }}</h3> + <div class="bulletin-text"> + {{ bulletin.text|safe }} + </div> + <p class="bulletin-meta">Posted: {{ bulletin.start_date|naturalday|capfirst }} + {{ bulletin.start_date|date:"H:i" }}.</p> +</div> +{% endfor %}
--- a/gpp/templates/home.html Tue Apr 21 23:25:05 2009 +0000 +++ b/gpp/templates/home.html Wed Apr 22 00:34:42 2009 +0000 @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load bulletin_tags %} {% load weblinks_tags %} {% load downloads_tags %} {% block title %}Home{% endblock %} @@ -16,6 +17,7 @@ permanent. The site (content, user accounts, etc.) may be wiped at any time while we fix bugs and add features. Also, I hope that the look and feel of this site can be greatly improved to something really cool! I'll need lots of help for this aspect, as I'm more of a coder than a designer.</p> +{% current_bulletins %} <div class="span-9 append-1"> {% latest_weblinks %} </div>
--- a/media/css/base.css Tue Apr 21 23:25:05 2009 +0000 +++ b/media/css/base.css Wed Apr 22 00:34:42 2009 +0000 @@ -112,3 +112,19 @@ text-align: center; padding: 0.5em; } +.bulletin { + text-align: center; + margin: 1em 1em; + padding: 1em 1em 0; + border: 1px solid black; +} +.bulletin h3 { + background-image: url(../icons/asterisk_orange.png); + background-position: center left; + background-repeat: no-repeat; +} +.bulletin .bulletin-meta { + font-size: x-small; + color: gray; + text-align: right; +}