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
faf70d31
Commit
faf70d31
authored
7 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Set mail for prepublication
parent
c1be3039
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
funders/views.py
+3
-0
3 additions, 0 deletions
funders/views.py
mails/mixins.py
+12
-16
12 additions, 16 deletions
mails/mixins.py
with
15 additions
and
16 deletions
funders/views.py
+
3
−
0
View file @
faf70d31
...
@@ -4,6 +4,8 @@ import json
...
@@ -4,6 +4,8 @@ import json
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.auth.decorators
import
permission_required
from
django.contrib.auth.decorators
import
permission_required
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.db
import
transaction
from
django.utils.decorators
import
method_decorator
from
django.views.generic.edit
import
CreateView
from
django.views.generic.edit
import
CreateView
from
django.shortcuts
import
get_object_or_404
,
render
,
redirect
from
django.shortcuts
import
get_object_or_404
,
render
,
redirect
...
@@ -78,6 +80,7 @@ class HttpRefererMixin:
...
@@ -78,6 +80,7 @@ class HttpRefererMixin:
return
super
().
form_valid
(
form
)
return
super
().
form_valid
(
form
)
@method_decorator
(
transaction
.
atomic
,
name
=
'
dispatch
'
)
class
CreateGrantView
(
PermissionsMixin
,
HttpRefererMixin
,
CreateView
):
class
CreateGrantView
(
PermissionsMixin
,
HttpRefererMixin
,
CreateView
):
"""
"""
Create a Grant in a separate window which may also be used by Production Supervisors.
Create a Grant in a separate window which may also be used by Production Supervisors.
...
...
This diff is collapsed.
Click to expand it.
mails/mixins.py
+
12
−
16
View file @
faf70d31
...
@@ -52,14 +52,7 @@ class MailUtilsMixin:
...
@@ -52,14 +52,7 @@ class MailUtilsMixin:
self
.
mail_template
=
mail_template
.
render
(
kwargs
)
self
.
mail_template
=
mail_template
.
render
(
kwargs
)
# Gather Recipients data
# Gather Recipients data
self
.
original_recipient
=
''
self
.
original_recipient
=
self
.
_validate_single_entry
(
self
.
mail_data
.
get
(
'
to_address
'
))[
0
]
if
self
.
object
:
recipient
=
self
.
object
for
attr
in
self
.
mail_data
.
get
(
'
to_address
'
).
split
(
'
.
'
):
recipient
=
getattr
(
recipient
,
attr
)
if
inspect
.
ismethod
(
recipient
):
recipient
=
recipient
()
self
.
original_recipient
=
recipient
self
.
subject
=
self
.
mail_data
[
'
subject
'
]
self
.
subject
=
self
.
mail_data
[
'
subject
'
]
...
@@ -74,18 +67,20 @@ class MailUtilsMixin:
...
@@ -74,18 +67,20 @@ class MailUtilsMixin:
# Email string
# Email string
return
[
entry
]
return
[
entry
]
else
:
else
:
bcc
_to
=
self
.
object
mail
_to
=
self
.
object
for
attr
in
entry
.
split
(
'
.
'
):
for
attr
in
entry
.
split
(
'
.
'
):
try
:
try
:
bcc_to
=
getattr
(
bcc_to
,
attr
)
mail_to
=
getattr
(
mail_to
,
attr
)
if
inspect
.
ismethod
(
mail_to
):
mail_to
=
mail_to
()
except
AttributeError
:
except
AttributeError
:
# Invalid property
, don't use bcc
# Invalid property
/mail
return
[]
return
[]
if
not
isinstance
(
bcc
_to
,
list
):
if
not
isinstance
(
mail
_to
,
list
):
return
[
bcc
_to
]
return
[
mail
_to
]
else
:
else
:
return
bcc
_to
return
mail
_to
elif
re
.
match
(
"
[^@]+@[^@]+\.[^@]+
"
,
entry
):
elif
re
.
match
(
"
[^@]+@[^@]+\.[^@]+
"
,
entry
):
return
[
entry
]
return
[
entry
]
...
@@ -96,8 +91,9 @@ class MailUtilsMixin:
...
@@ -96,8 +91,9 @@ class MailUtilsMixin:
"""
"""
# Get recipients list. Try to send through BCC to prevent privacy issues!
# Get recipients list. Try to send through BCC to prevent privacy issues!
self
.
bcc_list
=
[]
self
.
bcc_list
=
[]
for
bcc_entry
in
self
.
mail_data
.
get
(
'
bcc_to
'
,
''
).
split
(
'
,
'
):
if
self
.
mail_data
.
get
(
'
bcc_to
'
):
self
.
bcc_list
+=
self
.
_validate_single_entry
(
bcc_entry
)
for
bcc_entry
in
self
.
mail_data
[
'
bcc_to
'
].
split
(
'
,
'
):
self
.
bcc_list
+=
self
.
_validate_single_entry
(
bcc_entry
)
def
validate_recipients
(
self
):
def
validate_recipients
(
self
):
# Check the send list
# Check the send list
...
...
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