SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
b234b7e5
Commit
b234b7e5
authored
6 months ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
fix greeting & allow html tags in college mail
parent
d056895e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost_django/scipost/forms.py
+17
-13
17 additions, 13 deletions
scipost_django/scipost/forms.py
with
17 additions
and
13 deletions
scipost_django/scipost/forms.py
+
17
−
13
View file @
b234b7e5
...
@@ -3,6 +3,7 @@ __license__ = "AGPL v3"
...
@@ -3,6 +3,7 @@ __license__ = "AGPL v3"
import
datetime
import
datetime
import
bleach
from
django.db.models
import
Q
from
django.db.models
import
Q
import
pyotp
import
pyotp
import
re
import
re
...
@@ -23,6 +24,8 @@ from crispy_forms.helper import FormHelper
...
@@ -23,6 +24,8 @@ from crispy_forms.helper import FormHelper
from
crispy_forms.layout
import
Layout
,
Div
,
Field
,
ButtonHolder
,
Submit
from
crispy_forms.layout
import
Layout
,
Div
,
Field
,
ButtonHolder
,
Submit
from
dal
import
autocomplete
from
dal
import
autocomplete
from
markup.constants
import
BLEACH_ALLOWED_ATTRIBUTES
,
BLEACH_ALLOWED_TAGS
from
.behaviors
import
orcid_validator
from
.behaviors
import
orcid_validator
from
.constants
import
(
from
.constants
import
(
NEWLY_REGISTERED
,
NEWLY_REGISTERED
,
...
@@ -1075,23 +1078,24 @@ class EmailUsersForm(forms.Form):
...
@@ -1075,23 +1078,24 @@ class EmailUsersForm(forms.Form):
email_text
=
""
email_text
=
""
email_text_html
=
""
email_text_html
=
""
if
self
.
cleaned_data
[
"
personalize
"
]:
if
self
.
cleaned_data
[
"
personalize
"
]:
email_text
=
(
email_text
=
f
"
Dear
{
user
.
contributor
.
profile
.
formal_name
}
,
\n\n
"
"
Dear
"
email_text_html
=
"
Dear {{ formal_name }},<br/>
"
+
user
.
contributor
.
profile
.
get_title_display
()
+
"
"
bleached_email_text
=
bleach
.
clean
(
+
user
.
last_name
self
.
cleaned_data
[
"
email_text
"
],
+
"
,
\n\n
"
tags
=
BLEACH_ALLOWED_TAGS
,
)
attributes
=
BLEACH_ALLOWED_ATTRIBUTES
,
email_text_html
=
"
Dear {{ title }} {{ last_name }},<br/>
"
)
email_text
+=
self
.
cleaned_data
[
"
email_text
"
]
email_text
+=
bleached_email_text
email_text_html
+=
"
{{ email_text|linebreaks }}
"
email_text_html
+=
"
{{ bleached_email_text|safe|linebreaksbr }}
"
email_context
=
{
email_context
=
{
"
title
"
:
user
.
contributor
.
profile
.
get_title_display
(),
"
formal_name
"
:
user
.
contributor
.
profile
.
formal_name
,
"
last_name
"
:
user
.
last_name
,
"
bleached_email_text
"
:
bleached_email_text
,
"
email_text
"
:
self
.
cleaned_data
[
"
email_text
"
],
}
}
html_template
=
Template
(
email_text_html
)
html_template
=
Template
(
email_text_html
)
html_version
=
html_template
.
render
(
Context
(
email_context
))
html_version
=
html_template
.
render
(
Context
(
email_context
))
message
=
mail
.
EmailMultiAlternatives
(
message
=
mail
.
EmailMultiAlternatives
(
self
.
cleaned_data
[
"
email_subject
"
],
self
.
cleaned_data
[
"
email_subject
"
],
email_text
,
email_text
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment