Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nk20-scripts
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20-scripts
Commits
e2c1d70e
Commit
e2c1d70e
authored
5 years ago
by
Pierre-antoine Comby
Browse files
Options
Downloads
Patches
Plain Diff
Import boutons transaction, prep for adhésions
parent
5a963eb2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
management/commands/import_nk15.py
+28
-6
28 additions, 6 deletions
management/commands/import_nk15.py
with
28 additions
and
6 deletions
management/commands/import_nk15.py
+
28
−
6
View file @
e2c1d70e
...
...
@@ -16,16 +16,16 @@ from django.db import IntegrityError
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
,
TransactionType
from
member.models
import
Profile
,
Club
from
note.models
import
Transaction
,
TransactionTemplate
,
\
TemplateCategory
,
TemplateTransaction
,
MembershipTransaction
from
member.models
import
Profile
,
Club
,
Membership
"""
Script d
'
import de la nk15:
TODO: import aliases
TODO: import transactions
TODO: import adhesion
TODO: import activite
TODO: import
TODO: import
...
"""
@transaction.atomic
...
...
@@ -161,11 +161,33 @@ def import_boutons(cur,map_idbde):
@transaction.atomic
def
import_transaction
(
cur
,
map_idbde
):
cur
.
execute
(
"
SELECT * FROM transactions;
"
)
cur
.
execute
(
"
SELECT * FROM transactions
LEFT JOIN adhesions ON transactions.id = adhesions.idtransaction ORDER BY -id
;
"
)
for
row
in
cur
:
obj_dict
=
{
"
pk
"
:
row
[
"
id
"
],
# "pk": row["id"],
"
destination_id
"
:
map_idbde
[
row
[
"
destinataire
"
]],
"
source_id
"
:
map_idbde
[
row
[
"
emetteur
"
]],
"
created_at
"
:
make_aware
(
row
[
"
date
"
]),
"
amount
"
:
row
[
"
montant
"
],
"
quantity
"
:
row
[
"
quantite
"
],
"
reason
"
:
row
[
"
description
"
],
"
valid
"
:
row
[
"
valide
"
],
}
if
row
[
"
type
"
]
==
"
bouton
"
:
cat_name
=
row
[
"
categorie
"
]
if
cat_name
==
None
:
cat_name
=
'
None
'
cat
,
created
=
TemplateCategory
.
objects
.
get_or_create
(
name
=
cat_name
)
if
created
:
cat
.
save
()
obj_dict
[
"
category
"
]
=
cat
transac
=
TemplateTransaction
.
objects
.
create
(
**
obj_dict
)
transac
.
save
()
elif
row
[
"
type
"
]
==
"
adhésion
"
:
else
:
@transaction.atomic
def
import_aliases
(
cur
,
map_idbde
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment