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

Project published notification view and template #1792

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
28 changes: 23 additions & 5 deletions funnel/views/notifications/project_published_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,27 @@
from baseframe import _, __

from ...models import Project, ProjectPublishedNotification
from ...transports.sms import TwoLineTemplate
from ...transports.sms import SmsTemplate
from ..helpers import shortlink
from ..notification import RenderNotification
from .mixins import TemplateVarMixin


class ProjectPublishedTemplate(TemplateVarMixin, SmsTemplate):
"""DLT registered template for Project published."""

registered_template = (
"{#var#}, whose event you previously registered for, has just announced"
" {#var#}. Details here: {#var#}\n\nhttps://bye.li to stop -Hasgeek"
)
template = (
"{profile}, whose event you previously registered for, has just announced"
"{project}. Details here: {url}\n\nhttps://bye.li to stop -Hasgeek"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leading space is missing here.

)
plaintext_template = "{profile} has published a new project: {url}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to have {project} to be sufficiently verbose.


url: str
profile: str


@ProjectPublishedNotification.renderer
Expand Down Expand Up @@ -41,10 +59,10 @@ def email_content(self):
'notifications/project_published_email.html.jinja2', view=self
)

def sms(self) -> TwoLineTemplate:
return TwoLineTemplate(
text1=_("Update in {project}:").format(project=self.project.joined_title),
text2=self.project.title,
def sms(self) -> ProjectPublishedTemplate:
return ProjectPublishedTemplate(
profile=self.project.profile,
project=self.project,
url=shortlink(
self.update.url_for(_external=True, **self.tracking_tags('sms')),
shorter=True,
Expand Down
Loading