Skip to content

Instantly share code, notes, and snippets.

@ingenieroariel
Created June 29, 2010 18:47
Show Gist options
  • Save ingenieroariel/457610 to your computer and use it in GitHub Desktop.
Save ingenieroariel/457610 to your computer and use it in GitHub Desktop.
class Layer(models.Model):
...
contacts = models.ManyToManyField('Contact') #using the role field to tell the different type of contacts apart
ROLE_VALUES = [
'datasetProvider',
'custodian',
'owner',
'user',
'distributor',
'originator',
'pointOfContact',
'principalInvestigator',
'processor',
'publisher',
'author'
]
class Contact(models.Model):
name = models.CharField('Individual Name', max_length=255)
organization = models.CharField('Organization Name', max_length=255)
position = models.CharField('Position Name', max_length=255, blank=True, null=True)
voice = models.CharField('Voice', max_length=255, blank=True, null=True)
fax = models.CharField('Facsimile', max_length=255, blank=True, null=True)
delivery = models.CharField('Delivery Point', max_length=255, blank=True, null=True)
city = models.CharField(max_length=255, blank=True, null=True)
area = models.CharField('Administrative Area', max_length=255, blank=True, null=True)
zipcode = models.CharField('Postal Code', max_length=255, blank=True, null=True)
country = models.CharField(choices=COUNTRIES, max_length=3, blank=True, null=True)
role = models.CharField(choices= [(x, x) for x in ROLE_VALUES], max_length=255, blank=True, null=True)
email = models.EmailField()
#user = models.ForeignField(User) #In case we want to use this model as a profile.
def __unicode__(self):
return self.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment