Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
31
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Commits
093e585b
Commit
093e585b
authored
5 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
We don't need to create proxies for special transactions that don't require a remittance
parent
4cf1047f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!61
Tresorerie
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/treasury/apps.py
+8
-2
8 additions, 2 deletions
apps/treasury/apps.py
apps/treasury/signals.py
+2
-2
2 additions, 2 deletions
apps/treasury/signals.py
with
10 additions
and
4 deletions
apps/treasury/apps.py
+
8
−
2
View file @
093e585b
...
...
@@ -2,8 +2,10 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from
django.apps
import
AppConfig
from
django.db.models
import
Q
from
django.db.models.signals
import
post_save
,
post_migrate
from
django.utils.translation
import
gettext_lazy
as
_
from
note.models
import
NoteSpecial
class
TreasuryConfig
(
AppConfig
):
...
...
@@ -21,8 +23,12 @@ class TreasuryConfig(AppConfig):
post_save
.
connect
(
signals
.
save_special_transaction
,
sender
=
SpecialTransaction
)
def
setup_specialtransactions_proxies
(
**
kwargs
):
# If the treasury app was disabled, we ensure that each special transaction is linked to a proxy
for
transaction
in
SpecialTransaction
.
objects
.
filter
(
specialtransactionproxy
=
None
):
# If the treasury app was disabled for any reason during a certain amount of time,
# we ensure that each special transaction is linked to a proxy
for
transaction
in
SpecialTransaction
.
objects
.
filter
(
source__in
=
NoteSpecial
.
objects
.
filter
(
~
Q
(
remittancetype
=
None
)),
specialtransactionproxy
=
None
,
):
SpecialTransactionProxy
.
objects
.
create
(
transaction
=
transaction
,
remittance
=
None
)
post_migrate
.
connect
(
setup_specialtransactions_proxies
,
sender
=
SpecialTransactionProxy
)
This diff is collapsed.
Click to expand it.
apps/treasury/signals.py
+
2
−
2
View file @
093e585b
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from
treasury.models
import
SpecialTransactionProxy
from
treasury.models
import
SpecialTransactionProxy
,
RemittanceType
def
save_special_transaction
(
instance
,
created
,
**
kwargs
):
"""
When a special transaction is created, we create its linked proxy
"""
if
created
:
if
created
and
RemittanceType
.
objects
.
filter
(
note
=
instance
.
source
).
exists
()
:
SpecialTransactionProxy
.
objects
.
create
(
transaction
=
instance
,
remittance
=
None
).
save
()
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