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
d63a25a9
Unverified
Commit
d63a25a9
authored
Oct 12, 2016
by
Joost Rijneveld
Browse files
Flatten groups that are not committees/boards
parent
016e2d89
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/mailinglists/management/commands/migratelists.py
View file @
d63a25a9
...
...
@@ -38,7 +38,18 @@ class Command(BaseCommand):
mlist
.
archived
=
bool
(
arch
)
mlist
.
moderated
=
bool
(
mod
)
groups
=
lines
[:
lines
.
index
(
'-'
)]
group_it
=
iter
(
lines
[:
lines
.
index
(
'-'
)])
groups
=
[]
while
True
:
try
:
groups
.
append
((
next
(
group_it
),
[]))
while
True
:
x
=
next
(
group_it
)
if
x
==
'='
:
break
groups
[
-
1
][
1
].
append
(
x
)
except
StopIteration
:
break
lines
=
lines
[
lines
.
index
(
'-'
)
+
1
:]
users
=
lines
[:
lines
.
index
(
'-'
)]
verbatims
=
lines
[
lines
.
index
(
'-'
)
+
1
:]
...
...
@@ -47,7 +58,7 @@ class Command(BaseCommand):
for
user
in
users
:
mlist
.
members
.
add
(
Member
.
objects
.
get
(
user__username
=
user
))
for
g
in
groups
:
for
g
,
users
in
groups
:
try
:
mlist
.
committees
.
add
(
Committee
.
objects
.
get
(
name_nl
=
g
))
except
Committee
.
DoesNotExist
:
...
...
@@ -56,6 +67,12 @@ class Command(BaseCommand):
except
Committee
.
DoesNotExist
:
print
(
"[{}] Did not find group '{}'"
.
format
(
name
,
g
))
print
(
" Adding individual users: {}"
.
format
(
', '
.
join
(
users
))
)
for
user
in
users
:
mlist
.
members
.
add
(
Member
.
objects
.
get
(
user__username
=
user
))
for
v
in
verbatims
:
obj
=
VerbatimAddress
(
address
=
v
,
mailinglist
=
mlist
)
obj
.
save
()
...
...
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