Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
e0f9fdc7
Verified
Commit
e0f9fdc7
authored
Apr 24, 2019
by
Jelle Besseling
Browse files
Replace print with self.stdout.write in management
parent
dbc1b1cc
Changes
4
Hide whitespace changes
Inline
Side-by-side
website/members/management/commands/cleanmemberemails.py
View file @
e0f9fdc7
...
...
@@ -23,8 +23,8 @@ class Command(BaseCommand):
try
:
validate_email
(
user
.
email
)
except
ValidationError
:
print
(
"Email address for "
+
user
.
username
+
" invalid: "
+
user
.
email
)
self
.
stdout
.
write
(
"Email address for "
+
user
.
username
+
" invalid: "
+
user
.
email
)
if
not
options
[
'dry-run'
]:
user
.
email
=
""
user
.
save
()
website/members/management/commands/dataminimisation.py
View file @
e0f9fdc7
...
...
@@ -17,4 +17,4 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
processed
=
services
.
execute_data_minimisation
(
options
[
'dry-run'
])
for
p
in
processed
:
print
(
'Removed data for {}'
.
format
(
p
))
self
.
stdout
.
write
(
'Removed data for {}'
.
format
(
p
))
website/photos/management/commands/importphotos.py
View file @
e0f9fdc7
...
...
@@ -26,11 +26,11 @@ class Command(BaseCommand):
slug
=
slugify
(
'-'
.
join
([
str
(
date
),
title
]))
if
Album
.
objects
.
filter
(
title
=
title
,
date
=
date
).
exists
():
print
(
"An album with title ({}) and
date ({}) already exists.
"
.
format
(
title
,
date
))
self
.
stdout
.
write
(
"An album with title ({}) and"
" date ({}) already exists."
.
format
(
title
,
date
))
return
print
(
"Importing album '{}' ({})"
.
format
(
title
,
str
(
date
)))
self
.
stdout
.
write
(
"Importing album '{}' ({})"
.
format
(
title
,
str
(
date
)))
album
=
Album
(
title
=
title
,
date
=
date
,
slug
=
slug
)
album
.
save
()
...
...
@@ -43,6 +43,7 @@ class Command(BaseCommand):
photo
.
save
()
n
+=
1
except
Exception
:
print
(
"Could not import {}"
.
format
(
filename
))
self
.
stdout
.
write
(
"Could not import {}"
.
format
(
filename
))
print
(
"Imported {} photos from {}"
.
format
(
n
,
options
[
'folder'
]))
self
.
stdout
.
write
(
"Imported {} photos from {}"
.
format
(
n
,
options
[
'folder'
]))
website/utils/management/commands/createfixtures.py
View file @
e0f9fdc7
...
...
@@ -133,8 +133,8 @@ class Command(BaseCommand):
"""
members
=
Member
.
objects
.
all
()
if
len
(
members
)
<
6
:
print
(
'Your database does not contain 6 users.'
)
print
(
f
'Creating
{
6
-
len
(
members
)
}
more users.'
)
self
.
stdout
.
write
(
'Your database does not contain 6 users.'
)
self
.
stdout
.
write
(
f
'Creating
{
6
-
len
(
members
)
}
more users.'
)
for
__
in
range
(
6
-
len
(
members
)):
self
.
create_user
()
...
...
@@ -177,8 +177,8 @@ class Command(BaseCommand):
"""
members
=
Member
.
objects
.
all
()
if
len
(
members
)
<
6
:
print
(
'Your database does not contain 6 users.'
)
print
(
f
'Creating
{
6
-
len
(
members
)
}
more users.'
)
self
.
stdout
.
write
(
'Your database does not contain 6 users.'
)
self
.
stdout
.
write
(
f
'Creating
{
6
-
len
(
members
)
}
more users.'
)
for
__
in
range
(
6
-
len
(
members
)):
self
.
create_user
()
members
=
Member
.
objects
.
all
()
...
...
@@ -252,8 +252,9 @@ class Command(BaseCommand):
"""
groups
=
MemberGroup
.
objects
.
all
()
if
len
(
groups
)
==
0
:
print
(
'Your database does not contain any member groups.'
)
print
(
'Creating a committee.'
)
self
.
stdout
.
write
(
'Your database does not contain any '
'member groups.'
)
self
.
stdout
.
write
(
'Creating a committee.'
)
self
.
create_member_group
(
Committee
)
groups
=
MemberGroup
.
objects
.
all
()
event
=
Event
()
...
...
@@ -496,11 +497,12 @@ class Command(BaseCommand):
'user'
,
'vacancy'
,
'document'
,
'newsletter'
]
if
all
([
not
options
[
opt
]
for
opt
in
opts
]):
print
(
"Use ./manage.py help createfixtures to find out
how to call
"
"
this command"
)
self
.
stdout
.
write
(
"Use ./manage.py help createfixtures to find out"
" how to call
this command"
)
if
options
[
'all'
]:
print
(
'all argument given, overwriting all other inputs'
)
self
.
stdout
.
write
(
'all argument given, overwriting'
' all other inputs'
)
options
=
{
'user'
:
20
,
'board'
:
3
,
...
...
@@ -554,7 +556,8 @@ class Command(BaseCommand):
if
options
[
'vacancy'
]:
categories
=
VacancyCategory
.
objects
.
all
()
if
not
categories
:
print
(
'No vacancy categories found. Creating 5 categories.'
)
self
.
stdout
.
write
(
'No vacancy categories found. '
'Creating 5 categories.'
)
for
__
in
range
(
5
):
self
.
create_vacancy_category
()
categories
=
VacancyCategory
.
objects
.
all
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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