Commits

Anonymous committed 7fa2cb7

changed the models slightly

Comments (0)

Files changed (5)

             'django.contrib.contenttypes',
             'django.contrib.auth',
             'taggit',
+            'pagination',
+            'easy_thumbnails',
             'photos',
             'photos.tests'            
         ],
         ROOT_URLCONF='photos.tests.urls',
         MEDIA_URL='/static/',
-        MEDIA_ROOT=join(abspath(dirname(__file__)), 'src/photos/tests/static/')        
+        MEDIA_ROOT=join(abspath(dirname(__file__)), 'src/photos/tests/static/'),
+        TEMPLATE_CONTEXT_PROCESSORS=(
+                                     'django.core.context_processors.auth',
+                                     'django.core.context_processors.debug',
+                                     'django.core.context_processors.i18n',
+                                     'django.core.context_processors.media',
+                                     'django.core.context_processors.request'
+                                     )       
     )
 
 from django.test.simple import run_tests
     'django-templatetag-sugar',
     'easy_thumbnails',
     'django-pagination',    
-    'PIL'
+    'pil'
 ]
 
 

src/photos/models.py

 from django.contrib.auth.models import User
 
 class Photo(models.Model):
-    photo = models.ImageField(_('Photo'), upload_to='%y/%j/%H/%M/%S', height_field='height', width_field='width')
+    photo = models.ImageField(_('Photo'), upload_to='%y/%j/%H/%M/%S', height_field='height', width_field='width', max_length=250)
     height = models.PositiveIntegerField(_('Height'))
     width = models.PositiveIntegerField(_('Width'))
     display = models.BooleanField(_('Display'), default=True, help_text=_('Disable to not display this photo.'))
-    description = models.CharField(_('Description'), max_length=500)
+    name = models.CharField(_('Name'), max_length=250)
+    description = models.TextField(_('Description'), blank=True, null=True)
     user = models.ForeignKey(User, editable=False, blank=True, null=True)
     tags = TaggableManager()
     timestamp_created = models.DateTimeField(_('Timestamp created'), auto_now_add=True, editable=False)
     timestamp_edited = models.DateTimeField(_('Timestamp edited'), auto_now=True, editable=False)
     
     def __unicode__(self):
-        return self.photo.name
+        return self.name
     
     class Meta(object):
         verbose_name = _('Photo')
         
 class Album(models.Model):
     display = models.BooleanField(_('Display'), default=True, help_text=_('Disable to not display this gallery.'))
+    name = models.CharField(_('Name'), max_length=250)   
     description = models.TextField(_('Description'), blank=True, null=True)
     photos = models.ManyToManyField(Photo, verbose_name=_('Photos'))
     tags = TaggableManager()
     timestamp_created = models.DateTimeField(_('Timestamp created'), auto_now_add=True, editable=False)
     timestamp_edited = models.DateTimeField(_('Timestamp edited'), auto_now=True, editable=False)
     
+    def __unicode__(self):
+        return self.name
+    
     class Meta(object):
         verbose_name = _('Album')
         verbose_name_plural = _('Albums')

src/photos/tests/tests.py

     def test_photo_detail(self):
         photo = Photo.objects.latest('id')
         url = reverse('photo-detail', args=(photo.id, ))
-        print Photo.objects.filter(display=True)
         self.check_url(url, 200)
     

src/photos/views.py

 
 def photo_list(request, user_id=0, username=None, *args, **kwargs):
     qs = Photo.objects.filter(display=True)
+    user = None
     
     if user_id > 0:
         user = get_object_or_404(User, id=user_id)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.