Commits

Anonymous committed 792e0d0

Merged branch "tag_support" into trunk.

  • Participants
  • Parent commits 5db17e9

Comments (0)

Files changed (2)

 
 from django.db import models
 from django.db.models import signals
+from django.db.models.loading import AppCache
 from django.conf import settings
 from django.utils.functional import curry
 from django.core.validators import ValidationError
 from django.template.defaultfilters import slugify
 
 
-PHOTOLOGUE_DIR = 'photologue'
+# Get relative media path
+try:
+    PHOTOLOGUE_DIR = settings.PHOTOLOGUE_DIR
+except:
+    PHOTOLOGUE_DIR = 'photologue'
 
 
 class Gallery(models.Model):
         return (self.width, self.height)
 
 
-# Just a little instrospection...
-# The following MUST come after the model definition.
+"""
+Just a little instrospection...
+
+"""
+
+# Add the TagFields to models if django-tagging is found.
+if "tagging" in AppCache().app_models:
+    try:
+        from tagging.fields import TagField
+    except ImportError:
+        pass
+    else:
+        tag_field = TagField(help_text="Tags may not contain spaces. Seperate \
+                                        multiple tags with a space or comma.")
+        Gallery.add_to_class('tags', tag_field)
+        Photo.add_to_class('tags', tag_field)
+
+
+# Set up the accessor methods
 def add_methods(sender, instance, signal, *args, **kwargs):
     """ Adds methods to access sized images (urls, paths)
 
 from django.conf.urls.defaults import *
-from django_apps.photologue.models import *
+from django_apps.photologue.models import Gallery, Photo
 
 
 # galleries