#########################################################################
#
# Copyright (C) 2016 OSGeo
#
# This program 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, 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################
from django.utils.translation import ugettext_noop as _
from geonode.notifications_helper import NotificationsAppConfigBase
import enum
[docs]
class PeopleAppConfig(NotificationsAppConfigBase):
[docs]
name = "geonode.people"
[docs]
NOTIFICATIONS = (
(
"user_follow",
_("User following you"),
_("Another user has started following you"),
),
(
"account_approve",
_("User requested access"),
_("A new user has requested access to the site"),
),
(
"account_active",
_("Account activated"),
_("This account is now active and can log in the site"),
),
)
[docs]
def ready(self):
super().ready()
[docs]
default_app_config = "geonode.people.PeopleAppConfig"
[docs]
class Role:
def __init__(self, label, is_required, is_multivalue, is_toggled_in_metadata_editor):
[docs]
self.is_required = is_required
[docs]
self.is_multivalue = is_multivalue
[docs]
def __repr__(self):
return self.label
[docs]
class Roles(enum.Enum):
"""
Roles with their `label`, `is_required`, `is_multivalue`, `is_toggled_in_metadata_editor`
"""
[docs]
OWNER = Role("Owner", True, False, False)
[docs]
PROCESSOR = Role("Processor", False, True, True)
[docs]
PUBLISHER = Role("Publisher", False, True, True)
[docs]
CUSTODIAN = Role("Custodian", False, True, True)
[docs]
POC = Role("Point of Contact", True, True, False)
[docs]
DISTRIBUTOR = Role("Distributor", False, True, True)
[docs]
RESOURCE_USER = Role("Resource User", False, True, True)
[docs]
RESOURCE_PROVIDER = Role("Resource Provider", False, True, True)
[docs]
ORIGINATOR = Role("Originator", False, True, True)
[docs]
PRINCIPAL_INVESTIGATOR = Role("Principal Investigator", False, True, True)
@property
[docs]
def name(self):
return super().name.lower()
@property
[docs]
def label(self):
return self.value.label
@property
[docs]
def is_required(self):
return self.value.is_required
@property
[docs]
def is_multivalue(self):
return self.value.is_multivalue
@property
[docs]
def __repr__(self):
return self.name
@classmethod
[docs]
def get_required_ones(cls):
return [role for role in cls if role.is_required]
@classmethod
[docs]
def get_multivalue_ones(cls):
return [role for role in cls if role.is_multivalue]
@classmethod
[docs]
def get_toggled_ones(cls):
return [role for role in cls if role.is_toggled_in_metadata_editor]