SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
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
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
SciPost
SciPost
Commits
adaa107f
Commit
adaa107f
authored
11 months ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
improve notes admin page
parent
717996ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost_django/pins/admin.py
+21
-3
21 additions, 3 deletions
scipost_django/pins/admin.py
scipost_django/pins/views.py
+1
-1
1 addition, 1 deletion
scipost_django/pins/views.py
with
22 additions
and
4 deletions
scipost_django/pins/admin.py
+
21
−
3
View file @
adaa107f
...
@@ -2,13 +2,22 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
...
@@ -2,13 +2,22 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__
=
"
AGPL v3
"
__license__
=
"
AGPL v3
"
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
reverse
from
django.utils.html
import
format_html
from
pins.models
import
Note
from
pins.models
import
Note
@admin.register
(
Note
)
@admin.register
(
Note
)
class
NoteAdmin
(
admin
.
ModelAdmin
):
class
NoteAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
"
id
"
,
"
regarding__object
"
,
"
title
"
,
"
author
"
,
"
created
"
,
"
modified
"
)
list_display
=
(
"
id
"
,
"
regarding_object_links
"
,
"
title
"
,
"
author
"
,
"
created
"
,
"
modified
"
,
)
list_filter
=
(
"
created
"
,
"
modified
"
,
"
visibility
"
,
"
regarding_content_type
"
)
list_filter
=
(
"
created
"
,
"
modified
"
,
"
visibility
"
,
"
regarding_content_type
"
)
search_fields
=
(
"
title
"
,
"
author__username
"
)
search_fields
=
(
"
title
"
,
"
author__username
"
)
date_hierarchy
=
"
created
"
date_hierarchy
=
"
created
"
...
@@ -25,5 +34,14 @@ class NoteAdmin(admin.ModelAdmin):
...
@@ -25,5 +34,14 @@ class NoteAdmin(admin.ModelAdmin):
)
)
autocomplete_fields
=
(
"
author
"
,)
autocomplete_fields
=
(
"
author
"
,)
def
regarding__object
(
self
,
obj
):
def
regarding_object_links
(
self
,
obj
):
return
str
(
obj
.
regarding
)
content_type
=
obj
.
regarding_content_type
model
=
content_type
.
model_class
()
regarding
=
model
.
objects
.
get
(
pk
=
obj
.
regarding_object_id
)
admin_url
=
f
"
admin:
{
content_type
.
app_label
}
_
{
content_type
.
model
}
_change
"
return
format_html
(
"
<div style=
'
display: flex; justify-content:space-between;>
"
f
'
<a href=
"
{
regarding
.
get_absolute_url
()
}
"
>
{
regarding
}
</a>
'
f
'
<a href=
"
{
reverse
(
admin_url
,
args
=
[
obj
.
regarding_object_id
])
}
"
>[admin]</a>
'
"
</div>
"
)
This diff is collapsed.
Click to expand it.
scipost_django/pins/views.py
+
1
−
1
View file @
adaa107f
...
@@ -70,7 +70,7 @@ def _hx_notes_list(request, regarding_content_type, regarding_object_id):
...
@@ -70,7 +70,7 @@ def _hx_notes_list(request, regarding_content_type, regarding_object_id):
can_create_notes
=
request
.
user
.
has_perm
(
"
pins.can_add_notes
"
)
can_create_notes
=
request
.
user
.
has_perm
(
"
pins.can_add_notes
"
)
# Filter according to the visibility of the notes
# Filter according to the visibility of the notes
notes
=
notes
.
visible_to
(
request
.
user
,
object
)
notes
=
notes
.
visible_to
(
request
.
user
,
object
.
__class__
)
context
=
{
context
=
{
"
object
"
:
object
,
"
object
"
:
object
,
...
...
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