From 27300433922788ed6630ae61608517780385f876 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Fri, 30 Dec 2011 01:42:04 +0100 Subject: add detailed newspost view, fixup base template --- sublab_project/news/models.py | 2 +- sublab_project/news/templates/news/news_detail.html | 10 ++++++++++ sublab_project/news/templates/news/news_list.html | 5 +++-- sublab_project/news/urls.py | 3 ++- sublab_project/static/css/sublab.css | 7 +++++++ sublab_project/templates/base.html | 3 +-- 6 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 sublab_project/news/templates/news/news_detail.html (limited to 'sublab_project') diff --git a/sublab_project/news/models.py b/sublab_project/news/models.py index 72074a0..cd98248 100644 --- a/sublab_project/news/models.py +++ b/sublab_project/news/models.py @@ -38,4 +38,4 @@ class News(models.Model): @models.permalink def get_absolute_url(self): - return ('news_detail', (), {'id': self.id}) + return ('news_detail', (), {'slug': self.slug}) diff --git a/sublab_project/news/templates/news/news_detail.html b/sublab_project/news/templates/news/news_detail.html new file mode 100644 index 0000000..e3a0de1 --- /dev/null +++ b/sublab_project/news/templates/news/news_detail.html @@ -0,0 +1,10 @@ +{% extends 'base.html' %} + +{% block title %}{{ object.title }}{% endblock %} + +{% block content %} +

{{ object.date_updated|date:"DATETIME_FORMAT" }}

+

{{ object.title }}

+

{{ object.content_html|safe }}

+

{{ object.author }}

+{% endblock content %} diff --git a/sublab_project/news/templates/news/news_list.html b/sublab_project/news/templates/news/news_list.html index ab998e8..6330ffb 100644 --- a/sublab_project/news/templates/news/news_list.html +++ b/sublab_project/news/templates/news/news_list.html @@ -1,10 +1,11 @@ {% extends 'base.html' %} {%block content %} +

sublab - news

{% for post in news_list %}

- {{ post.date_updated|date }} - {{ post.title }} + {{ post.date_updated|date }} - {{ post.title }}

-

{{ post.content }}

+

{{ post.content_html|safe }}

{% endfor %} {% endblock content %} diff --git a/sublab_project/news/urls.py b/sublab_project/news/urls.py index a1c5c0a..c26d12d 100644 --- a/sublab_project/news/urls.py +++ b/sublab_project/news/urls.py @@ -4,5 +4,6 @@ from django.views.generic import ListView, DetailView from news.models import News urlpatterns = patterns('', - url(r'^$', ListView.as_view(model=News, paginate_by=8), name='news_list') + url(r'^$', ListView.as_view(model=News, paginate_by=8), name='news_list'), + url(r'^news/(?P[-\w]+)/$', DetailView.as_view(model=News), name='news_detail'), ) diff --git a/sublab_project/static/css/sublab.css b/sublab_project/static/css/sublab.css index 20e9c5b..6a974f6 100644 --- a/sublab_project/static/css/sublab.css +++ b/sublab_project/static/css/sublab.css @@ -250,6 +250,13 @@ p.header { margin: 10px; } +p.news_date { + color: #ddd; + margin-bottom: -20px; + margin-left: 10px; + font-size: 10px; +} + span.header { background-color: rgba(16, 16, 16, 0.75); padding: 5px 10px 5px 10px; diff --git a/sublab_project/templates/base.html b/sublab_project/templates/base.html index 63b0f72..4c478d7 100644 --- a/sublab_project/templates/base.html +++ b/sublab_project/templates/base.html @@ -2,7 +2,7 @@ - {% block title %}sublab - Ein Hackerspace in Leipzig{% endblock %} + sublab - {% block title %}Ein Hackerspace in Leipzig{% endblock %} @@ -129,7 +129,6 @@ {% block content %} This is where the content would be. {% endblock %} -