add mediagallery, this time to get it right

This commit is contained in:
Sanj 2012-10-06 05:31:29 +05:30
parent d0c7a8fbfa
commit 60ad39dba4
4 changed files with 59 additions and 0 deletions

View File

View File

@ -0,0 +1,42 @@
from django.db import models
from app.models import ItfModel
from ox.django.fields import DictField
class GalleryAlbum(ItfModel):
'''
'''
title = models.CharField(max_length=512, unique=True)
slug = models.SlugField(unique=True)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
def __unicode__(self):
return self.title
class GalleryItem(models.Model):
title = models.CharField(max_length=512, blank=True, null=True)
album = models.ForeignKey(GalleryAlbum)
data = models.DictField()
def __unicode__(self):
return self.title
class Photo(GalleryItem):
image = models.ImageField()
#class Video(GalleryItem):
# ...
#class YoutubeVideo(GalleryItem):
# ...
# Create your models here.

16
itf/mediagallery/tests.py Normal file
View File

@ -0,0 +1,16 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)

View File

@ -0,0 +1 @@
# Create your views here.