Skip to content

Commit

Permalink
Fixes GeoNode#10290 complete_ISO_contact_roles_per_ressource_base_wit…
Browse files Browse the repository at this point in the history
…h_multiplicity
  • Loading branch information
mwallschlaeger committed Jan 13, 2023
1 parent 5d10ab4 commit 8768cb5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ def _get_contact_role_elements(self, role: str) -> List[Optional[ContactRole]]:
"""
generell getter of for all contact roles except owner
param role (str): string coresponding to ROLE_VALUES in geonode/people/enumarations, defining which propery is requested
param role (str): string coresponding to ROLE_VALUES in geonode/people/enumarations, defining which propery is requested
return List(ContactRole): returns the requested contact role from the database
"""
try:
Expand Down Expand Up @@ -1962,13 +1962,13 @@ def _set_principal_investigator(self, user_profile): return self._set_contact_ro
def principal_investigator_csv(self): return ','.join(p.get_full_name() or p.username for p in self.principal_investigator)

def get_defined_multivalue_contact_roles(self) -> List[Tuple[List[settings.AUTH_USER_MODEL], str]]:
""" _summary_: Returns all set contact roles of the ressource with additional ROLE_VALUES from geonode.people.enumarations.ROLE_VALUES. Mainly used to generate output xml more easy.
""" _summary_: Returns all set contact roles of the ressource with additional ROLE_VALUES from geonode.people.enumarations.ROLE_VALUES. Mainly used to generate output xml more easy.
Returns:
_type_: List[Tuple[List[people object], roles_label_name]]
_description: list tuples including two elements: 1. list of people have a certain role. 2. role label
"""
return [ (self.__getattribute__(role.name),role.label) for role in Roles.get_multivalue_ones() if self.__getattribute__(role.name) ]
Returns:
_type_: List[Tuple[List[people object], roles_label_name]]
_description: list tuples including two elements: 1. list of people have a certain role. 2. role label
"""
return [(self.__getattribute__(role.name), role.label) for role in Roles.get_multivalue_ones() if self.__getattribute__(role.name)]


class LinkManager(models.Manager):
Expand Down
11 changes: 6 additions & 5 deletions geonode/catalogue/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from django.core.exceptions import ObjectDoesNotExist
from geonode.people import Roles


@csrf_exempt
def csw_global_dispatch(request, dataset_filter=None, config_updater=None):
"""pycsw wrapper"""
Expand Down Expand Up @@ -298,7 +299,7 @@ def __append_contact_role__(content, cr_attr_name, title_in_txt):
content += f"name{s}{fst(user.last_name)}{sc}"
content += f"e-mail{s}{fst(user.email)}{sc}"
return content

for role in set(Roles).difference([Roles.OWNER]):
content = __append_contact_role__(content, role.name, role.label)

Expand Down Expand Up @@ -333,12 +334,12 @@ def csw_render_extra_format_html(request, layeruuid, resname):
extra_res_md["roles"] = []
for role in Roles:
cr = resource.__getattribute__(role.name)
if not type(cr)==list:
if not type(cr) == list:
cr = [cr]
users=[{"pk":user.id, 'last_name': user.last_name, 'email': user.email} for user in cr]
users = [{"pk": user.id, 'last_name': user.last_name, 'email': user.email} for user in cr]
if users:
extra_res_md["roles"].append({"label":role.label, "users":users})
extra_res_md["roles"].append({"label": role.label, "users": users})

return render(request, "geonode_metadata_full.html", context={"resource": resource, "extra_res_md": extra_res_md})


Expand Down
2 changes: 0 additions & 2 deletions geonode/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import warnings
import traceback


from django.urls import reverse
from django.conf import settings
from django.contrib import messages
from django.shortcuts import render, get_object_or_404
from django.forms.utils import ErrorList
from django.utils.translation import ugettext as _
from django.contrib.auth.decorators import login_required
from django.template import loader
Expand Down
2 changes: 1 addition & 1 deletion geonode/geoapps/templates/apps/app_metadata_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h2>{% trans "Point of Contact" %}</h2>
</fieldset>
<fieldset class="form-controls modal-forms modal hide fade" id="metadata_form">
<h2>{% trans "Metadata Provider" %}</h2>
{{ author_form|as_bootstrap }}
{{ metadata_author_form|as_bootstrap }}
<button type='button' class="modal-cloose-btn btn btn-primary">{% trans "Done" %}</button>
</fieldset>

Expand Down
1 change: 0 additions & 1 deletion geonode/geoapps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from django.conf import settings
from django.shortcuts import render
from django.forms.utils import ErrorList
from django.utils.translation import ugettext as _
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect, Http404
Expand Down
4 changes: 3 additions & 1 deletion geonode/people/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from geonode.notifications_helper import NotificationsAppConfigBase
import enum


class PeopleAppConfig(NotificationsAppConfigBase):
name = 'geonode.people'
NOTIFICATIONS = (("user_follow", _("User following you"), _("Another user has started following you"),),
Expand All @@ -35,6 +36,7 @@ def ready(self):

default_app_config = 'geonode.people.PeopleAppConfig'


class Role:
def __init__(self, label, is_required, is_multivalue):
self.label = label
Expand Down Expand Up @@ -63,7 +65,7 @@ class Roles(enum.Enum):
@property
def name(self):
return super().name.lower()

@property
def label(self):
return self.value.label
Expand Down

0 comments on commit 8768cb5

Please sign in to comment.