Skip to content

Commit

Permalink
merge: #781 from ginger/maintainer
Browse files Browse the repository at this point in the history
  • Loading branch information
alycejenni authored Jul 5, 2024
2 parents c1f3cf4 + 8fc5381 commit 196721b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
20 changes: 14 additions & 6 deletions ckanext/nhm/lib/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,29 @@ def get_package_owners(package: dict) -> List[Recipient]:
:param package: the package dict
"""
maintainer_name = package.get('maintainer', 'Maintainer')
maintainer_email = package.get('maintainer_email')

collaborators = toolkit.get_action('package_collaborator_list')(
# ignore auth to ensure we can access the list of collaborators
{'ignore_auth': True},
# only email admins
{'id': package['id'], 'capacity': 'admin'},
)

recipient_ids = []
if collaborators:
recipient_ids.extend(collaborator['user_id'] for collaborator in collaborators)
recipients = []
if maintainer_email:
recipients.append(Recipient(maintainer_name, maintainer_email))
elif collaborators:
recipients = [
Recipient.from_user_id(collaborator['user_id'])
for collaborator in collaborators
]
else:
# if there aren't any collaborators, use the creator
recipient_ids.append(package['creator_user_id'])
# if there's no maintainer and there aren't any collaborators, use the creator
recipients.append(Recipient.from_user_id(package['creator_user_id']))

return list(map(Recipient.from_user_id, recipient_ids))
return recipients


def create_package_email(mail_dict: dict, package: dict):
Expand Down
6 changes: 6 additions & 0 deletions ckanext/nhm/theme/assets/less/nhm.less
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ iframe {
margin: 5px 0;
}

.info-block,
.form-group .info-block {
color: @grey4;
font-size: @font-size-body-s;
Expand All @@ -1396,6 +1397,11 @@ iframe {
}
}

.form-group + .info-block {
margin-top: -25px; // the margin-bottom for .form-group is 30px
margin-bottom: 30px;
}

input[type='radio'],
input[type='checkbox'] {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
{% endblock %}

{% block package_metadata_fields_maintainer %}
{{ form.input('maintainer_email', label=_('Contact email'), id='field-maintainer-email', placeholder=_('e.g. shared-inbox@nhm.ac.uk'), value=data.maintainer_email, error=errors.maintainer_email, classes=['control-medium']) }}
{{ form.info('Enquiries about this dataset will be sent to this address. If not set, messages will go to the collaborators or creator of the dataset.', inline=False) }}

{{ form.input('maintainer', label=_('Contact name'), id='field-maintainer', placeholder=_('e.g Project Y'), value=data.maintainer, error=errors.maintainer, classes=['control-medium']) }}
{{ form.info('Name of the person or group receiving dataset enquiries (see above). Optional.', inline=False) }}
{% endblock %}

{% block custom_fields %}
Expand All @@ -21,8 +26,8 @@
{{ super() }}
{% endblock %}

{{ form.info("What time period does this dataset cover? If not applicable, leave blank.", inline=True) }}
{{ form.input('temporal_extent', label=_('Temporal extent'), id='field-temporal-extent', placeholder=_('1970 - 1985'), value=data.temporal_extent, error=errors.temporal_extent, classes=['control-medium']) }}
{{ form.info("What time period does this dataset cover? If not applicable, leave blank.", inline=True) }}

{{ form.select('update_frequency', label=_('Update frequency'), id='field-update-frequency', options=h.form_select_update_frequency_options(), selected=data.update_frequency, error=errors.update_frequency, classes=['control-medium']) }}
{# TODO: Add map to pick spatial extent - hidden for non sysadmin until then #}
Expand Down

0 comments on commit 196721b

Please sign in to comment.