~panosl/+junk/django-attachments

« back to all changes in this revision

Viewing changes to attachments/models.py

  • Committer: Martin Mahner
  • Date: 2009-06-05 13:29:50 UTC
  • Revision ID: git-v1:0faaae306fabdefc092c47882810fe3a73dcaae0
Removed the dependence of django-extensins. This is backwards compatible.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
import os
3
3
from django.db import models
4
4
from django.contrib.auth.models import User
5
 
from django_extensions.db.models import TimeStampedModel
6
5
from django.contrib.contenttypes.models import ContentType
7
6
from django.contrib.contenttypes import generic
8
7
from django.utils.translation import ugettext_lazy as _
13
12
        return self.filter(content_type__pk=object_type.id,
14
13
                           object_id=obj.id)
15
14
 
16
 
class Attachment(TimeStampedModel):
 
15
class Attachment(models.Model):
17
16
    def attachment_upload(instance, filename):
18
17
        """Stores the attachment in a "per module/appname/primary key" folder"""
19
18
        return 'attachments/%s/%s/%s' % (
29
28
    content_object = generic.GenericForeignKey('content_type', 'object_id')
30
29
    creator = models.ForeignKey(User, related_name="created_attachments", verbose_name=_('creator'))
31
30
    attachment_file = models.FileField(_('attachment'), upload_to=attachment_upload)
32
 
 
 
31
    created = models.DateTimeField(_('created'), auto_now_add=True)
 
32
    modified = models.DateTimeField(_('modified'), auto_now=True)
 
33
    
33
34
    class Meta:
34
35
        ordering = ['-created']
35
36
        permissions = (