Skip to content

Commit

Permalink
Handle missing contact address in project_submission (#2178)
Browse files Browse the repository at this point in the history
Pull #2156 introduced the PROJECT_EDITOR_EMAIL setting.

If this setting is not defined (or blank) then we want to fall back to
the old behavior of showing the assigned editor's email address.

However, if the project has not yet been assigned to an editor, and
PROJECT_EDITOR_EMAIL is blank, it would crash.

(For example, clear the PROJECT_EDITOR_EMAIL setting, then log in as
rgmark and try to submit the "MIMIC-III Clinical Database" project.)
  • Loading branch information
tompollard authored Jan 18, 2024
2 parents 2d97768 + 28e995a commit ac23bf7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
23 changes: 23 additions & 0 deletions physionet-django/project/modelcomponents/unpublishedproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,29 @@ def has_wfdb(self):
"""
return self.files.has_wfdb_files(self)

@property
def editor_contact_email(self):
"""
Email address for contacting the project editor.
If a site-wide contact address is configured, that address
will be used for all projects. The string PROJECT-SLUG can be
included and will be replaced by the active project slug (for
example, PROJECT_EDITOR_EMAIL can be set to
'[email protected]', if the mail server
understands how to handle it.)
If there is no site-wide contact address, the primary email
address of the assigned editor is used.
"""
if not self.editor:
return None
elif settings.PROJECT_EDITOR_EMAIL:
return settings.PROJECT_EDITOR_EMAIL.replace('PROJECT-SLUG',
self.slug)
else:
return self.editor.email

def content_modified(self):
"""
Update the project's modification timestamp.
Expand Down
8 changes: 1 addition & 7 deletions physionet-django/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,12 +1418,6 @@ def project_submission(request, project_slug, **kwargs):
else:
edit_logs, copyedit_logs = None, None

if settings.PROJECT_EDITOR_EMAIL:
contact_email = settings.PROJECT_EDITOR_EMAIL.replace('PROJECT-SLUG',
project.slug)
else:
contact_email = project.editor.email

return render(
request,
"project/project_submission.html",
Expand All @@ -1435,7 +1429,7 @@ def project_submission(request, project_slug, **kwargs):
"edit_logs": edit_logs,
"copyedit_logs": copyedit_logs,
"awaiting_user_approval": awaiting_user_approval,
"contact_email": contact_email,
"contact_email": project.editor_contact_email,
},
)

Expand Down

0 comments on commit ac23bf7

Please sign in to comment.