[cmsiki-svn] SF.net SVN: cmsiki: [4] trunk/cmsiki
Status: Pre-Alpha
Brought to you by:
cnu
From: <cn...@us...> - 2007-03-21 19:06:45
|
Revision: 4 http://cmsiki.svn.sourceforge.net/cmsiki/?rev=4&view=rev Author: cnu Date: 2007-03-21 12:06:28 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Created Story app Added basic model for Story app Created simple template for story app with generic views Modified Paths: -------------- trunk/cmsiki/settings.py trunk/cmsiki/urls.py Added Paths: ----------- trunk/cmsiki/apps/ trunk/cmsiki/apps/__init__.py trunk/cmsiki/apps/story/ trunk/cmsiki/apps/story/__init__.py trunk/cmsiki/apps/story/models.py trunk/cmsiki/apps/story/views.py trunk/cmsiki/templates/ trunk/cmsiki/templates/admin/ trunk/cmsiki/templates/admin/base_site.html trunk/cmsiki/templates/story/ trunk/cmsiki/templates/story/story_archive.html trunk/cmsiki/templates/story/story_archive_day.html trunk/cmsiki/templates/story/story_archive_month.html trunk/cmsiki/templates/story/story_archive_year.html trunk/cmsiki/templates/story/story_detail.html Added: trunk/cmsiki/apps/__init__.py =================================================================== Added: trunk/cmsiki/apps/story/__init__.py =================================================================== Added: trunk/cmsiki/apps/story/models.py =================================================================== --- trunk/cmsiki/apps/story/models.py (rev 0) +++ trunk/cmsiki/apps/story/models.py 2007-03-21 19:06:28 UTC (rev 4) @@ -0,0 +1,37 @@ +from django.db import models +from django.contrib.auth.models import User +# Create your models here. + +class Category(models.Model): + name = models.CharField(maxlength=50) + description = models.CharField(maxlength=200) + + def __str__(self): + return self.name + + class Admin: + list_display = ('name', 'description') + +class Story(models.Model): + title = models.CharField(maxlength=150) + body = models.TextField() + category = models.ForeignKey(Category) + slug = models.SlugField(prepopulate_from=('title',), unique_for_date='pub_date') + author = models.ForeignKey(User) + pub_date = models.DateTimeField('Publish Date') + datetime = models.DateTimeField(auto_now_add=True,editable=False) + published = models.BooleanField() + + def __str__(self): + return self.title + + class Meta: + ordering = ['-pub_date'] + + class Admin: + list_display = ('title','category','author','pub_date','published') + list_filter = ('pub_date','author','published') + search_fields = ('title','body') + + def get_absolute_url(self): + return '/%s/%s/' % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug) Added: trunk/cmsiki/apps/story/views.py =================================================================== --- trunk/cmsiki/apps/story/views.py (rev 0) +++ trunk/cmsiki/apps/story/views.py 2007-03-21 19:06:28 UTC (rev 4) @@ -0,0 +1 @@ +# Create your views here. Modified: trunk/cmsiki/settings.py =================================================================== --- trunk/cmsiki/settings.py 2007-03-10 18:18:50 UTC (rev 3) +++ trunk/cmsiki/settings.py 2007-03-21 19:06:28 UTC (rev 4) @@ -9,16 +9,16 @@ MANAGERS = ADMINS -DATABASE_ENGINE = '' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. -DATABASE_NAME = '' # Or path to database file if using sqlite3. -DATABASE_USER = '' # Not used with sqlite3. +DATABASE_ENGINE = 'mysql' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. +DATABASE_NAME = 'cmsiki' # Or path to database file if using sqlite3. +DATABASE_USER = 'root' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. # Local time zone for this installation. All choices can be found here: # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE -TIME_ZONE = 'America/Chicago' +TIME_ZONE = 'America/Calcutta' # Language code for this installation. All choices can be found here: # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes @@ -62,11 +62,14 @@ TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates". # Always use forward slashes, even on Windows. + '/home/cnu/projects/python/django/cmsiki/templates' ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', - 'django.contrib.sites', + #'django.contrib.sites', + 'django.contrib.admin', + 'cmsiki.apps.story', ) Added: trunk/cmsiki/templates/admin/base_site.html =================================================================== --- trunk/cmsiki/templates/admin/base_site.html (rev 0) +++ trunk/cmsiki/templates/admin/base_site.html 2007-03-21 19:06:28 UTC (rev 4) @@ -0,0 +1,10 @@ +{% extends "admin/base.html" %} +{% load i18n %} + +{% block title %}{{ title|escape }} | {% trans 'cmsiki site admin' %}{% endblock %} + +{% block branding %} +<h1 id="site-name">{% trans 'cmsiki administration' %}</h1> +{% endblock %} + +{% block nav-global %}{% endblock %} Added: trunk/cmsiki/templates/story/story_archive.html =================================================================== --- trunk/cmsiki/templates/story/story_archive.html (rev 0) +++ trunk/cmsiki/templates/story/story_archive.html 2007-03-21 19:06:28 UTC (rev 4) @@ -0,0 +1,7 @@ +<h1>Latest entries</h1> + +{% for story in latest %} + <h2><a href="{{ story.get_absolute_url }}">{{ story.title }}</a></h2> + {{ story.body }} + <p class="date small">Posted by <strong>{{ story.author }}</strong> on {{ story.pub_date|date:"F j, Y" }} </p> +{% endfor %} \ No newline at end of file Added: trunk/cmsiki/templates/story/story_archive_day.html =================================================================== --- trunk/cmsiki/templates/story/story_archive_day.html (rev 0) +++ trunk/cmsiki/templates/story/story_archive_day.html 2007-03-21 19:06:28 UTC (rev 4) @@ -0,0 +1,9 @@ +<h1>{{ day|date:"F j" }} archive</h1> + +{% for story in object_list %} +<h2><a href="{{ story.get_absolute_url }}">{{ story.title }}</a></h2> +<p class="small date">{{ story.pub_date|date:"F j, Y" }}</p> +{{ story.body }} + +{% endfor %} + Added: trunk/cmsiki/templates/story/story_archive_month.html =================================================================== --- trunk/cmsiki/templates/story/story_archive_month.html (rev 0) +++ trunk/cmsiki/templates/story/story_archive_month.html 2007-03-21 19:06:28 UTC (rev 4) @@ -0,0 +1,9 @@ +<h1>{{ month|date:"F" }} archive</h1> + +{% for story in object_list %} +<h2><a href="{{ story.get_absolute_url }}">{{ story.title }}</a></h2> +<p class="small date">{{ story.pub_date|date:"F j, Y" }}</p> +{{ story.body }} + +{% endfor %} + Added: trunk/cmsiki/templates/story/story_archive_year.html =================================================================== --- trunk/cmsiki/templates/story/story_archive_year.html (rev 0) +++ trunk/cmsiki/templates/story/story_archive_year.html 2007-03-21 19:06:28 UTC (rev 4) @@ -0,0 +1,7 @@ +<h1>{{ year }} archive</h1> + +<ul class="linklist"> +{% for date in date_list %} +<li><a href="{{ date|date:"M"|lower }}/">{{ date|date:"F" }}</a></li> +{% endfor %} +</ul> \ No newline at end of file Added: trunk/cmsiki/templates/story/story_detail.html =================================================================== --- trunk/cmsiki/templates/story/story_detail.html (rev 0) +++ trunk/cmsiki/templates/story/story_detail.html 2007-03-21 19:06:28 UTC (rev 4) @@ -0,0 +1,3 @@ +<h1>{{ object.title }}</h1> +{{ object.body }} +<p class="date small">Posted by <strong>{{ object.author }}</strong> on {{ object.pub_date|date:"F j, Y" }}</p> \ No newline at end of file Modified: trunk/cmsiki/urls.py =================================================================== --- trunk/cmsiki/urls.py 2007-03-10 18:18:50 UTC (rev 3) +++ trunk/cmsiki/urls.py 2007-03-21 19:06:28 UTC (rev 4) @@ -1,9 +1,21 @@ from django.conf.urls.defaults import * +from cmsiki.apps.story.models import Story -urlpatterns = patterns('', +info_dict = { + 'queryset': Story.objects.all(), + 'date_field': 'pub_date', +} + + +urlpatterns = patterns('django.views.generic.date_based', # Example: # (r'^cmsiki/', include('cmsiki.apps.foo.urls.foo')), # Uncomment this for admin: -# (r'^admin/', include('django.contrib.admin.urls')), -) + (r'^admin/', include('django.contrib.admin.urls')), + (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', 'object_detail', dict(info_dict, slug_field='slug')), + (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'archive_day', info_dict), + (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', info_dict), + (r'^(?P<year>\d{4})/$', 'archive_year', info_dict), + (r'^/?$', 'archive_index', info_dict), +) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |