forked from openhatch/oh-mainline
/
models.py
75 lines (61 loc) · 2.58 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding: utf-8 -*-
from __future__ import absolute_import
# vim: set ai et ts=4 sw=4:
# This file is part of OpenHatch.
# Copyright (C) 2014 Elana Hashman
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Imports {{{
import mysite.bugsets.views
import mysite.search.models
from django.db import models
from django.template.defaultfilters import slugify
from django.core.urlresolvers import reverse
# }}}
class AnnotatedBug(models.Model):
url = models.URLField(max_length=200, unique=True)
title = models.CharField(max_length=500, blank=True)
description = models.TextField(blank=True, verbose_name='Task Description')
assigned_to = models.CharField(max_length=200, blank=True)
mentor = models.CharField(max_length=200, blank=True,
verbose_name='Assigned Mentor')
time_estimate = models.CharField(max_length=200, blank=True,
verbose_name='Estimated Time Commitment')
STATUS_CHOICES = (
('u', 'unclaimed'),
('c', 'claimed'),
('n', 'needs-review'),
('r', 'resolved'),
)
status = models.CharField(max_length=1, default='u',
choices=STATUS_CHOICES)
# Kludgey replacement field for skills
skill_list = models.CharField(max_length=500, blank=True)
project = models.ForeignKey(mysite.search.models.Project,
null=True,
blank=True)
class BugSet(models.Model):
name = models.CharField(max_length=200, verbose_name='Event Name')
# Many-to-many relationship with annotated bugs
bugs = models.ManyToManyField(AnnotatedBug)
def get_absolute_url(self):
return reverse(mysite.bugsets.views.list_index, kwargs={
'pk': self.pk,
'slug': slugify(self.name),
})
def get_edit_url(self):
return reverse(mysite.bugsets.views.create_index, kwargs={
'pk': self.pk,
'slug': slugify(self.name),
})