1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
'''
Created on Feb 23, 2011
@author: leifj
'''
from django.db import models
import re
from pprint import pformat
import logging
from django.db.models.fields import CharField, SmallIntegerField
class Entity(models.Model):
SP = 0
IDP = 1
OTHER = 2
entityId = CharField(max_length=1024,unique=True,editable=False)
display_name = CharField(max_length=1024,blank=True,null=True)
type = SmallIntegerField(blank=True,null=True,editable=False,choices=((IDP,"Identity Provider"),(SP,"Service Provider"),(OTHER,"Other Entity")))
timecreated = models.DateTimeField(auto_now_add=True)
lastupdated = models.DateTimeField(auto_now=True)
def __unicode__(self):
return "%s (%s)" % (self.name(),self.type)
def name(self):
if self.display_name:
return self.display_name
else:
return self.entityId
|