# Path: apps/account/models.py
# class Account(Model):
# 
#     # main data
#     user = ForeignKey('auth.User', unique=True, related_name="accounts")
#     description = TextField(blank=True)
#     source = CharField(max_length=64, choices=SOURCE_CHOICES, default='OTHER')
#     mobile = CharField(max_length=1024, blank=True)
#     links = ManyToManyField('link.Link', null=True, blank=True) 
#     passport = ProcessedImageField(upload_to=_upload_to, null=True, blank=True, 
#                                    processors=[ResizeToFit(1024, 768)],
#                                    format='JPEG', options={'quality': 90})
# 
#     # meta
#     # created_by = self
#     # updated_by = self
#     created_on = DateTimeField(auto_now_add=True)
#     updated_on = DateTimeField(auto_now=True)
# 
#     def get_name():
#         return self.user.username
# 
#     def __unicode__(self):
#         return self.user.username
# 
#     class Meta:
# 
#         ordering = ['user__username']


import hashlib
import os.path
from django.db import models
from imagekit.models.fields import ProcessedImageField
from imagekit.processors import ResizeToFill
from apps.account.models import Account

    def __unicode__(self):
        return u"%s" % self.id


def _get_upload_path(prefix, data):
    hasher = hashlib.sha1()
    for chunk in data.chunks():
        hasher.update(chunk)
    digest = hasher.hexdigest()
    return "gallery/%s/%s.%s" % (prefix, digest, 'jpeg')


def _image_upload_to(instance, filename, **kwargs):
    return _get_upload_path("images", instance.image)


def _thumbnail_upload_to(instance, filename, **kwargs):
    return _get_upload_path("thumbnails", instance.thumbnail)


def _preview_upload_to(instance, filename, **kwargs):
    return _get_upload_path("previews", instance.preview)


class Picture(models.Model):

    gallery = models.ForeignKey('gallery.Gallery', related_name="pictures")

    image = ProcessedImageField(

# Path: apps/account/models.py
# class Account(Model):
# 
#     # main data
#     user = ForeignKey('auth.User', unique=True, related_name="accounts")
#     description = TextField(blank=True)
#     source = CharField(max_length=64, choices=SOURCE_CHOICES, default='OTHER')
#     mobile = CharField(max_length=1024, blank=True)
#     links = ManyToManyField('link.Link', null=True, blank=True) 
#     passport = ProcessedImageField(upload_to=_upload_to, null=True, blank=True, 
#                                    processors=[ResizeToFit(1024, 768)],
#                                    format='JPEG', options={'quality': 90})
# 
#     # meta
#     # created_by = self
#     # updated_by = self
#     created_on = DateTimeField(auto_now_add=True)
#     updated_on = DateTimeField(auto_now=True)
# 
#     def get_name():
#         return self.user.username
# 
#     def __unicode__(self):
#         return self.user.username
# 
#     class Meta:
# 
#         ordering = ['user__username']


# Path: apps/gallery/models.py
import hashlib
import os.path
from django.db import models
from imagekit.models.fields import ProcessedImageField
from imagekit.processors import ResizeToFill
from apps.account.models import Account


    def __unicode__(self):
        return u"%s" % self.id


def _get_upload_path(prefix, data):
    hasher = hashlib.sha1()
    for chunk in data.chunks():
        hasher.update(chunk)
    digest = hasher.hexdigest()
    return "gallery/%s/%s.%s" % (prefix, digest, 'jpeg')


def _image_upload_to(instance, filename, **kwargs):
    return _get_upload_path("images", instance.image)


def _thumbnail_upload_to(instance, filename, **kwargs):
    return _get_upload_path("thumbnails", instance.thumbnail)


def _preview_upload_to(instance, filename, **kwargs):
    return _get_upload_path("previews", instance.preview)


class Picture(models.Model):

    gallery = models.ForeignKey('gallery.Gallery', related_name="pictures")

    image = ProcessedImageField(

        upload_to=_image_upload_to, 