Dear Gitlab users, due to maintenance reasons, Gitlab will not be available on Thursday 30.09.2021 from 5:00 pm to approximately 5:30 pm.

Commit 5b6ddd66 authored by felix.herrmann's avatar felix.herrmann
Browse files

Merge branch '181-e-mail-notification-dashboard' into 'master'

Resolve "E-Mail notification & dashboard"

Closes #181

See merge request !394
parents 55be2b8b 8d3ffde3
......@@ -510,6 +510,7 @@ class DataSetPublicationRequest(models.Model):
)
def save(self, *args, **kwargs):
logger.error("[DataSetPublicationRequest] start save")
# send notification on save
ct = ContentType.objects.get_for_model(self.dataset)
text = _("Publication request for category {}".format(self.category))
......@@ -520,7 +521,9 @@ class DataSetPublicationRequest(models.Model):
text=text,
notification_type=Notification.PUB_REQUEST,
)
logger.error("[DataSetPublicationRequest] notification save")
notification.save()
logger.error("[DataSetPublicationRequest] notification saved")
self.notification = notification
# send email to all curators
......@@ -1333,6 +1336,7 @@ class DataSet(models.Model):
return settings.DD_LICENSE_MATRIX[self.data_access]
def request_publication(self, user):
logger.error("in request publication")
pub_request = DataSetPublicationRequest.objects.filter(dataset=self, user=user)
# TODO: add a check for compatibility between access model and chosen license
if not self.published:
......@@ -1345,13 +1349,17 @@ class DataSet(models.Model):
self.privacy_rights_declaration_text = (
self.PRIVACY_RIGHTS_DECLARATION_STRING
)
logger.error("save ds")
self.save()
logger.error("saved ds")
# trigger publication request
pubreq = DataSetPublicationRequest()
pubreq.dataset = self
pubreq.user = user
pubreq.category = self.get_main_category()
logger.error("save pubreq")
pubreq.save()
logger.error("saved pubreq")
return _("Dataset publication requested")
else:
......
......@@ -1640,6 +1640,7 @@ def edit_publish_request(request, ds_uuid):
ds = get_object_or_404(DataSet, uuid=ds_uuid)
manpage = get_man_page("dataset-publish-request")
if not check_perms("admin_dsmo", request.user, ds.dataset_management_object):
logger.error("access denied")
return HttpResponse(_("Access denied"))
# check_perms_403("admin_dataset", request.user, ds.dataset_management_object)
if ds.is_frozen():
......@@ -1647,13 +1648,18 @@ def edit_publish_request(request, ds_uuid):
if request.method == "POST":
# run checks
logger.error("POST publish request")
check_error, check_list = ds.perform_checks()
logger.error(check_error)
if check_error:
error_string = _("Errors ocurred, please fix: ") + " ".join(check_list)
publish_message = error_string
logger.error(error_string)
messages.error(request, error_string)
else:
logger.error("start request_publication")
publish_message = ds.request_publication(request.user)
logger.error("end request_publication")
return edit_versions(request, ds_uuid)
else:
publish_message = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment