Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
5
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
3a6d39a5
Unverified
Commit
3a6d39a5
authored
5 years ago
by
me5na7qbjqbrp
Browse files
Options
Downloads
Patches
Plain Diff
Note admin fully implemented
parent
1bfcedd4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7633
failed with stage
in 2 minutes and 24 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
note/admin.py
+39
-8
39 additions, 8 deletions
note/admin.py
note/models/transactions.py
+2
-2
2 additions, 2 deletions
note/models/transactions.py
with
41 additions
and
10 deletions
note/admin.py
+
39
−
8
View file @
3a6d39a5
...
...
@@ -3,8 +3,9 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from
django.contrib
import
admin
from
polymorphic.admin
import
PolymorphicParentModelAdmin
,
\
PolymorphicChildModelAdmin
,
PolymorphicChildModelFilter
from
django.utils.translation
import
gettext_lazy
as
_
from
polymorphic.admin
import
PolymorphicChildModelAdmin
,
\
PolymorphicChildModelFilter
,
PolymorphicParentModelAdmin
from
.models.notes
import
Alias
,
Note
,
NoteClub
,
NoteSpecial
,
NoteUser
from
.models.transactions
import
MembershipTransaction
,
Transaction
,
\
...
...
@@ -93,16 +94,46 @@ class NoteUserAdmin(PolymorphicChildModelAdmin):
return
False
@admin.register
(
Transaction
)
class
TransactionAdmin
(
admin
.
ModelAdmin
):
"""
Admin customisation for Transaction
"""
list_display
=
(
'
created_at
'
,
'
poly_source
'
,
'
poly_destination
'
,
'
quantity
'
,
'
amount
'
,
'
transaction_type
'
,
'
valid
'
)
list_filter
=
(
'
transaction_type
'
,
'
valid
'
)
autocomplete_fields
=
(
'
source
'
,
'
destination
'
,)
def
poly_source
(
self
,
obj
):
"""
Force source to resolve polymorphic object
"""
return
str
(
obj
.
source
)
poly_source
.
short_description
=
_
(
'
source
'
)
def
poly_destination
(
self
,
obj
):
"""
Force destination to resolve polymorphic object
"""
return
str
(
obj
.
destination
)
poly_destination
.
short_description
=
_
(
'
destination
'
)
@admin.register
(
TransactionTemplate
)
class
TransactionTemplateAdmin
(
admin
.
ModelAdmin
):
"""
Admin customisation for TransactionTemplate
"""
list_display
=
(
'
name
'
,
'
destination
'
,
'
amount
'
,
'
template_type
'
)
list_filter
=
(
'
destination
'
,
'
template_type
'
,)
#
autocomplete_fields = ('destination',)
list_display
=
(
'
name
'
,
'
poly_
destination
'
,
'
amount
'
,
'
template_type
'
)
list_filter
=
(
'
template_type
'
,)
autocomplete_fields
=
(
'
destination
'
,)
def
poly_destination
(
self
,
obj
):
"""
Force destination to resolve polymorphic object
"""
return
str
(
obj
.
destination
)
# Register other models here.
admin
.
site
.
register
(
MembershipTransaction
)
admin
.
site
.
register
(
Transaction
)
poly_destination
.
short_description
=
_
(
'
destination
'
)
This diff is collapsed.
Click to expand it.
note/models/transactions.py
+
2
−
2
View file @
3a6d39a5
...
...
@@ -51,8 +51,8 @@ class Transaction(models.Model):
related_name
=
'
+
'
,
verbose_name
=
_
(
'
destination
'
),
)
datetime
=
models
.
DateTimeField
(
verbose_name
=
_
(
'
destination
'
),
created_at
=
models
.
DateTimeField
(
verbose_name
=
_
(
'
created at
'
),
default
=
timezone
.
now
,
)
quantity
=
models
.
PositiveSmallIntegerField
(
...
...
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