45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
# welco - multichannel request processing
|
|
# Copyright (C) 2015 Entr'ouvert
|
|
#
|
|
# 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/>.
|
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
from django.contrib.contenttypes import generic
|
|
from django.db import models
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from welco.utils import get_wcs_data
|
|
|
|
|
|
class Inbox(models.Model):
|
|
INFO = 1
|
|
AVIS = 2
|
|
MANDATORY_AVIS = 3
|
|
|
|
role_slug = models.CharField(max_length=50)
|
|
subtype = models.PositiveSmallIntegerField(
|
|
choices=((INFO, 'info'),
|
|
(AVIS, 'avis'),
|
|
(MANDATORY_AVIS, 'mandatory-avis')),
|
|
default=INFO)
|
|
source_type = models.ForeignKey(ContentType, null=True)
|
|
source_pk = models.PositiveIntegerField(null=True)
|
|
source = generic.GenericForeignKey('source_type', 'source_pk')
|
|
done = models.BooleanField(default=False)
|
|
comments = models.TextField(blank=True, null=True, verbose_name=_('Comments'))
|
|
|
|
def role_name(self):
|
|
return [x for x in get_wcs_data('api/roles').get('data')
|
|
if x['slug'] == self.role_slug][0]['name']
|