Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
83abbb5f
Verified
Commit
83abbb5f
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Move unread notifications query set to a property of the person object
parent
e3d82618
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!447
Resolve "Add own menu entry for notifications"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/models.py
+10
-0
10 additions, 0 deletions
aleksis/core/models.py
aleksis/core/util/core_helpers.py
+1
-1
1 addition, 1 deletion
aleksis/core/util/core_helpers.py
with
11 additions
and
1 deletion
aleksis/core/models.py
+
10
−
0
View file @
83abbb5f
...
...
@@ -245,6 +245,16 @@ class Person(ExtensibleModel):
)
]
@property
def
unread_notifications
(
self
)
->
QuerySet
:
"""
Get all unread notifications for this person.
"""
return
self
.
notifications
.
filter
(
read
=
False
)
@property
def
unread_notifications_count
(
self
)
->
int
:
"""
Return the count of unread notifications for this person.
"""
return
self
.
unread_notifications
.
count
()
def
save
(
self
,
*
args
,
**
kwargs
):
super
().
save
(
*
args
,
**
kwargs
)
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/util/core_helpers.py
+
1
−
1
View file @
83abbb5f
...
...
@@ -408,4 +408,4 @@ def queryset_rules_filter(
def
unread_notifications_badge
(
request
:
HttpRequest
)
->
int
:
"""
Generate badge content with the number of unread notifications.
"""
return
request
.
user
.
person
.
notifications
.
all
().
filter
(
read
=
False
).
count
()
return
request
.
user
.
person
.
unread_
notifications
_
count
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