1 from django.conf import settings
2 from django.contrib.auth.models import User
3 from django.db import models
6 class Service(models.Model):
7 name = models.CharField(max_length=255)
8 url = models.URLField(blank=True)
9 key = models.CharField(max_length=255, blank=True)
10 uses_ssh = models.BooleanField(default=False)
11 groups = models.ManyToManyField('auth.Group', blank=True)
12 users = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True)
21 return User.objects.filter(
22 models.Q(service=self) |
23 models.Q(groups__service=self)
27 def for_user(cls, user):
28 return cls.objects.filter(models.Q(users=user) | models.Q(groups__user=user))
31 class Hook(models.Model):
32 service = models.ForeignKey(Service, on_delete=models.CASCADE)
33 email = models.CharField(max_length=255)