-
Notifications
You must be signed in to change notification settings - Fork 52
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
anishTP
wants to merge
10
commits into
main
Choose a base branch
from
project-published
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a5173d2
Project published notification view and template
anishTP 0cc0993
Updated SMS template
djamg bcbf5ec
Changed document model to profile
anishTP 4ee48c6
Change base class
jace 5dabd69
Merge branch 'main' into project-published
jace 3dd3458
Only dispatch notification when first published
jace 97ef947
Minor styling fixing
anishTP d84d241
Fixed errors
djamg bc8eefe
Added ProjectPublishedNotification in the models namespace and refact…
anishTP 2c050e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
funnel/templates/notifications/project_published_email.html.jinja2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{%- extends "notifications/layout_email.html.jinja2" -%} | ||
{%- from "notifications/macros_email.html.jinja2" import cta_button, rsvp_footer, pinned_update -%} | ||
|
||
{% block stylesheet %} | ||
<style> | ||
a { | ||
text-decoration: none; | ||
font-weight: bold; | ||
color: #1f2d3d; | ||
} | ||
.project-banner__box__image { | ||
position: relative; | ||
transform: translate(0, -8px); | ||
object-fit: cover; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
.mui-list--unstyled { | ||
padding-left: 0; | ||
list-style: none; | ||
} | ||
.mui--align-middle { | ||
vertical-align: middle !important; | ||
} | ||
.fa-icon--right-margin { | ||
margin-right: 8px; | ||
} | ||
.project_time { | ||
margin: 8px 0 8px; | ||
font-size: 16px; | ||
font-weight: 600; | ||
} | ||
.mui--text-light { | ||
color: #4d5763; | ||
} | ||
.button-td, | ||
.button-a { | ||
border-radius: 4px; | ||
background-color: #4d5763; | ||
transition: all 100ms ease-in; | ||
font-family: sans-serif; | ||
font-size: 15px; | ||
line-height: 15px; | ||
text-decoration: none; | ||
} | ||
.button-a { | ||
border: 1px solid #4d5763; | ||
padding: 13px 17px; | ||
color: #ffffff; | ||
display: block; | ||
} | ||
.button-td-primary:hover, | ||
.button-a-primary:hover { | ||
background-color: #1f2d3d !important; | ||
border-color: #1f2d3d !important; | ||
} | ||
.project-banner__profile-details { | ||
display: -webkit-box-flex; | ||
display: -ms-flexbox; | ||
display: flex; | ||
line-height: 30px; | ||
margin-left: 0; | ||
} | ||
.project_title { | ||
line-height: 1.6rem; | ||
margin-top: 0; | ||
} | ||
.project_details { | ||
padding: 0; | ||
} | ||
.profile-details__text { | ||
margin-left: 4px; | ||
} | ||
</style> | ||
{% endblock stylesheet %} | ||
{%- block content -%} | ||
|
||
<tr> | ||
<td> | ||
{%- if view.project.bg_image.url %} | ||
<img class="project-banner__box__image" src="{{ view.project.bg_image.resize(700) }}" alt="{{ view.project.title }}"/> | ||
{%- else %} | ||
<img class="project-banner__box__image" src="{{ url_for('static', filename='img/default-banner.png') }}" alt="{{ view.project.title }}"/> | ||
{% endif %} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="project_details" align="left"> | ||
<div class="project-banner__profile-details"> | ||
{%- if view.project.profile.logo_url.url %} | ||
<a href="{{ view.project.profile.url_for() }}"> | ||
<img src="{{ view.project.profile.logo_url.resize(30) }}" alt="{{ view.project.profile.title }}"/> | ||
</a> | ||
{% endif %} | ||
<a href="{{ view.project.profile.url_for() }}" class="profile-details__text">{{ view.project.profile.title }}</a> | ||
</div> | ||
</td> | ||
</tr> | ||
<tr width="100%"> | ||
<td align="left"> | ||
<h2 class="project_title"><a href="{{ view.project.url_for() }}">{{ view.project.title }}</a></h2> | ||
<p class="project_time">{{ view.project.start_at|datetime(format='dd MMM YYYY') }} | {{ view.project.start_at|datetime(format='HH:MM') }}</p> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
{{ view.project.description.html }} | ||
</td> | ||
</tr> | ||
<br> | ||
|
||
{# Button : BEGIN #} | ||
{{ cta_button(view.project.url_for(_external=true), gettext("Register") )}} | ||
{# Button : END #} | ||
|
||
{# {{ pinned_update(view, project) }} #} | ||
|
||
<tr> | ||
<td class="line-separator"></td> | ||
</tr> | ||
<tr> | ||
<td class="footer-text">{{ view.reason }}</td> | ||
</tr> | ||
|
||
{%- endblock content -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
funnel/views/notifications/project_published_notification.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"""Project published notification.""" | ||
|
||
from __future__ import annotations | ||
|
||
from flask import render_template | ||
|
||
from baseframe import _, __ | ||
|
||
from ...models import Project, ProjectPublishedNotification | ||
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" | ||
) | ||
plaintext_template = "{profile} has published a new project: {url}" | ||
|
||
url: str | ||
profile: str | ||
|
||
|
||
@ProjectPublishedNotification.renderer | ||
class RenderProjectPublishedNotification(RenderNotification): | ||
"""Notify account followers when a new project is published.""" | ||
|
||
project: Project | ||
aliases = {'document': 'profile', 'fragment': 'project'} | ||
emoji_prefix = "📰 " | ||
reason = __( | ||
"You are receiving this because you have registered for this or related" | ||
" projects" | ||
) | ||
|
||
@property | ||
def actor(self): | ||
return self.project.user | ||
|
||
def web(self): | ||
return render_template('notifications/update_new_web.html.jinja2', view=self) | ||
|
||
def email_subject(self): | ||
return self.emoji_prefix + _("{update} ({project})").format( | ||
update=self.project.title, project=self.project.joined_title | ||
) | ||
|
||
def email_content(self): | ||
return render_template( | ||
'notifications/project_published_email.html.jinja2', view=self | ||
) | ||
|
||
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, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.