-
Notifications
You must be signed in to change notification settings - Fork 77
/
models.py
56 lines (42 loc) · 1.72 KB
/
models.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2012 VPAC, http://www.vpac.org
# Copyright 2013-2021 Marcus Furlong <furlongm@gmail.com>
#
# This file is part of Patchman.
#
# Patchman is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 only.
#
# Patchman is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Patchman. If not, see <http://www.gnu.org/licenses/>
from django.db import models
from django.urls import reverse
from repos.models import Repository
class OSGroup(models.Model):
name = models.CharField(max_length=255, unique=True)
repos = models.ManyToManyField(Repository, blank=True)
class Meta:
verbose_name = 'Operating System Group'
verbose_name_plural = 'Operating System Groups'
ordering = ('name',)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('operatingsystems:osgroup_detail', args=[str(self.id)])
class OS(models.Model):
name = models.CharField(max_length=255, unique=True)
osgroup = models.ForeignKey(OSGroup, blank=True, null=True,
on_delete=models.SET_NULL)
class Meta:
verbose_name = 'Operating System'
verbose_name_plural = 'Operating Systems'
ordering = ('name',)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('operatingsystems:os_detail', args=[str(self.id)])