Commits

Adam Knight committed 74487f9

Rename to Milton; XML-RPC fixes; Section fixes

  • Participants
  • Parent commits 9933ea5

Comments (0)

Files changed (11)

 from django.contrib import admin
 from django.utils.translation import ugettext_lazy as _
 
-from sitepoet.models import *
+from milton.models import *
 
 ## ACTIONS ##
 

File drupal_support/management/commands/convertdrupal.py

 from django.contrib.sites.models import Site
 from django.core.management.base import BaseCommand, CommandError
 
-from sitepoet.drupal_support.models import *
-from sitepoet.models import *
-from sitepoet.templatetags.slugify import slugify
+from milton.drupal_support.models import *
+from milton.models import *
+from milton.templatetags.slugify import slugify
 
-from sitepoet.threadedcomments.models import MPTTComment
+from milton.threadedcomments.models import MPTTComment
 
 def vancode2int(vancode):
     if len(vancode):

File metaweblog.py

 
 import urlparse
 from django.contrib.auth.models import User
-from sitepoet.models import *
+from milton.models import *
 from tagging.models import Tag
 from tagging.utils import parse_tag_input
-from sitepoet.xmlrpc import public
+from milton.xmlrpc import public
 from django.conf import settings
 from django.core.urlresolvers import reverse
 import xmlrpclib # import DateTime

File middleware/__init__.py

 from django.http import HttpResponsePermanentRedirect, HttpResponseRedirect, HttpResponseGone, Http404
 from django.template import Template, RequestContext, loader
 
-from sitepoet.models import Redirect, Page, Story
-from sitepoet.views import view_page
+from milton.models import Redirect, Page, Story
+from milton.views import view_page
 
 class RedirectionMiddleware(object):
     def process_response(self, request, response):

File middleware/page.py

 from django.conf import settings
 from django.http import Http404
 
-from sitepoet.models import Page
-from sitepoet.views import view_page
+from milton.models import Page
+from milton.views import view_page
 
 
 class PageMiddleware(object):

File middleware/redirection.py

 from django.conf import settings
 from django.http import HttpResponsePermanentRedirect, HttpResponseRedirect, HttpResponseGone
 from django.template import RequestContext, loader
-from sitepoet.models import Redirect
+from milton.models import Redirect
 
 class RedirectionMiddleware(object):
     def process_response(self, request, response):
 import tagging
 from tagging.fields import TagField
 
-from sitepoet.managers import *
-from sitepoet.templatetags.slugify import slugify
+from milton.managers import *
+from milton.templatetags.slugify import slugify
 
 
 ### CONSTANTS ###
         abstract = True
         get_latest_by = 'date_published'
     
-    @property
-    def visible(self):
-        return (self.status == ENTRY_STATUS_PUBLISHED and self.date_published < datetime.datetime.now())
-    
     def __init__(self, *args, **kwargs):
         super(Resource, self).__init__(*args, **kwargs)
         if self.id != None:
         return self.title
     
     @property
+    def visible(self):
+        return (self.status == ENTRY_STATUS_PUBLISHED and self.date_published < datetime.datetime.now())
+    
+    @property
+    def modified_since_publication(self):
+        # Allow for some immediate changes for formatting, etc.
+        forgiveness = datetime.timedelta(minutes=1)
+        
+        return (self.date_modified > (self.date_published + forgiveness))
+    
+    @property
     def formatted_teaser(self):
         return format_text(self.teaser_format, self.teaser)
     

File templates/tag_cloud.html

 {% load tagging_tags %}
-{% tag_cloud_for_model sitepoet.Story as tag_cloud with min_count=10 steps=5 %}
+{% tag_cloud_for_model milton.Story as tag_cloud with min_count=10 steps=5 %}
 <div class="cloud" style="width: 300px">{%for tag in tag_cloud%}
     <span class="tag" style="font-size:{{tag.font_size}}ex; white-space: nowrap;"><a href="{% url tag tag.name %}">{{tag.name}}</a></span>{%endfor%}
 </div>
 import unittest
 from django.test import TestCase
 from django.conf import settings
-from sitepoet.models import *
+from milton.models import *
 
 class PageTests(TestCase):
     def setUp(self):
 from django.conf.urls.defaults import *
 from models import Story
 from django.conf import settings
+from django.views.decorators.csrf import csrf_exempt
+from milton.xmlrpc import view as xmlrpc_view
 
 urlpatterns = patterns('',
     # MetaWeblog access point
-    url(r'^api/', 'sitepoet.xmlrpc.view', kwargs={'module':'sitepoet.metaweblog'}),
+    url(r'^api/', csrf_exempt(xmlrpc_view), kwargs={'module':'milton.metaweblog'}),
 )
 
-urlpatterns += patterns('sitepoet.views',
+urlpatterns += patterns('milton.views',
     # Comments
     (r'^comments/', include('django.contrib.comments.urls')),
     
     
     # Articles
     url(
-        regex  = r'^(?:(?P<section>[^/]+?)/)?(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>.+)/$',
+        regex  = r'^(?:(?P<section>[^0-9][^/]+)/)?(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>.+)/$',
         view   = 'story_detail',
         name   = "story-detail"
     ),
     url(
-        regex  = r'^(?:(?P<section>[^/]+)/)?(?:(?P<year>\d{4})/)?(?:(?P<month>\d{1,2})/)?(?:(?P<day>\d{1,2})/)?$',
+        regex  = r'^(?:(?P<section>[^0-9][^/]+)/)?(?:(?P<year>\d{4})/)?(?:(?P<month>\d{1,2})/)?(?:(?P<day>\d{1,2})/)?$',
         view   = 'story_archive',
         kwargs = { "teasers": True },
         name   = "story-archive"
     )
 )
 
-urlpatterns += patterns('sitepoet.views',
+urlpatterns += patterns('milton.views',
     (r'^(?P<url>.*)$', 'view_page'),
 )
 from django.conf import settings
 from django.contrib.sites.models import *
 
-from sitepoet.models import *
+from milton.models import *
 
 from tagging.models import Tag, TaggedItem
 from tagging.utils import get_tag_list
     try:
         if section == None:
             story = Story.published.get(
+            	section = None,
                 date_published__year = int(year),
                 date_published__month = int(month),
                 date_published__day = int(day),
 
 def story_archive(request, section=None, year=None, month=None, day=None, teasers=False):
     # If there's a section, try and load it then filter the stories by it
+    try:
+        if section and len(section):
+            section = Section.objects.get(slug=section)
+        else:
+            section = None
+    except Section.DoesNotExist:
+        section = None
+    
     if section:
-        obj = get_object_or_404(Section, slug=section)
-        stories = Story.published.filter(section=obj)
+        stories = Story.published.filter(section=section)
     else:
         stories = Story.published.all()
     
     template_name = "story_archive.html"
     templates = []
     if section:
-        templates.append("section/" + section + "/" + template_name)
+        templates.append("section/" + section.slug + "/" + template_name)
     templates.append(template_name)
     
     return render_to_response(templates, context, context_instance=RequestContext(request))