~django-foundations-dev/ubuntu-django-foundations/extauth

« back to all changes in this revision

Viewing changes to models.py

  • Committer: Michael Hall
  • Date: 2010-12-21 04:08:41 UTC
  • Revision ID: mhall119@gmail.com-20101221040841-ae1uxq738j35xd18
Initial code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''
 
2
Copyright 2009 H. Lee Moffitt Cancer Center and Research Institute, Inc. 
 
3
All rights reserved.
 
4
 
 
5
@author: Michael Hall <mhall119@gmail.com>
 
6
'''
 
7
from django.contrib import auth
 
8
from django.db import models
 
9
from django.contrib.contenttypes.models import ContentType
 
10
 
 
11
class Role(models.Model):
 
12
    
 
13
    class Meta:
 
14
        verbose_name = "Role"
 
15
        unique_together = (('model', 'role'),)
 
16
        
 
17
    model = models.ForeignKey(ContentType, verbose_name='Model Type')
 
18
    role = models.CharField(max_length=255, verbose_name='Role Name')
 
19
    permissions = models.ManyToManyField(auth.models.Permission, blank=True, verbose_name='Role Permissions')
 
20
    
 
21
    def __unicode__(self):
 
22
        return "%s.%s: %s" % (self.model.app_label, self.model, self.role)
 
23