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
Compare revisions
4984159a61642a0d3668e85daf39472b59b86447 to 169895a825d0ea670682a6e718b719d91807e1f9
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
bde/nk20-scripts
Select target project
No results found
169895a825d0ea670682a6e718b719d91807e1f9
Select Git revision
Branches
borg_backup
master
merge_club
notes_report
Swap
Target
bde/nk20-scripts
Select target project
bde/nk20-scripts
1 result
4984159a61642a0d3668e85daf39472b59b86447
Select Git revision
Branches
borg_backup
master
merge_club
notes_report
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
Import Société générale credits
· 169895a8
ynerant
authored
4 years ago
169895a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
management/commands/import_transaction.py
+27
-1
27 additions, 1 deletion
management/commands/import_transaction.py
with
27 additions
and
1 deletion
management/commands/import_transaction.py
View file @
169895a8
...
...
@@ -8,6 +8,7 @@ import pytz
import
datetime
import
copy
from
django.contrib.auth.models
import
User
from
django.utils.timezone
import
make_aware
from
django.db
import
transaction
from
django.contrib.contenttypes.models
import
ContentType
...
...
@@ -23,7 +24,7 @@ from note.models import Note, NoteClub
from
activity.models
import
Guest
,
GuestTransaction
,
Entry
from
member.models
import
Membership
from
treasury.models
import
Remittance
,
SpecialTransactionProxy
from
treasury.models
import
Remittance
,
SpecialTransactionProxy
,
SogeCredit
from
._import_utils
import
ImportCommand
,
BulkCreateManager
,
timed
MAP_TRANSACTION
=
dict
()
...
...
@@ -367,6 +368,30 @@ class Command(ImportCommand):
except
:
print
(
"
Failed to save row:
"
+
str
(
row
))
@timed
def
import_soge_credits
(
self
):
users
=
User
.
objects
.
filter
(
profile__registration_valid
=
True
).
order_by
(
'
pk
'
)
n
=
users
.
count
()
for
idx
,
user
in
enumerate
(
users
.
all
()):
self
.
update_line
(
idx
,
n
,
user
.
username
)
soge_credit_transaction
=
SpecialTransaction
.
objects
.
filter
(
reason__icontains
=
"
crédit sogé
"
,
destination_id
=
user
.
note
.
id
,
)
if
soge_credit_transaction
.
exists
():
soge_credit_transaction
=
soge_credit_transaction
.
get
()
soge_credit
=
SogeCredit
.
objects
.
create
(
user
=
user
,
credit_transaction
=
soge_credit_transaction
)
memberships
=
Membership
.
objects
.
filter
(
user
=
user
,
club_id__in
=
[
BDE_PK
,
KFET_PK
],
date_start__lte
=
soge_credit_transaction
.
created_at
,
date_end__gte
=
soge_credit_transaction
.
created_at
,
).
all
()
for
membership
in
memberships
:
soge_credit
.
transactions
.
add
(
membership
.
transaction
)
soge_credit
.
save
()
@timed
def
handle
(
self
,
*
args
,
**
kwargs
):
# default args, provided by ImportCommand.
...
...
@@ -383,3 +408,4 @@ class Command(ImportCommand):
self
.
set_roles
()
self
.
import_remittances
(
cur
,
kwargs
[
"
chunk
"
])
self
.
import_checks
(
cur
)
self
.
import_soge_credits
()
This diff is collapsed.
Click to expand it.