Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
AURA
steering
Commits
f8e44af7
Verified
Commit
f8e44af7
authored
8 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: update inline admin for CBA
parent
5b8c6db5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/admin.py
+12
-11
12 additions, 11 deletions
program/admin.py
with
12 additions
and
11 deletions
program/admin.py
+
12
−
11
View file @
f8e44af7
...
...
@@ -7,6 +7,7 @@ from django.contrib.auth.models import User
from
django.db.models
import
JSONField
from
django.utils.safestring
import
mark_safe
from
program.models
import
(
CBA
,
Category
,
FundingCategory
,
Host
,
...
...
@@ -18,7 +19,6 @@ from program.models import (
RRule
,
Topic
,
Type
,
UserProfile
,
)
...
...
@@ -58,19 +58,20 @@ class RRuleAdmin(admin.ModelAdmin):
list_display
=
(
"
name
"
,
"
freq
"
,
"
interval
"
,
"
by_set_pos
"
,
"
by_weekdays
"
,
"
count
"
)
class
UserProfile
Inline
(
admin
.
StackedInline
):
model
=
UserProfile
fields
=
(
"
cba_
username
"
,
"
cba_
user_token
"
)
class
CBA
Inline
(
admin
.
StackedInline
):
model
=
CBA
fields
=
(
"
username
"
,
"
user_token
"
)
can_delete
=
False
verbose_name_plural
=
"
Profile
"
verbose_name
=
"
CBA
"
verbose_name_plural
=
"
CBA
"
fk_name
=
"
user
"
class
User
ProfileUser
Admin
(
UserAdmin
):
inlines
=
(
UserProfile
Inline
,)
class
User
CBA
Admin
(
UserAdmin
):
inlines
=
(
CBA
Inline
,)
def
get_queryset
(
self
,
request
):
"""
Let common users only edit their own
profile
"""
"""
Let common users only edit their own
CBA.
"""
if
not
request
.
user
.
is_superuser
:
return
super
(
UserAdmin
,
self
).
get_queryset
(
request
).
filter
(
pk
=
request
.
user
.
id
)
...
...
@@ -92,15 +93,15 @@ class UserProfileUserAdmin(UserAdmin):
return
list
()
def
get_inline_instances
(
self
,
request
,
obj
=
None
):
"""
Append
profile
fields to UserAdmin
"""
"""
Append
CBA
fields to UserAdmin
"""
if
not
obj
:
return
list
()
return
super
(
User
ProfileUser
Admin
,
self
).
get_inline_instances
(
request
,
obj
)
return
super
(
User
CBA
Admin
,
self
).
get_inline_instances
(
request
,
obj
)
admin
.
site
.
unregister
(
User
)
admin
.
site
.
register
(
User
,
User
ProfileUser
Admin
)
admin
.
site
.
register
(
User
,
User
CBA
Admin
)
@admin.register
(
RadioSettings
)
...
...
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