[cmsiki-svn] SF.net SVN: cmsiki: [16] trunk/cmsiki
Status: Pre-Alpha
Brought to you by:
cnu
From: <cn...@us...> - 2007-03-27 20:19:29
|
Revision: 16 http://cmsiki.svn.sourceforge.net/cmsiki/?rev=16&view=rev Author: cnu Date: 2007-03-27 13:19:28 -0700 (Tue, 27 Mar 2007) Log Message: ----------- Added permanent Pages Modified Paths: -------------- trunk/cmsiki/apps/story/models.py trunk/cmsiki/settings.py trunk/cmsiki/templates/base.html trunk/cmsiki/urls.py Added Paths: ----------- trunk/cmsiki/apps/page/ trunk/cmsiki/apps/page/__init__.py trunk/cmsiki/apps/page/models.py trunk/cmsiki/apps/page/views.py trunk/cmsiki/templates/page/ trunk/cmsiki/templates/page/page_detail.html Added: trunk/cmsiki/apps/page/__init__.py =================================================================== Added: trunk/cmsiki/apps/page/models.py =================================================================== --- trunk/cmsiki/apps/page/models.py (rev 0) +++ trunk/cmsiki/apps/page/models.py 2007-03-27 20:19:28 UTC (rev 16) @@ -0,0 +1,48 @@ +from django.db import models +from django.contrib.auth.models import User +import cmsikireplace + +# Create your models here. +WEIGHT_CHOICES = ( + (0, 0), + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10,10), +) + + + +class Page(models.Model): + title = models.CharField(maxlength=150) + body = models.TextField() + slug = models.SlugField(prepopulate_from=('title',)) + weight = models.IntegerField(choices=WEIGHT_CHOICES) + author = models.ForeignKey(User) + datetime = models.DateTimeField(auto_now_add=True, editable=False) + last_modified = models.DateTimeField(auto_now=True, editable=False) + + def __str__(self): + return self.title + + class Meta: + ordering = ['weight'] + + class Admin: + list_display = ('title','author','weight','last_modified') + list_filter = ('author', 'last_modified') + search_fields = ('title','body') + + def get_absolute_url(self): + '''Return the absolute URL of the page.''' + return '/%s/' % (self.slug) + + def replaced_body(self): + '''Replace the tags in the body from the data in the wiki.''' + return cmsikireplace.tagreplace(self.body) Added: trunk/cmsiki/apps/page/views.py =================================================================== --- trunk/cmsiki/apps/page/views.py (rev 0) +++ trunk/cmsiki/apps/page/views.py 2007-03-27 20:19:28 UTC (rev 16) @@ -0,0 +1 @@ +# Create your views here. Modified: trunk/cmsiki/apps/story/models.py =================================================================== --- trunk/cmsiki/apps/story/models.py 2007-03-27 19:14:07 UTC (rev 15) +++ trunk/cmsiki/apps/story/models.py 2007-03-27 20:19:28 UTC (rev 16) @@ -1,7 +1,7 @@ from django.db import models from django.contrib.auth.models import User import cmsikireplace -import re + # Create your models here. class Category(models.Model): Modified: trunk/cmsiki/settings.py =================================================================== --- trunk/cmsiki/settings.py 2007-03-27 19:14:07 UTC (rev 15) +++ trunk/cmsiki/settings.py 2007-03-27 20:19:28 UTC (rev 16) @@ -73,6 +73,7 @@ 'django.contrib.admin', 'django.contrib.comments', 'cmsiki.apps.story', + 'cmsiki.apps.page', ) # Comments: to get the URL of the current page a template variable Modified: trunk/cmsiki/templates/base.html =================================================================== --- trunk/cmsiki/templates/base.html 2007-03-27 19:14:07 UTC (rev 15) +++ trunk/cmsiki/templates/base.html 2007-03-27 20:19:28 UTC (rev 16) @@ -60,10 +60,12 @@ <h2>Pages</h2> {% block pages %} <ul> + {% for page in pages %} <li class="page_item"> - <a href="http://localhost/wordpress/?page_id=2" - title="About">About</a> + <a href="{{ page.get_absolute_url }}" + title="{{ page.title }}">{{ page.title }}</a> </li> + {% endfor %} </ul> {% endblock %} </li> Added: trunk/cmsiki/templates/page/page_detail.html =================================================================== --- trunk/cmsiki/templates/page/page_detail.html (rev 0) +++ trunk/cmsiki/templates/page/page_detail.html 2007-03-27 20:19:28 UTC (rev 16) @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %}{{ object.title }}{% endblock %} + +{% block post %} +<div class="post"> + <h2><a href="{{ object.get_absolute_url }}">{{ object.title }}</a></h2> + <div class="postinfo">Last Edited on <span class="postdate">{{ object.last_modified|date:"F j, Y" }}</span> by <strong>{{ object.author }}</strong></div> + {{ object.replaced_body }} + +</div> +{% endblock %} Modified: trunk/cmsiki/urls.py =================================================================== --- trunk/cmsiki/urls.py 2007-03-27 19:14:07 UTC (rev 15) +++ trunk/cmsiki/urls.py 2007-03-27 20:19:28 UTC (rev 16) @@ -1,5 +1,6 @@ from django.conf.urls.defaults import * from cmsiki.apps.story.models import * +from cmsiki.apps.page.models import * from django.conf import settings info_dict = { @@ -7,6 +8,7 @@ 'date_field': 'pub_date', 'extra_context':{ 'categories':Category.objects.all(), + 'pages':Page.objects.all(), }, } @@ -14,15 +16,26 @@ 'queryset':Category.objects.all(), 'extra_context':{ 'categories':Category.objects.all(), + 'pages':Page.objects.all(), }, } - + +page_detail_info = { + 'queryset': Page.objects.all(), + 'extra_context':{ + 'categories':Category.objects.all(), + 'pages':Page.objects.all(), + }, +} + +# Comments urlpatterns = patterns('', (r'^comments/', include('django.contrib.comments.urls.comments')), # (r'^comments/posted/', 'views.my_post_free_comment'), ) +# Stories urlpatterns += patterns('django.views.generic.date_based', # Example: # (r'^cmsiki/', include('cmsiki.apps.foo.urls.foo')), @@ -36,12 +49,18 @@ (r'^/?$', 'archive_index', dict(info_dict)), ) +# Categories urlpatterns += patterns('django.views.generic.list_detail', (r'^category/$', 'object_list', dict(category_detail_info)), (r'^category/(?P<slug>[-\w]+)/$', 'object_detail', dict(category_detail_info, slug_field='slug')), ) +# Pages +urlpatterns += patterns('django.views.generic.list_detail', + (r'^(?P<slug>[-\w]+)/$', 'object_detail', dict(page_detail_info, slug_field='slug')), +) + if settings.DEBUG: urlpatterns += patterns('', (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/cnu/projects/python/django/cmsiki/static/', 'show_indexes':True}), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |