Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
KIF
AKPlanning
Commits
3ee08b9a
Commit
3ee08b9a
authored
2 months ago
by
Benjamin Hättasch
Browse files
Options
Downloads
Patches
Plain Diff
Fix code quality issues
parent
869ec34f
Branches
Branches containing commit
No related tags found
1 merge request
!242
Admin interface improvements
Pipeline
#274448
passed
2 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AKModel/admin.py
+19
-2
19 additions, 2 deletions
AKModel/admin.py
AKScheduling/views.py
+3
-1
3 additions, 1 deletion
AKScheduling/views.py
with
22 additions
and
3 deletions
AKModel/admin.py
+
19
−
2
View file @
3ee08b9a
...
...
@@ -3,7 +3,7 @@ from django.apps import apps
from
django.contrib
import
admin
,
messages
from
django.contrib.admin
import
SimpleListFilter
,
RelatedFieldListFilter
,
action
,
display
from
django.contrib.auth.admin
import
UserAdmin
as
BaseUserAdmin
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
# pylint: disable=E5142
from
django.db.models
import
Count
,
F
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
render
,
redirect
...
...
@@ -574,20 +574,37 @@ class DefaultSlotAdmin(EventTimezoneFormMixin, admin.ModelAdmin):
# Define a new User admin
class
UserAdmin
(
BaseUserAdmin
):
"""
Admin interface for Users
Enhances the built-in UserAdmin with additional actions to activate and deactivate users and a custom selection
of displayed properties in overview list
"""
list_display
=
[
"
username
"
,
"
email
"
,
"
is_active
"
,
"
is_staff
"
,
"
is_superuser
"
]
actions
=
[
'
activate
'
,
'
deactivate
'
]
@admin.action
(
description
=
_
(
"
Activate selected users
"
))
def
activate
(
self
,
request
,
queryset
):
"""
Bulk activate users
:param request: HTTP request
:param queryset: queryset containing all users that should be activated
"""
queryset
.
update
(
is_active
=
True
)
self
.
message_user
(
request
,
_
(
"
The selected users have been activated.
"
))
@admin.action
(
description
=
_
(
"
Deactivate selected users
"
))
def
deactivate
(
self
,
request
,
queryset
):
"""
Bulk deactivate users
:param request: HTTP request
:param queryset: queryset containing all users that should be deactivated
"""
queryset
.
update
(
is_active
=
False
)
self
.
message_user
(
request
,
_
(
"
The selected users have been deactivated.
"
))
# Re-register UserAdmin
admin
.
site
.
unregister
(
User
)
admin
.
site
.
register
(
User
,
UserAdmin
)
\ No newline at end of file
admin
.
site
.
register
(
User
,
UserAdmin
)
This diff is collapsed.
Click to expand it.
AKScheduling/views.py
+
3
−
1
View file @
3ee08b9a
...
...
@@ -41,7 +41,9 @@ class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
context_object_name
=
"
slots_unscheduled
"
def
get_queryset
(
self
):
return
super
().
get_queryset
().
filter
(
start__isnull
=
True
).
select_related
(
'
event
'
,
'
ak
'
,
'
ak__track
'
,
'
ak__category
'
).
prefetch_related
(
'
ak__types
'
,
'
ak__owners
'
,
'
ak__conflicts
'
,
'
ak__prerequisites
'
,
'
ak__requirements
'
).
order_by
(
'
ak__track
'
,
'
ak
'
)
return
super
().
get_queryset
().
filter
(
start__isnull
=
True
).
select_related
(
'
event
'
,
'
ak
'
,
'
ak__track
'
,
'
ak__category
'
).
prefetch_related
(
'
ak__types
'
,
'
ak__owners
'
,
'
ak__conflicts
'
,
'
ak__prerequisites
'
,
'
ak__requirements
'
).
order_by
(
'
ak__track
'
,
'
ak
'
)
def
get_context_data
(
self
,
*
,
object_list
=
None
,
**
kwargs
):
context
=
super
().
get_context_data
(
object_list
=
object_list
,
**
kwargs
)
...
...
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