Skip to content
GitLab
Explore
Sign in
Commits on Source (3)
I broke the import script
· 2a113d22
ynerant
authored
Sep 05, 2020
2a113d22
Change debug option to "print stdout" / "edit wiki" in the Refresh activities script
· 7246f4d1
ynerant
authored
Sep 05, 2020
7246f4d1
Don't rebuild systematically migrations
· 7479671b
ynerant
authored
Sep 05, 2020
7479671b
Hide whitespace changes
Inline
Side-by-side
management/commands/import_account.py
View file @
7479671b
...
...
@@ -94,7 +94,7 @@ class Command(ImportCommand):
# clean pseudo (normalized pseudo must be unique and not empty)
if
not
pseudo_norm
or
pseudo_norm
in
ALIAS_SET
:
pseudo
=
pseudo
+
str
(
row
[
"
idbde
"
])
CHANGED_USERNAMES
.
append
((
pk_note
,
row
[
pseudo
],
pseudo
))
CHANGED_USERNAMES
.
append
((
pk_note
,
row
[
"
idbde
"
],
pseudo
))
else
:
ALIAS_SET
.
add
(
pseudo_norm
)
# clean date
...
...
@@ -138,7 +138,7 @@ class Command(ImportCommand):
"
registration_valid
"
:
True
,
"
email_confirmed
"
:
True
,
"
promotion
"
:
MAP_IDBDE_PROMOTION
[
row
[
"
idbde
"
]][
"
promo
"
],
"
report_frequency
"
:
row
[
"
report_period
"
],
"
report_frequency
"
:
max
(
row
[
"
report_period
"
],
0
),
"
last_report
"
:
make_aware
(
row
[
"
previous_report_date
"
]),
}
note_dict
[
"
created_at
"
]
=
make_aware
(
MAP_IDBDE_PROMOTION
[
row
[
"
idbde
"
]][
"
created_at
"
])
...
...
@@ -248,7 +248,7 @@ class Command(ImportCommand):
json
.
dump
(
MAP_IDBDE
,
fp
,
sort_keys
=
True
,
indent
=
2
)
for
pk_user
,
old_username
,
new_username
in
CHANGED_USERNAMES
:
user
=
User
.
objects
.
get
(
pk_user
)
user
=
User
.
objects
.
get
(
pk
=
pk
_user
)
mail_text
=
render_to_string
(
"
scripts/unsupported_username.txt
"
,
dict
(
user
=
user
,
old_username
=
old_username
,
...
...
@@ -257,7 +257,7 @@ class Command(ImportCommand):
user
.
email_user
(
"
Transition à la Note Kfet 2020 : pseudo non supporté
"
,
mail_text
)
for
pk_user
,
aliases_list
in
CHANGED_USERNAMES
:
user
=
User
.
objects
.
get
(
pk_user
)
user
=
User
.
objects
.
get
(
pk
=
pk
_user
)
mail_text
=
render_to_string
(
"
scripts/deleted_aliases.txt
"
,
dict
(
user
=
user
,
aliases_list
=
aliases_list
,
...
...
management/commands/refresh_activities.py
View file @
7479671b
...
...
@@ -150,30 +150,31 @@ class Command(BaseCommand):
return
page
,
header
+
body
@staticmethod
def
refresh_raw_wiki_page
(
comment
=
"
refresh
"
,
debug
=
Tru
e
):
def
refresh_raw_wiki_page
(
comment
=
"
refresh
"
,
print_stdout
=
False
,
edit_wiki
=
Fals
e
):
page
,
content
=
Command
.
get_raw_page
()
if
debug
:
if
print_stdout
:
print
(
content
)
else
:
if
edit_wiki
:
Command
.
edit_wiki
(
page
,
content
,
comment
)
@staticmethod
def
refresh_human_readable_wiki_page
(
comment
=
"
refresh
"
,
debug
=
Tru
e
):
def
refresh_human_readable_wiki_page
(
comment
=
"
refresh
"
,
print_stdout
=
False
,
edit_wiki
=
Fals
e
):
page
,
content
=
Command
.
get_human_readable_page
()
if
debug
:
if
print_stdout
:
print
(
content
)
else
:
if
edit_wiki
:
Command
.
edit_wiki
(
page
,
content
,
comment
)
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
"
--human
"
,
"
-H
"
,
action
=
"
store_true
"
,
help
=
"
Save human readable page
"
)
parser
.
add_argument
(
"
--raw
"
,
"
-r
"
,
action
=
"
store_true
"
,
help
=
"
Save raw page, for the calendar
"
)
parser
.
add_argument
(
"
--comment
"
,
"
-c
"
,
action
=
"
store
"
,
type
=
str
,
default
=
""
,
help
=
"
Comment of the modification
"
)
parser
.
add_argument
(
"
--debug
"
,
"
-d
"
,
action
=
"
store_true
"
,
help
=
"
Don
'
t commit to the wiki, render in stdout
"
)
parser
.
add_argument
(
"
--stdout
"
,
"
-o
"
,
action
=
"
store_true
"
,
help
=
"
Render the wiki page in stdout
"
)
parser
.
add_argument
(
"
--wiki
"
,
"
-w
"
,
action
=
"
store_true
"
,
help
=
"
Send modifications to the wiki
"
)
def
handle
(
self
,
*
args
,
**
options
):
if
options
[
"
raw
"
]:
Command
.
refresh_raw_wiki_page
(
options
[
"
comment
"
],
options
[
"
debug
"
])
Command
.
refresh_raw_wiki_page
(
options
[
"
comment
"
],
options
[
"
stdout
"
],
options
[
"
wiki
"
])
if
options
[
"
human
"
]:
Command
.
refresh_human_readable_wiki_page
(
options
[
"
comment
"
],
options
[
"
debug
"
])
Command
.
refresh_human_readable_wiki_page
(
options
[
"
comment
"
],
options
[
"
stdout
"
],
options
[
"
wiki
"
])
shell/tabularasa
View file @
7479671b
...
...
@@ -3,7 +3,5 @@ sudo service postgresql stop
sudo
service postgresql start
sudo
-u
postgres sh
-c
"dropdb note_db && psql -c 'CREATE DATABASE note_db OWNER note;'"
;
echo
'reset db'
;
find apps/
-path
"*/migrations/*.py*"
-not
-name
"__init__.py"
-delete
./manage.py makemigrations
./manage.py migrate
./manage.py loaddata initial