~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to images/models.py

  • Committer: Holger Rapp
  • Date: 2009-03-01 20:47:48 UTC
  • Revision ID: sirver@kallisto.local-20090301204748-h3ouqkp8zhv10ydq
First (working) commit of wlimages app, the app that will handle image uploading and managing. Uploading works now; images can only be uploaded once (with the same filename). Much stil missing. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from django.db import models
2
 
from django.contrib.contenttypes.models import ContentType
3
 
from django.contrib.contenttypes import generic
4
 
from django.contrib.auth.models import User
5
 
from django.utils.translation import ugettext_lazy as _
6
 
from datetime import datetime
7
 
 
8
 
class Image(models.Model):
9
 
    """
10
 
    TODO
11
 
    """
12
 
    # Generic Foreign Key Fields
13
 
    content_type = models.ForeignKey(ContentType)
14
 
    object_id = models.PositiveIntegerField(_('object ID'))
15
 
    content_object = generic.GenericForeignKey()
16
 
    
17
 
    name = models.CharField(max_length="100")
18
 
    revision = models.PositiveIntegerField()
19
 
 
20
 
    # User Field
21
 
    user = models.ForeignKey(User)
22
 
    ip_address = models.IPAddressField(_('IP address'), null=True, blank=True)
23
 
    
24
 
    # Date Fields
25
 
    date_submitted = models.DateTimeField(_('date/time submitted'), default = datetime.now)
26
 
    image = models.ImageField(upload_to="images/")
27
 
 
28
 
    # objects = ThreadedCommentManager()
29
 
    # public = PublicThreadedCommentManager()
30
 
   
31
 
    def __unicode__(self):
32
 
        return "Bildchen"
33
 
 
34
 
    def get_content_object(self):
35
 
        """
36
 
        taken from threadedcomments:
37
 
 
38
 
        Wrapper around the GenericForeignKey due to compatibility reasons
39
 
        and due to ``list_display`` limitations.
40
 
        """
41
 
        return self.content_object
42
 
    
43
 
    class Meta:
44
 
        ordering = ('-date_submitted',)
45
 
        verbose_name = _("Image")
46
 
        verbose_name_plural = _("Images")
47
 
        get_latest_by = "date_submitted"
48
 
 
49