Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added password reset and comment report sms template #1820

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Account, AccountPasswordNotification
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 @@ -45,14 +65,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 @@ -20,7 +20,7 @@
Project,
Proposal,
)
from ...transports.sms import OneLineTemplate, SmsPriority, SmsTemplate
from ...transports.sms import SmsPriority, SmsTemplate
from ..helpers import shortlink
from ..notification import RenderNotification
from .mixins import TemplateVarMixin
Expand Down Expand Up @@ -77,6 +77,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 @@ -102,9 +110,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 @@ -243,3 +243,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