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
90ffaae2
Unverified
Commit
90ffaae2
authored
5 years ago
by
me5na7qbjqbrp
Browse files
Options
Downloads
Patches
Plain Diff
More models in admin
parent
eed5f4b5
No related branches found
No related tags found
1 merge request
!2
Not so atomic, sorry
Pipeline
#7629
passed with stage
in 2 minutes and 24 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
member/admin.py
+6
-1
6 additions, 1 deletion
member/admin.py
note/admin.py
+30
-0
30 additions, 0 deletions
note/admin.py
with
36 additions
and
1 deletion
member/admin.py
+
6
−
1
View file @
90ffaae2
...
@@ -7,7 +7,7 @@ from django.contrib.auth.admin import UserAdmin
...
@@ -7,7 +7,7 @@ from django.contrib.auth.admin import UserAdmin
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
.forms
import
CustomUserChangeForm
from
.forms
import
CustomUserChangeForm
from
.models
import
Club
,
Profile
from
.models
import
Club
,
Membership
,
Profile
,
Role
class
ProfileInline
(
admin
.
StackedInline
):
class
ProfileInline
(
admin
.
StackedInline
):
...
@@ -33,6 +33,11 @@ class CustomUserAdmin(UserAdmin):
...
@@ -33,6 +33,11 @@ class CustomUserAdmin(UserAdmin):
return
super
().
get_inline_instances
(
request
,
obj
)
return
super
().
get_inline_instances
(
request
,
obj
)
# Update Django User with profile
admin
.
site
.
unregister
(
User
)
admin
.
site
.
unregister
(
User
)
admin
.
site
.
register
(
User
,
CustomUserAdmin
)
admin
.
site
.
register
(
User
,
CustomUserAdmin
)
# Add other models
admin
.
site
.
register
(
Club
)
admin
.
site
.
register
(
Club
)
admin
.
site
.
register
(
Membership
)
admin
.
site
.
register
(
Role
)
This diff is collapsed.
Click to expand it.
note/admin.py
+
30
−
0
View file @
90ffaae2
...
@@ -26,6 +26,21 @@ class NoteClubAdmin(admin.ModelAdmin):
...
@@ -26,6 +26,21 @@ class NoteClubAdmin(admin.ModelAdmin):
list_filter
=
(
'
is_active
'
,)
list_filter
=
(
'
is_active
'
,)
search_fields
=
[
'
club__name
'
]
search_fields
=
[
'
club__name
'
]
# We can't change club after creation
readonly_fields
=
(
'
club
'
,)
def
has_add_permission
(
self
,
request
):
"""
A club note should not be manually added
"""
return
False
def
has_delete_permission
(
self
,
request
,
obj
=
None
):
"""
A club note should not be manually removed
"""
return
False
class
NoteSpecialAdmin
(
admin
.
ModelAdmin
):
class
NoteSpecialAdmin
(
admin
.
ModelAdmin
):
"""
"""
...
@@ -47,6 +62,21 @@ class NoteUserAdmin(admin.ModelAdmin):
...
@@ -47,6 +62,21 @@ class NoteUserAdmin(admin.ModelAdmin):
date_hierarchy
=
'
user__date_joined
'
date_hierarchy
=
'
user__date_joined
'
ordering
=
[
'
-user__date_joined
'
]
ordering
=
[
'
-user__date_joined
'
]
# We can't change user after creation
readonly_fields
=
(
'
user
'
,)
def
has_add_permission
(
self
,
request
):
"""
An user note should not be manually added
"""
return
False
def
has_delete_permission
(
self
,
request
,
obj
=
None
):
"""
An user note should not be manually removed
"""
return
False
class
TransactionTemplateAdmin
(
admin
.
ModelAdmin
):
class
TransactionTemplateAdmin
(
admin
.
ModelAdmin
):
"""
"""
...
...
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