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
072835d4
Unverified
Commit
072835d4
authored
May 25, 2021
by
urbec
🐣
Committed by
Pierre-Elliott Bécue
May 25, 2021
Browse files
Not translating template for RT ticket
Signed-off-by:
Pierre-Elliott Bécue
<
becue@crans.org
>
parent
c50fae19
Pipeline
#257390
passed with stage
in 8 minutes and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
process/views.py
View file @
072835d4
...
...
@@ -4,6 +4,7 @@ from django.shortcuts import redirect, get_object_or_404
from
django.views.generic
import
TemplateView
,
View
from
django.views.generic.edit
import
FormView
from
django.utils.timezone
import
now
import
django.utils.translation
as
translation
from
django.db
import
transaction
from
django
import
forms
,
http
from
django.core.exceptions
import
PermissionDenied
...
...
@@ -608,98 +609,99 @@ def make_rt_ticket_text(request, visitor, process):
# Build request text
req
=
[]
if
process
.
person
.
status
==
const
.
STATUS_DC
:
if
process
.
applying_for
==
const
.
STATUS_DC_GA
:
req
.
append
(
"Please create a porter account for {person.fullname} (sponsored by {sponsors})."
)
elif
process
.
person
.
status
==
const
.
STATUS_DC_GA
:
pass
elif
process
.
person
.
status
==
const
.
STATUS_DM
:
if
process
.
applying_for
==
const
.
STATUS_DM_GA
:
req
.
append
(
"Please create a porter account for {person.fullname} (currently a DM)."
)
elif
process
.
person
.
status
==
const
.
STATUS_DM_GA
:
pass
elif
process
.
person
.
status
==
const
.
STATUS_DD_NU
:
pass
elif
process
.
person
.
status
==
const
.
STATUS_EMERITUS_DD
:
pass
elif
process
.
person
.
status
==
const
.
STATUS_REMOVED_DD
:
pass
only_guest_account
=
only_needs_guest_account
(
process
)
if
retiring
or
(
process
.
person
.
status
==
const
.
STATUS_DD_U
and
process
.
applying_for
==
const
.
STATUS_DD_NU
):
req
.
append
(
"Please make {person.fullname} (currently {status_with_pronoun}) {applying_for_with_pronoun}."
)
elif
not
only_guest_account
:
req
.
append
(
"Please make {person.fullname} (currently {status_with_pronoun}) "
"{applying_for_with_pronoun} (advocated by {sponsors})."
)
if
not
only_guest_account
:
with
translation
.
override
(
'en'
):
req
=
[]
if
process
.
person
.
status
==
const
.
STATUS_DC
:
if
process
.
applying_for
==
const
.
STATUS_DC_GA
:
req
.
append
(
"Please create a porter account for {person.fullname} (sponsored by {sponsors})."
)
elif
process
.
person
.
status
==
const
.
STATUS_DC_GA
:
pass
elif
process
.
person
.
status
==
const
.
STATUS_DM
:
if
process
.
applying_for
==
const
.
STATUS_DM_GA
:
req
.
append
(
"Please create a porter account for {person.fullname} (currently a DM)."
)
elif
process
.
person
.
status
==
const
.
STATUS_DM_GA
:
pass
elif
process
.
person
.
status
==
const
.
STATUS_DD_NU
:
pass
elif
process
.
person
.
status
==
const
.
STATUS_EMERITUS_DD
:
pass
elif
process
.
person
.
status
==
const
.
STATUS_REMOVED_DD
:
pass
only_guest_account
=
only_needs_guest_account
(
process
)
if
retiring
or
(
process
.
person
.
status
==
const
.
STATUS_DD_U
and
process
.
applying_for
==
const
.
STATUS_DD_NU
):
req
.
append
(
"
Key {person.fpr} should be added to the '{applying_for}' keyring
."
)
el
se
:
"
Please make {person.fullname} (currently {status_with_pronoun}) {applying_for_with_pronoun}
."
)
el
if
not
only_guest_account
:
req
.
append
(
"Key {person.fpr} should be moved from the '{status}' to the '{applying_for}' keyring."
)
if
retiring
:
req
.
append
(
"Please also disable the {person.ldap_fields.uid} LDAP account."
)
elif
process
.
person
.
status
not
in
(
const
.
STATUS_DC
,
const
.
STATUS_DM
):
req
.
append
(
"Note that {person.fullname} already has an account in LDAP."
)
sponsors
=
set
()
try
:
adv_req
=
process
.
requirements
.
get
(
type
=
"advocate"
)
except
pmodels
.
Requirement
.
DoesNotExist
:
adv_req
=
None
if
adv_req
is
not
None
:
for
st
in
adv_req
.
statements
.
all
():
sponsors
.
add
(
st
.
uploaded_by
.
lookup_key
)
sponsors
=
", "
.
join
(
sorted
(
sponsors
))
format_args
=
{
"person"
:
process
.
person
,
"process"
:
process
,
"status"
:
const
.
ALL_STATUS_DESCS
[
process
.
person
.
status
],
"status_with_pronoun"
:
const
.
ALL_STATUS_DESCS_WITH_PRONOUN
[
process
.
person
.
status
],
"applying_for"
:
const
.
ALL_STATUS_DESCS
[
process
.
applying_for
],
"applying_for_with_pronoun"
:
const
.
ALL_STATUS_DESCS_WITH_PRONOUN
[
process
.
applying_for
],
"sponsors"
:
sponsors
,
}
"Please make {person.fullname} (currently {status_with_pronoun}) "
"{applying_for_with_pronoun} (advocated by {sponsors})."
)
import
textwrap
wrapper
=
textwrap
.
TextWrapper
(
width
=
75
)
wrapped
=
[]
for
paragraph
in
req
:
for
line
in
wrapper
.
wrap
(
paragraph
.
format
(
**
format_args
)):
wrapped
.
append
(
line
)
wrapped
.
append
(
""
)
ctx
[
"request"
]
=
"
\n
"
.
join
(
wrapped
)
# Format the declarations of intent
wrapper
=
textwrap
.
TextWrapper
(
width
=
75
,
initial_indent
=
" "
,
subsequent_indent
=
" "
)
wrapped
=
[]
for
intent
in
pmodels
.
Statement
.
objects
.
filter
(
requirement__process
=
process
,
requirement__type
=
"intent"
):
wrapped
.
append
(
"Details from {}:"
.
format
(
intent
.
uploaded_by
.
ldap_fields
.
uid
))
wrapped
.
append
(
""
)
for
paragraph
in
intent
.
statement_clean
.
splitlines
():
for
line
in
wrapper
.
wrap
(
paragraph
):
wrapped
.
append
(
line
)
wrapped
.
append
(
""
)
ctx
[
"intents"
]
=
"
\n
"
.
join
(
wrapped
)
if
not
only_guest_account
:
if
process
.
person
.
status
==
const
.
STATUS_DC
:
req
.
append
(
"Key {person.fpr} should be added to the '{applying_for}' keyring."
)
else
:
req
.
append
(
"Key {person.fpr} should be moved from the '{status}' to the '{applying_for}' keyring."
)
ctx
[
"process_url"
]
=
build_absolute_uri
(
process
.
get_absolute_url
(),
request
)
if
retiring
:
req
.
append
(
"Please also disable the {person.ldap_fields.uid} LDAP account."
)
elif
process
.
person
.
status
not
in
(
const
.
STATUS_DC
,
const
.
STATUS_DM
):
req
.
append
(
"Note that {person.fullname} already has an account in LDAP."
)
from
django.template.loader
import
render_to_string
return
render_to_string
(
"process/rt_ticket.txt"
,
ctx
).
strip
()
sponsors
=
set
()
try
:
adv_req
=
process
.
requirements
.
get
(
type
=
"advocate"
)
except
pmodels
.
Requirement
.
DoesNotExist
:
adv_req
=
None
if
adv_req
is
not
None
:
for
st
in
adv_req
.
statements
.
all
():
sponsors
.
add
(
st
.
uploaded_by
.
lookup_key
)
sponsors
=
", "
.
join
(
sorted
(
sponsors
))
format_args
=
{
"person"
:
process
.
person
,
"process"
:
process
,
"status"
:
const
.
ALL_STATUS_DESCS
[
process
.
person
.
status
],
"status_with_pronoun"
:
const
.
ALL_STATUS_DESCS_WITH_PRONOUN
[
process
.
person
.
status
],
"applying_for"
:
const
.
ALL_STATUS_DESCS
[
process
.
applying_for
],
"applying_for_with_pronoun"
:
const
.
ALL_STATUS_DESCS_WITH_PRONOUN
[
process
.
applying_for
],
"sponsors"
:
sponsors
,
}
import
textwrap
wrapper
=
textwrap
.
TextWrapper
(
width
=
75
)
wrapped
=
[]
for
paragraph
in
req
:
for
line
in
wrapper
.
wrap
(
paragraph
.
format
(
**
format_args
)):
wrapped
.
append
(
line
)
wrapped
.
append
(
""
)
ctx
[
"request"
]
=
"
\n
"
.
join
(
wrapped
)
# Format the declarations of intent
wrapper
=
textwrap
.
TextWrapper
(
width
=
75
,
initial_indent
=
" "
,
subsequent_indent
=
" "
)
wrapped
=
[]
for
intent
in
pmodels
.
Statement
.
objects
.
filter
(
requirement__process
=
process
,
requirement__type
=
"intent"
):
wrapped
.
append
(
"Details from {}:"
.
format
(
intent
.
uploaded_by
.
ldap_fields
.
uid
))
wrapped
.
append
(
""
)
for
paragraph
in
intent
.
statement_clean
.
splitlines
():
for
line
in
wrapper
.
wrap
(
paragraph
):
wrapped
.
append
(
line
)
wrapped
.
append
(
""
)
ctx
[
"intents"
]
=
"
\n
"
.
join
(
wrapped
)
ctx
[
"process_url"
]
=
build_absolute_uri
(
process
.
get_absolute_url
(),
request
)
from
django.template.loader
import
render_to_string
return
render_to_string
(
"process/rt_ticket.txt"
,
ctx
).
strip
()
class
EmeritusForm
(
forms
.
Form
):
...
...
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