Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
547b4d62
Unverified
Commit
547b4d62
authored
Mar 27, 2021
by
Pierre-Elliott Bécue
🚼
Browse files
Send various mails when processes are ready for a review or FD approved
parent
1643f0cc
Pipeline
#251559
passed with stage
in 5 minutes and 46 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
process/email.py
View file @
547b4d62
...
...
@@ -331,3 +331,123 @@ If you need help with anything, please mail nm@debian.org.
", "
.
join
(
msg
.
bcc
),
", "
.
join
(
msg
.
reply_to
),
msg
.
subject
)
def
notify_dd_awaiting
(
process
,
request
=
None
):
"""
Sends a notification to FD/DAM when a DD process is awaiting a review.
"""
if
request
is
None
:
url
=
"https://{}{}"
.
format
(
Site
.
objects
.
get_current
().
domain
,
process
.
get_absolute_url
())
else
:
url
=
build_absolute_uri
(
process
.
get_absolute_url
(),
request
)
with
translation
.
override
(
'en'
):
body
=
"""Hello,
{process.person.fullname} <{process.person.ldap_fields.uid}> {status}'s process
is ready for a review.
The nm.debian.org page for this process is at {url}
Debian New Member Front Desk
"""
body
=
body
.
format
(
process
=
process
,
status
=
const
.
ALL_STATUS_DESCS
[
process
.
applying_for
],
url
=
url
)
msg
=
build_django_message
(
from_email
=
(
"nm.debian.org"
,
"nm@debian.org"
),
to
=
[
"nm@debian.org"
,
"da-manager@debian.org"
],
subject
=
"Please Review {}: {} <{}>"
.
format
(
const
.
ALL_STATUS_DESCS
[
process
.
applying_for
],
process
.
person
.
fullname
,
process
.
person
.
ldap_fields
.
uid
),
body
=
body
)
msg
.
send
()
log
.
debug
(
"sent mail from %s to %s cc %s bcc %s subject %s"
,
msg
.
from_email
,
", "
.
join
(
msg
.
to
),
", "
.
join
(
msg
.
cc
),
", "
.
join
(
msg
.
bcc
),
msg
.
subject
)
def
notify_dd_fd_approved
(
process
,
request
=
None
):
"""
Notify DAM and FD when a DD process is FD-approved
"""
if
request
is
None
:
url
=
"https://{}{}"
.
format
(
Site
.
objects
.
get_current
().
domain
,
process
.
get_absolute_url
())
else
:
url
=
build_absolute_uri
(
process
.
get_absolute_url
(),
request
)
with
translation
.
override
(
'en'
):
body
=
"""Hello,
{process.person.fullname} <{process.person.ldap_fields.uid}> {status}'s process
has been FD-approved by {process.approved_by}.
The nm.debian.org page for this process is at {url}
Debian New Member Front Desk
"""
body
=
body
.
format
(
process
=
process
,
status
=
const
.
ALL_STATUS_DESCS
[
process
.
applying_for
],
url
=
url
)
msg
=
build_django_message
(
from_email
=
(
"nm.debian.org"
,
"nm@debian.org"
),
to
=
[
"nm@debian.org"
,
"da-manager@debian.org"
],
subject
=
"FD approval {}: {} <{}>"
.
format
(
const
.
ALL_STATUS_DESCS
[
process
.
applying_for
],
process
.
person
.
fullname
,
process
.
person
.
ldap_fields
.
uid
),
body
=
body
)
msg
.
send
()
log
.
debug
(
"sent mail from %s to %s cc %s bcc %s subject %s"
,
msg
.
from_email
,
", "
.
join
(
msg
.
to
),
", "
.
join
(
msg
.
cc
),
", "
.
join
(
msg
.
bcc
),
msg
.
subject
)
def
notify_process_awaiting
(
process
,
request
=
None
):
"""
Notify FD that a process is awaiting for a review.
"""
if
request
is
None
:
url
=
"https://{}{}"
.
format
(
Site
.
objects
.
get_current
().
domain
,
process
.
get_absolute_url
())
else
:
url
=
build_absolute_uri
(
process
.
get_absolute_url
(),
request
)
with
translation
.
override
(
'en'
):
body
=
"""Hello,
{process.person.fullname} <{process.person.ldap_fields.uid}> {status}'s process
is ready for a review.
The nm.debian.org page for this process is at {url}
Debian New Member Front Desk
"""
body
=
body
.
format
(
process
=
process
,
status
=
const
.
ALL_STATUS_DESCS
[
process
.
applying_for
],
url
=
url
)
msg
=
build_django_message
(
from_email
=
(
"nm.debian.org"
,
"nm@debian.org"
),
to
=
[
"nm@debian.org"
],
subject
=
"Please Review {}: {} <{}>"
.
format
(
const
.
ALL_STATUS_DESCS
[
process
.
applying_for
],
process
.
person
.
fullname
,
process
.
person
.
ldap_fields
.
uid
),
body
=
body
)
msg
.
send
()
log
.
debug
(
"sent mail from %s to %s cc %s bcc %s subject %s"
,
msg
.
from_email
,
", "
.
join
(
msg
.
to
),
", "
.
join
(
msg
.
cc
),
", "
.
join
(
msg
.
bcc
),
msg
.
subject
)
process/ops.py
View file @
547b4d62
...
...
@@ -144,6 +144,23 @@ class RequirementApprove(op.Operation):
self
.
requirement
.
add_log
(
self
.
audit_author
,
self
.
audit_notes
,
action
=
"req_approve"
,
is_public
=
True
,
logdate
=
self
.
audit_time
)
self
.
_check_for_mail
()
def
_check_for_mail
(
self
):
from
.email
import
notify_dd_awaiting
,
notify_process_awaiting
process
=
self
.
requirement
.
process
if
process
.
applying_for
in
(
const
.
STATUS_DD_NU
,
const
.
STATUS_DD_U
):
process
=
self
.
requirement
.
process
# For DD, we consider that DAM/FD's attention is required as soon as am_ok is approved.
if
self
.
requirement
.
type
==
"am_ok"
:
notify_dd_awaiting
(
process
)
# Other processes trigger a mail when all requirements are ok except approval.
if
process
.
applying_for
in
(
const
.
STATUS_DM
,
const
.
STATUS_DM_GA
,
const
.
STATUS_DC_GA
):
rnok
=
process
.
requirements
.
filter
(
approved_by__isnull
=
True
)
if
len
(
rnok
)
==
1
and
rnok
[
0
].
type
==
"approval"
:
notify_process_awaiting
(
process
)
@
op
.
Operation
.
register
class
RequirementUnapprove
(
op
.
Operation
):
...
...
@@ -226,6 +243,15 @@ class ProcessApprove(op.Operation):
self
.
process
.
add_log
(
self
.
audit_author
,
self
.
audit_notes
,
action
=
"proc_approve"
,
is_public
=
True
,
logdate
=
self
.
audit_time
)
self
.
_check_for_mail
()
def
_check_for_mail
(
self
):
from
.email
import
notify_dd_fd_approved
# Any non DAM approval triggers a mail
am
=
self
.
process
.
approved_by
.
am_or_none
if
am
is
None
or
not
am
.
is_dam
:
notify_dd_fd_approved
(
self
.
process
)
@
op
.
Operation
.
register
class
ProcessUnapprove
(
op
.
Operation
):
...
...
process/tests/test_log.py
View file @
547b4d62
...
...
@@ -250,7 +250,7 @@ class TestLog(ProcessFixtureMixin, TestCase):
self
.
assertEqual
(
self
.
processes
.
app
.
closed_time
,
self
.
orig_ts
)
self
.
assertIntentUnchanged
()
self
.
assertAmOkUnchanged
()
self
.
assertEqual
(
len
(
mail
.
outbox
),
0
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
def
test_process_proc_unapprove
(
self
):
with
patch
(
"process.views.now"
)
as
mock_now
:
...
...
process/tests/test_ops.py
View file @
547b4d62
...
...
@@ -254,3 +254,90 @@ class TestProcessClose(ProcessFixtureMixin, TestCase):
self
.
assertEqual
(
self
.
processes
.
app
.
closed_time
,
self
.
now
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
to
,
[
"leader@debian.org"
])
class
TestProcessRequirementApprove
(
ProcessFixtureMixin
,
TestCase
):
@
classmethod
def
setUpClass
(
cls
):
super
().
setUpClass
()
cls
.
create_person
(
"app"
,
status
=
const
.
STATUS_DC
,
fullname
=
"applicant"
)
cls
.
processes
.
create
(
"app"
,
person
=
cls
.
persons
.
app
,
applying_for
=
const
.
STATUS_DD_U
,
fd_comment
=
"test"
)
cls
.
now
=
now
()
def
test_am_ok_mail
(
self
):
req
=
self
.
processes
.
app
.
requirements
.
get
(
type
=
"am_ok"
)
op
=
pops
.
RequirementApprove
(
requirement
=
req
,
statement
=
"foo"
,
audit_author
=
self
.
persons
.
dam
,
audit_time
=
self
.
now
,
audit_notes
=
'requirement approved'
)
op
.
execute
()
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
from_email
,
'"nm.debian.org" <nm@debian.org>'
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
to
,
[
'nm@debian.org'
,
'da-manager@debian.org'
])
self
.
assertEqual
(
mail
.
outbox
[
0
].
cc
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
bcc
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
reply_to
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
subject
,
"Please Review Debian Developer, uploading: applicant <app>"
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
body
,
"Hello,
\n
"
"
\n
"
"applicant <app> Debian Developer, uploading's process
\n
"
"is ready for a review.
\n
"
"
\n
"
"The nm.debian.org page for this process is at https://example.com/process/1/
\n
"
"
\n
"
"Debian New Member Front Desk
\n
"
)
def
test_fd_approved_mail
(
self
):
req
=
self
.
processes
.
app
.
requirements
.
get
(
type
=
"approval"
)
op
=
pops
.
ProcessApprove
(
process
=
self
.
processes
.
app
,
audit_author
=
self
.
persons
.
fd
,
audit_time
=
self
.
now
)
op
.
execute
()
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
from_email
,
'"nm.debian.org" <nm@debian.org>'
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
to
,
[
'nm@debian.org'
,
'da-manager@debian.org'
])
self
.
assertEqual
(
mail
.
outbox
[
0
].
cc
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
bcc
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
reply_to
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
subject
,
"FD approval Debian Developer, uploading: applicant <app>"
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
body
,
"Hello,
\n
"
"
\n
"
"applicant <app> Debian Developer, uploading's process
\n
"
"has been FD-approved by Fd <fd@example.org>.
\n
"
"
\n
"
"The nm.debian.org page for this process is at https://example.com/process/1/
\n
"
"
\n
"
"Debian New Member Front Desk
\n
"
)
def
test_process_awaiting
(
self
):
self
.
processes
.
app
.
applying_for
=
const
.
STATUS_DM
self
.
processes
.
app
.
save
()
for
req
in
self
.
processes
.
app
.
requirements
.
all
():
if
req
.
type
!=
"approval"
:
op
=
pops
.
RequirementApprove
(
requirement
=
req
,
statement
=
"foo"
,
audit_author
=
self
.
persons
.
dam
,
audit_time
=
self
.
now
,
audit_notes
=
'requirement approved'
)
op
.
execute
()
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
from_email
,
'"nm.debian.org" <nm@debian.org>'
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
to
,
[
'nm@debian.org'
])
self
.
assertEqual
(
mail
.
outbox
[
0
].
cc
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
bcc
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
reply_to
,
[])
self
.
assertEqual
(
mail
.
outbox
[
0
].
subject
,
"Please Review Debian Maintainer: applicant <app>"
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
body
,
"Hello,
\n
"
"
\n
"
"applicant <app> Debian Maintainer's process
\n
"
"is ready for a review.
\n
"
"
\n
"
"The nm.debian.org page for this process is at https://example.com/process/1/
\n
"
"
\n
"
"Debian New Member Front Desk
\n
"
)
Pierre-Elliott Bécue
🚼
@peb
mentioned in issue
#39 (closed)
·
May 14, 2021
mentioned in issue
#39 (closed)
mentioned in issue #39
Toggle commit list
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment