Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: servee/django-servee-gallery
base: 808dad46e2
...
head fork: servee/django-servee-gallery
compare: 5f8940ebf1
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 21 additions and 30 deletions.
  1. +1 −16 servee_gallery/__init__.py
  2. +20 −14 servee_gallery/models.py
View
17 servee_gallery/__init__.py
@@ -1,16 +1 @@
-VERSION = (0, 1, 0, "a", 1) # following PEP 386
-DEV_N = 2
-
-
-def get_version():
- version = "%s.%s" % (VERSION[0], VERSION[1])
- if VERSION[2]:
- version = "%s.%s" % (version, VERSION[2])
- if VERSION[3] != "f":
- version = "%s%s%s" % (version, VERSION[3], VERSION[4])
- if DEV_N:
- version = "%s.dev%s" % (version, DEV_N)
- return version
-
-
-__version__ = get_version()
+__version__ = "0.2.1"
View
34 servee_gallery/models.py
@@ -5,27 +5,33 @@
class BaseGallery(models.Model):
"""
- BaseGallery
+ BaseGallery
"""
title = models.CharField(max_length=256, blank=True, null=True)
slug = models.SlugField(max_length=128, blank=True, null=True)
description = models.TextField(blank=True, null=True)
created = models.DateTimeField(blank=True)
modified = models.DateTimeField(blank=True)
-
+
def save(self, *args, **kwargs):
self.modified = datetime.datetime.now()
-
+
if not self.slug:
self.slug = slugify(self.title)
-
+
if not self.created:
self.created = datetime.datetime.now()
super(BaseGallery, self).save(*args, **kwargs) # Call the "real" save() method.
-
+
class Meta:
abstract = True
+ def __unicode__(self):
+ if self.title:
+ return self.title
+ else:
+ return u"Gallery #%s" % self.id
+
class Gallery(BaseGallery):
"""
Non-Abstract Gallery Model
@@ -46,25 +52,25 @@ class BaseGalleryItem(models.Model):
def __unicode__(self):
return "%s" % self.title
-
+
def save(self, *args, **kwargs):
self.modified = datetime.datetime.now()
-
+
# update gallery modified time
self.gallery.modified = datetime.datetime.now()
self.gallery.save()
-
+
if not self.uploaded:
self.uploaded = datetime.datetime.now()
super(BaseGalleryItem, self).save(*args, **kwargs) # Call the "real" save() method.
-
+
def get_absolute_url(self):
return self.item.url
class Meta:
abstract = True
ordering = ("gallery", "order")
-
+
class Image(BaseGalleryItem):
"""
"""
@@ -72,14 +78,14 @@ class Image(BaseGalleryItem):
upload_to=IMAGE_UPLOAD_TO,
storage=DEFAULT_STORAGE()
)
-
+
def save(self, *args, **kwargs):
# create a title if the galleritem has a name
if not self.title:
self.title = self.image.name
super(Image, self).save(*args, **kwargs) # Call the "real" save() method.
-
- class Meta:
+
+ class Meta:
verbose_name = "servee gallery image"
verbose_name_plural = "servee gallery images"
- ordering = ["modified",]
+ ordering = ["modified",]

No commit comments for this range

Something went wrong with that request. Please try again.