Skip to content

Commit d5c1678

Browse files
committed
LPC: add notificatoins for abstract comments
1 parent 12ec605 commit d5c1678

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

indico/modules/events/abstracts/models/email_logs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ def create_from_email(cls, email_data, email_tpl, user=None):
101101
notification
102102
"""
103103
recipients = sorted(email_data['to'] | email_data['cc'] | email_data['bcc'])
104-
data = {'template_name': email_tpl.title}
104+
if email_tpl is not None:
105+
name = email_tpl.title
106+
else:
107+
name = "Unknown"
108+
109+
data = {'template_name': name}
105110
return cls(email_template=email_tpl, user=user, recipients=recipients, subject=email_data['subject'],
106111
body=email_data['body'], data=data)

indico/modules/events/abstracts/notifications.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
from indico.util.placeholders import replace_placeholders
1717
from indico.util.rules import Condition, check_rule
1818
from indico.web.flask.templating import get_template_module
19-
19+
from indico.web.util import url_for_index
20+
from indico.web.flask.util import url_for
2021

2122
class EmailNotificationCondition(Condition):
2223
#: Override if you want to customize the text
@@ -176,3 +177,34 @@ def send_abstract_notifications(abstract):
176177
if email_tpl.stop_on_match and matched:
177178
break
178179
return sent
180+
181+
def send_abstract_comment(abstract, comment):
182+
"""Send comment about an abstract.
183+
184+
:param abstract: the abstract that is going to be checked
185+
against the event's notification rules
186+
:param comment: new comment
187+
"""
188+
title = abstract.title
189+
url = url_for('abstracts.display_abstract', abstract, management=False, _external=True)
190+
text = comment["text"]
191+
192+
contact = "contact@linuxplumbersconf.org"
193+
authors = [author.email for author in abstract.primary_authors]
194+
authors += [author.email for author in abstract.secondary_authors]
195+
196+
body = """
197+
A new comment has been added to submission "%s":
198+
199+
%s
200+
201+
You can review and respond at the submission page
202+
%s
203+
or reply to this email
204+
""" % (title, text, url)
205+
206+
email = make_email(to_list=[ contact ], cc_list=authors,
207+
subject="LPC: Comment added to your submission",
208+
reply_address=contact, body=body)
209+
send_email(email, abstract.event, 'Abstracts', session.user)
210+
abstract.email_logs.append(AbstractEmailLogEntry.create_from_email(email, email_tpl=None, user=session.user))

indico/modules/events/abstracts/operations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from indico.modules.events.abstracts.models.review_ratings import AbstractReviewRating
2323
from indico.modules.events.abstracts.models.reviews import AbstractAction, AbstractReview
2424
from indico.modules.events.abstracts.notifications import send_abstract_notifications
25+
from indico.modules.events.abstracts.notifications import send_abstract_comment
2526
from indico.modules.events.contributions.operations import create_contribution_from_abstract, delete_contribution
2627
from indico.modules.events.logs.models.entries import EventLogKind, EventLogRealm
2728
from indico.modules.events.logs.util import make_diff_log
@@ -298,6 +299,7 @@ def create_abstract_comment(abstract, comment_data):
298299
logger.info('Abstract %s received a comment from %s', abstract, session.user)
299300
abstract.log(EventLogRealm.reviewing, EventLogKind.positive, 'Abstracts',
300301
f'Abstract {abstract.verbose_title} received a comment', session.user)
302+
send_abstract_comment(abstract, comment_data)
301303

302304

303305
def update_abstract_comment(comment, comment_data):

0 commit comments

Comments
 (0)