Source

copelco / lib / copelco / apps / flickr / models.py

import datetime

from django.db import models


class User(models.Model):
	username = models.CharField(max_length=255)
	nsid = models.CharField(max_length=255)

	def __unicode__(self):
		return self.nsid


class Photo(models.Model):

	user = models.ForeignKey(User)
	id = models.BigIntegerField('ID', primary_key=True)
	title = models.CharField(max_length=255, blank=True, default='')
	date_uploaded = models.DateTimeField()
	date_taken = models.DateTimeField()
	date_synced = models.DateTimeField()

	def __unicode__(self):
		return unicode(self.id)


class PhotoSize(models.Model):

	SIZE_CHOICES = (
		('', 'Unknown'),
		('square', 'Square'),
		('thumbnail', 'Thumbnail'),
		('small', 'Small'),
		('medium', 'Medium'),
		('original', 'Original'),
	)

	photo = models.ForeignKey(Photo, related_name='sizes')
	type = models.CharField(max_length=16, choices=SIZE_CHOICES, blank=True,
	                        db_index=True)
	width = models.PositiveSmallIntegerField()
	height = models.PositiveSmallIntegerField()
	source = models.URLField(verify_exists=False)

	def __unicode__(self):
		return self.source