# 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
    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, 
        processors=[ResizeToFill(640, 480)],
        format='JPEG', options={'quality': 90}
    )

    preview = ProcessedImageField(
        upload_to=_preview_upload_to, 
        processors=[ResizeToFill(320, 240)],
        format='JPEG', options={'quality': 90}
    )

    thumbnail = ProcessedImageField(
        upload_to=_thumbnail_upload_to, 
        processors=[ResizeToFill(100, 75)],
        format='JPEG', options={'quality': 90}
    )

    # metadata

# 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

    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, 
        processors=[ResizeToFill(640, 480)],
        format='JPEG', options={'quality': 90}
    )

    preview = ProcessedImageField(
        upload_to=_preview_upload_to, 
        processors=[ResizeToFill(320, 240)],
        format='JPEG', options={'quality': 90}
    )

    thumbnail = ProcessedImageField(
        upload_to=_thumbnail_upload_to, 
        processors=[ResizeToFill(100, 75)],
        format='JPEG', options={'quality': 90}
    )

    # metadata

    created_by  = models.ForeignKey(Account, related_name="pictures_created")