Skip to content

Commit

Permalink
Added password reset and comment report sms template
Browse files Browse the repository at this point in the history
  • Loading branch information
djamg committed Jul 24, 2023
1 parent 4460adf commit 536073d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
39 changes: 26 additions & 13 deletions funnel/views/notifications/account_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@

from __future__ import annotations

from flask import render_template, url_for
from flask import render_template

from baseframe import _, __

from ... import app
from ...models import AccountPasswordNotification, User
from ...transports.sms import OneLineTemplate
from ..helpers import shortlink
from ...transports.sms import SmsTemplate
from ..notification import RenderNotification


class PasswordResetNotificationTemplate(SmsTemplate):
"""DLT registered template for Password Reset."""

registered_template = (
"Your password has been updated. If this was not authorized,"
" reset your password or contact support at {#var#}."
"\n\nhttps://bye.li to unsubscribe -Hasgeek"
)
template = (
"Your password has been updated. If this was not authorized,"
" reset your password or contact support at {email}."
"\n\nhttps://bye.li to unsubscribe -Hasgeek"
)
plaintext_template = (
"Your password has been updated. If this was not authorized,"
" reset your password or contact support at {email}."
)

email: str


@AccountPasswordNotification.renderer
class RenderAccountPasswordNotification(RenderNotification):
"""Notify user when their password is changed."""
Expand Down Expand Up @@ -44,14 +64,7 @@ def email_content(self):
'notifications/user_password_set_email.html.jinja2', view=self
)

def sms(self) -> OneLineTemplate:
return OneLineTemplate(
text1=_(
"Your password has been updated. If this was not authorized, reset"
" your password or contact support at {email}."
).format(email=app.config['SITE_SUPPORT_EMAIL']),
url=shortlink(
url_for('reset', _external=True, **self.tracking_tags('sms')),
shorter=True,
),
def sms(self) -> PasswordResetNotificationTemplate:
return PasswordResetNotificationTemplate(
email=app.config.get('SITE_SUPPORT_EMAIL')
)
15 changes: 11 additions & 4 deletions funnel/views/notifications/comment_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
NewCommentNotification,
User,
)
from ...transports.sms import OneLineTemplate, SmsTemplate
from ...transports.sms import SmsTemplate
from ..helpers import shortlink
from ..notification import RenderNotification
from .mixins import TemplateVarMixin
Expand Down Expand Up @@ -76,6 +76,14 @@ class CommentProjectTemplate(TemplateVarMixin, SmsTemplate):
url: str


class CommentReportReceivedTemplate(SmsTemplate):
registered_template = 'A comment has been reported as spam: {#var#} -Hasgeek'
template = 'A comment has been reported as spam: {url} -Hasgeek'
plaintext_template = 'A comment has been reported as spam: {url}'

url: str


@CommentReportReceivedNotification.renderer
class RenderCommentReportReceivedNotification(RenderNotification):
"""Notify site admins when a comment report is received."""
Expand All @@ -101,9 +109,8 @@ def email_content(self) -> str:
'notifications/comment_report_received_email.html.jinja2', view=self
)

def sms(self) -> OneLineTemplate:
return OneLineTemplate(
text1=_("A comment has been reported as spam."),
def sms(self) -> CommentReportReceivedTemplate:
return CommentReportReceivedTemplate(
url=shortlink(
url_for(
'siteadmin_review_comment',
Expand Down
2 changes: 2 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,5 @@ FLASK_SMS_DLT_TEMPLATE_IDS__update_template=null
FLASK_SMS_DLT_TEMPLATE_IDS__comment_project_template=null
FLASK_SMS_DLT_TEMPLATE_IDS__comment_proposal_template=null
FLASK_SMS_DLT_TEMPLATE_IDS__comment_reply_template=null
FLASK_SMS_DLT_TEMPLATE_IDS__comment_report_received_template=null
FLASK_SMS_DLT_TEMPLATE_IDS__password_reset_notification_template=null

0 comments on commit 536073d

Please sign in to comment.