Skip to content
GitLab
Explore
Sign in
Commits on Source (3)
Rename TemplateTransaction into RecurrentTransaction
· 2571477b
Maxime Bombar
authored
Mar 22, 2020
2571477b
Do not hardcode database name and owner
· 146260b3
Maxime Bombar
authored
Mar 22, 2020
146260b3
Merge branch 'Update_Scripts' into 'master'
· b9fdced3
Pierre-antoine Comby
authored
Mar 22, 2020
Update scripts See merge request
!1
b9fdced3
Hide whitespace changes
Inline
Side-by-side
management/commands/import_nk15.py
View file @
b9fdced3
...
...
@@ -18,7 +18,7 @@ from django.contrib.auth.models import User
from
note.models
import
Note
,
NoteSpecial
,
NoteUser
,
NoteClub
from
note.models
import
Alias
from
note.models
import
Transaction
,
TransactionTemplate
,
\
TemplateCategory
,
Template
Transaction
,
MembershipTransaction
TemplateCategory
,
Recurrent
Transaction
,
MembershipTransaction
from
member.models
import
Profile
,
Club
,
Membership
"""
...
...
@@ -185,7 +185,7 @@ def import_transaction(cur, map_idbde):
if
created
:
cat
.
save
()
obj_dict
[
"
category
"
]
=
cat
transac
=
Template
Transaction
.
objects
.
create
(
**
obj_dict
)
transac
=
Recurrent
Transaction
.
objects
.
create
(
**
obj_dict
)
transac
.
save
()
elif
row
[
"
type
"
]
==
"
adhésion
"
:
print
(
"
adhesion not supported yet
"
)
...
...
@@ -231,13 +231,16 @@ class Command(BaseCommand):
parser
.
add_argument
(
'
-b
'
,
'
--boutons
'
,
action
=
'
store_true
'
,
help
=
"
import boutons
"
)
parser
.
add_argument
(
'
-t
'
,
'
--transactions
'
,
action
=
'
store_true
'
,
help
=
"
import transaction
"
)
parser
.
add_argument
(
'
-a
'
,
'
--aliases
'
,
action
=
'
store_true
'
,
help
=
"
import aliases
"
)
parser
.
add_argument
(
'
-d
'
,
'
--nk15db
'
,
action
=
'
store
'
,
default
=
'
nk15
'
,
help
=
'
NK15 database name
'
)
parser
.
add_argument
(
'
-u
'
,
'
--nk15user
'
,
action
=
'
store
'
,
default
=
'
nk15_user
'
,
help
=
'
NK15 database owner
'
)
def
handle
(
self
,
*
args
,
**
kwargs
):
nk15db
,
nk15user
=
kwargs
[
'
nk15db
'
],
kwargs
[
'
nk15user
'
]
#reset database.
call_command
(
"
flush
"
)
self
.
print_success
(
"
flush nk20 database
"
)
# connecting to nk15 database
conn
=
pg
.
connect
(
database
=
"
nk15
"
,
user
=
"
nk15
_
user
"
)
conn
=
pg
.
connect
(
database
=
nk15
db
,
user
=
nk15user
)
cur
=
conn
.
cursor
(
cursor_factory
=
pge
.
DictCursor
)
if
kwargs
[
"
special
"
]:
...
...