48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
import datetime
|
|
|
|
from django.db import models
|
|
|
|
import reversion
|
|
|
|
from django.contrib.auth.models import Permission, User
|
|
|
|
|
|
TEAM_ACCESS_CHOICES = [
|
|
("open", "open"),
|
|
("application", "by application"),
|
|
("invitation", "by invitation")
|
|
]
|
|
|
|
|
|
class Team(models.Model):
|
|
|
|
slug = models.SlugField(unique=True)
|
|
name = models.CharField(max_length=100)
|
|
description = models.TextField(blank=True)
|
|
access = models.CharField(max_length=20, choices=TEAM_ACCESS_CHOICES)
|
|
permissions = models.ManyToManyField(Permission, blank=True)
|
|
created = models.DateTimeField(default=datetime.datetime.now, editable=False)
|
|
|
|
def __unicode__(self):
|
|
return self.name
|
|
|
|
|
|
MEMBERSHIP_STATE_CHOICES = [
|
|
("applied", "applied"),
|
|
("invited", "invited"),
|
|
("declined", "declined"),
|
|
("rejected", "rejected"),
|
|
("member", "member"),
|
|
("manager", "manager"),
|
|
]
|
|
|
|
|
|
class Membership(models.Model):
|
|
|
|
user = models.ForeignKey(User, related_name="memberships")
|
|
team = models.ForeignKey(Team, related_name="memberships")
|
|
state = models.CharField(max_length=20, choices=MEMBERSHIP_STATE_CHOICES)
|
|
message = models.TextField(blank=True)
|
|
|
|
|
|
reversion.register(Membership)
|