From: Stephen Burrows Date: Fri, 3 Jun 2011 16:37:50 +0000 (-0400) Subject: Merge branch 'release' into develop X-Git-Tag: philo-0.9.1^2~8^2~7 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/093ad8d3312e2ba27730f8f5c915ca113ce72041?hp=fffac3a965cb9cf3dc7c97a0108d5304f22b486f Merge branch 'release' into develop --- diff --git a/philo/contrib/penfield/models.py b/philo/contrib/penfield/models.py index 2a145fb..bcd0ba4 100644 --- a/philo/contrib/penfield/models.py +++ b/philo/contrib/penfield/models.py @@ -471,7 +471,7 @@ class BlogView(FeedView): @property def urlpatterns(self): urlpatterns = self.feed_patterns(r'^', 'get_all_entries', 'index_page', 'index') +\ - self.feed_patterns(r'^%s/(?P[-\w]+[-+/\w]*)$' % self.tag_permalink_base, 'get_entries_by_tag', 'tag_page', 'entries_by_tag') + self.feed_patterns(r'^%s/(?P[-\w]+[-+/\w]*)' % self.tag_permalink_base, 'get_entries_by_tag', 'tag_page', 'entries_by_tag') if self.tag_archive_page: urlpatterns += patterns('', diff --git a/philo/models/base.py b/philo/models/base.py index 0218261..86569b7 100644 --- a/philo/models/base.py +++ b/philo/models/base.py @@ -1,7 +1,7 @@ from django import forms from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic -from django.core.exceptions import ObjectDoesNotExist +from django.core.exceptions import ValidationError from django.core.validators import RegexValidator from django.db import models from django.utils import simplejson as json @@ -16,7 +16,7 @@ from philo.utils.entities import AttributeMapper, TreeAttributeMapper from philo.validators import json_validator -__all__ = ('Tag', 'value_content_type_limiter', 'register_value_model', 'unregister_value_model', 'JSONValue', 'ForeignKeyValue', 'ManyToManyValue', 'Attribute', 'Entity', 'TreeEntity') +__all__ = ('Tag', 'value_content_type_limiter', 'register_value_model', 'unregister_value_model', 'JSONValue', 'ForeignKeyValue', 'ManyToManyValue', 'Attribute', 'Entity', 'TreeEntity', 'SlugTreeEntity') class Tag(models.Model): @@ -522,6 +522,15 @@ class SlugTreeEntity(TreeEntity): return super(SlugTreeEntity, self).get_path(root, pathsep, field) path = property(get_path) + def clean(self): + if self.parent is None: + try: + self._default_manager.exclude(pk=self.pk).get(slug=self.slug, parent__isnull=True) + except self.DoesNotExist: + pass + else: + raise ValidationError(self.unique_error_message(self.__class__, ('parent', 'slug'))) + class Meta: unique_together = ('parent', 'slug') abstract = True \ No newline at end of file diff --git a/philo/static/philo/js/TagCreation.js b/philo/static/philo/js/TagCreation.js index 610a4f0..a23e609 100644 --- a/philo/static/philo/js/TagCreation.js +++ b/philo/static/philo/js/TagCreation.js @@ -85,6 +85,9 @@ var tagCreation = window.tagCreation; addEvent(input, 'keypress', function(e) { if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) { e.preventDefault(); + if (select.options.length == 0) { + tagCreation.addTagFromSlug(addLink); + } } }) },