Skip to content

Commit

Permalink
Merge 7bb4ecd into 3040d67
Browse files Browse the repository at this point in the history
  • Loading branch information
zeynepaki authored May 25, 2022
2 parents 3040d67 + 7bb4ecd commit 9716756
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ $(document).ready(function() {
html_block += '<div class="trigger-actions">';
if (additional_class == 'reserve') {
html_block += '<button data-toggle="tooltip" data-placement="top" title="Remove user from submission" class="btn btn-xs btn-danger mail-trigger" data-action="remove" data-person-type="' + action_type + '" data-recid="' + data["recid"] + '" data-userid="' + array[val_idx]['id'] + '"><span class="fa fa-trash-o"></span> </button>';
} else {
html_block += '<button data-toggle="tooltip" data-placement="top" title="Send a reminder to this user" class="btn btn-xs btn-primary mail-trigger" data-action="email" data-person-type="' + action_type + '" data-recid="' + data["recid"] + '" data-userid="' + array[val_idx]['id'] + '"><span class="fa fa-envelope-o"></span> </button>';
}
html_block += '<button data-toggle="tooltip" data-placement="top" title="' + alt_text + '" class="btn btn-xs btn-' + arrow_box_class + ' ' + downgrade_show + ' mail-trigger" data-action="' + action + '" data-person-type="' + action_type + '" data-recid="' + data["recid"] + '" data-userid="' + array[val_idx]['id'] + '"><span class="fa ' + arrow_box_icon + '"></span> </button>' +
'</div>';
Expand Down
38 changes: 38 additions & 0 deletions hepdata/modules/email/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def send_notification_email(recid, version, user, reviewers_notified, message=No
reviewers_notified=reviewers_notified,
title=record['title'],
site_url=site_url,
reminder=False,
link=site_url + "/record/{0}"
.format(recid))

Expand Down Expand Up @@ -310,6 +311,43 @@ def send_cookie_email(submission_participant,
message_body,
reply_to_address=coordinator.email)

def send_reminder_email(submission_participant, record_information, version, show_detail=False):

site_url = current_app.config.get('SITE_URL', 'https://www.hepdata.net')
tables = []
hepsubmission = get_latest_hepsubmission(
publication_recid=record_information['recid']
)
coordinator = User.query.get(hepsubmission.coordinator)

reviewers_notified = submission_participant.user_account is not None

message_body = render_template('hepdata_theme/email/submission_status.html',
name=submission_participant.full_name,
actor=coordinator.email,
article=record_information['recid'],
message=None,
invite_token=submission_participant.invitation_cookie,
role=submission_participant.role,
show_detail=show_detail,
data_tables=tables,
reviewers_notified=reviewers_notified,
title=record_information['title'],
site_url=site_url,
reminder=True,
link=site_url + "/record/{0}"
.format(record_information['recid']))

if not reviewers_notified:
message_subject = '[HEPData] Reminder to review submission {0}'.format(record_information['recid'])
else:
message_subject = '[HEPData] Reminder about submission {0}'.format(record_information['recid'])

create_send_email_task(submission_participant.email,
message_subject,
message_body,
reply_to_address=coordinator.email)


def send_reserve_email(submission_participant, record_information):

Expand Down
37 changes: 21 additions & 16 deletions hepdata/modules/permissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from hepdata.ext.elasticsearch.admin_view.api import AdminIndexer
from hepdata.modules.dashboard.api import get_dashboard_current_user
from hepdata.modules.email.api import send_coordinator_request_mail, send_coordinator_approved_email, \
send_cookie_email, send_reserve_email
send_cookie_email, send_reserve_email, send_reminder_email
from hepdata.modules.permissions.api import get_records_participated_in_by_user, get_approved_coordinators, \
get_pending_request
from hepdata.modules.permissions.models import SubmissionParticipant, CoordinatorRequest
Expand Down Expand Up @@ -72,29 +72,34 @@ def manage_participant_status(recid, action, status_action,
participant = SubmissionParticipant.query.filter_by(
id=participant_id).one()

if status_action == 'remove':
db.session.delete(participant)
else:
status = 'reserve'
if status_action == 'promote':
status = 'primary'
if status_action != 'email':
if status_action == 'remove':
db.session.delete(participant)
else:
status = 'reserve'
if status_action == 'promote':
status = 'primary'

participant.status = status
db.session.add(participant)
participant.status = status
db.session.add(participant)

db.session.commit()
db.session.commit()

record = get_record_by_id(recid)

# now send the email telling the user of their new status!
hepsubmission = get_latest_hepsubmission(publication_recid=recid)
if status_action == 'promote':
send_cookie_email(participant, record, version=hepsubmission.version)
elif status_action == 'demote':
send_reserve_email(participant, record)
if status_action != 'email':
if status_action == 'promote':
send_cookie_email(participant, record, version=hepsubmission.version)
elif status_action == 'demote':
send_reserve_email(participant, record)
admin_idx = AdminIndexer()
admin_idx.index_submission(hepsubmission)
else:
send_reminder_email(participant, record, version=hepsubmission.version)


admin_idx = AdminIndexer()
admin_idx.index_submission(hepsubmission)

return json.dumps({"success": True, "recid": recid})
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{% extends 'hepdata_theme/email/email_container.html' %}
{% block email_type %}
{% if reminder %}
Reminder:
{% endif %}
{% if invite_token %}
Invitation to be {{ role }} for a HEPData Record {{ article }}
{% elif reviewers_notified %}
Expand Down
11 changes: 11 additions & 0 deletions tests/e2e/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ def test_dashboard(live_server, logged_in_browser):
EC.visibility_of_element_located((By.ID, 'manageWidget'))
)
assert manage_widget.find_element_by_class_name('modal-title').text == 'Manage Submission'

# Check reminder email button works
reminder_button = manage_widget.find_element_by_css_selector('.trigger-actions .btn-primary')
assert reminder_button.get_attribute('data-action') == 'email'
reminder_button.click()
confirmation_message = manage_widget.find_element_by_id('confirmation_message').text
assert confirmation_message == 'Are you sure you want to email this uploader?'
confirmation_button = manage_widget.find_element_by_css_selector('.confirm-move-action')
confirmation_button.click()
assert not manage_widget.find_element_by_id('confirmation').is_displayed()

# Close modal
manage_widget.find_element_by_css_selector('.modal-footer .btn-default').click()
WebDriverWait(browser, 10).until(
Expand Down

0 comments on commit 9716756

Please sign in to comment.