src/ldt/ldt/core/models.py
author ymh <ymh.work@gmail.com>
Fri, 06 May 2011 01:01:51 +0200
changeset 95 8e57d39f660d
parent 63 93325a5d61f0
child 125 5c3ed9c919bb
permissions -rw-r--r--
correct indexation problem
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63
93325a5d61f0 organize format and import
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
     1
from django.contrib.auth.models import User, Group
0
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
from django.db import models
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
class Owner(models.Model):
13
97ab7b3191cf add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     6
    user = models.ForeignKey(User, blank=True, null=True)
97ab7b3191cf add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     7
    group = models.ForeignKey(Group, blank=True, null=True)
0
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
    def __unicode__(self):
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
        if self.user:
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
            return self.user.username
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
        else:
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
            return self.group.name
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
class Document(models.Model):
13
97ab7b3191cf add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    17
    owner = models.ForeignKey(Owner, blank=True, null=True)
0
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    class Meta:
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
        abstract = True
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22