Commits

Horst Gutmann committed 957e9ce

Updates urls to use the url-object and also the latest_news.html template to be a bit more flexible

  • Participants
  • Parent commits 14a45ca

Comments (0)

Files changed (2)

File cmsplugin_news/templates/cmsplugin_news/latest_news.html

 {% load i18n %}
-<h1>{% trans "Latest news" %}</h1>
-<ul>
-{% for news in latest %}
-	<li><a href="{{ news.get_absolute_url }}">{{ news.title }}</a></li>
-{% empty %}
-	<li>{% trans "No news yet" %}</li>
-{% endfor %}
-</ul>
-<a href="{% url news_archive_index %}">Archive</a>
+<div class="cmsplugin-news">
+    <h2>{% trans "Latest news" %}</h2>
+    <div class="content">
+        {% if latest %}
+            <ul>
+            {% for news in latest %}
+                <li>
+                <a href="{{ news.get_absolute_url }}">{{ news.title }}</a>
+                <span class="pub_date">{{ news.pub_date|date:"DATE_FORMAT" }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        {% else %}
+            <p class="empty">{% trans "No news yet" %}</p>
+        {% endif %}
+        <a href="{% url news_archive_index %}">{% trans "Archive" %}</a>
+    </div>
+</div>

File cmsplugin_news/urls.py

 }
 
 urlpatterns = patterns('django.views.generic.date_based',
-    (r'^$', 
-        'archive_index', news_info_dict, 'news_archive_index'),
+    url(r'^$', 
+        'archive_index', news_info_dict, name='news_archive_index'),
     
-    (r'^(?P<year>\d{4})/$', 
-        'archive_year', news_info_dict, 'news_archive_year'),
+    url(r'^(?P<year>\d{4})/$', 
+        'archive_year', news_info_dict, name='news_archive_year'),
     
-    (r'^(?P<year>\d{4})/(?P<month>\d{2})/$', 
-        'archive_month', news_info_month_dict, 'news_archive_month'),
+    url(r'^(?P<year>\d{4})/(?P<month>\d{2})/$', 
+        'archive_month', news_info_month_dict, name='news_archive_month'),
     
-    (r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', 
-        'archive_day', news_info_month_dict, 'news_archive_day'),
+    url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', 
+        'archive_day', news_info_month_dict, name='news_archive_day'),
     
-    (r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$', 
-        'object_detail', news_info_month_dict, 'news_detail'),
+    url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$', 
+        'object_detail', news_info_month_dict, name='news_detail'),
 
     url(r'^feed/$', feeds.NewsFeed())
 )