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
073a07d1
Verified
Commit
073a07d1
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Make filter methods for announcements more intuitive
parent
7abf8e9d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!184
Improve announcement queries
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/models.py
+3
-6
3 additions, 6 deletions
aleksis/core/models.py
aleksis/core/views.py
+1
-1
1 addition, 1 deletion
aleksis/core/views.py
with
4 additions
and
7 deletions
aleksis/core/models.py
+
3
−
6
View file @
073a07d1
...
...
@@ -312,15 +312,12 @@ class AnnouncementQuerySet(models.QuerySet):
return
announcements
def
for_person_at_time
(
self
,
person
:
Person
,
when
:
Optional
[
datetime
]
=
None
)
->
List
:
"""
Get all announcements for one person at a certain time
"""
# Get announcements by time
announcements
=
self
.
at_time
(
when
)
def
for_person
(
self
,
person
:
Person
)
->
List
:
"""
Get all announcements for one person
"""
# Filter by person
announcements_for_person
=
[]
for
announcement
in
announcements
:
for
announcement
in
self
:
if
person
in
announcement
.
recipient_persons
:
announcements_for_person
.
append
(
announcement
)
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/views.py
+
1
−
1
View file @
073a07d1
...
...
@@ -34,7 +34,7 @@ def index(request: HttpRequest) -> HttpResponse:
context
[
"
notifications
"
]
=
notifications
context
[
"
unread_notifications
"
]
=
unread_notifications
announcements
=
Announcement
.
objects
.
for_person
_at_time
(
request
.
user
.
person
)
announcements
=
Announcement
.
objects
.
at_time
().
for_person
(
request
.
user
.
person
)
context
[
"
announcements
"
]
=
announcements
widgets
=
DashboardWidget
.
objects
.
filter
(
active
=
True
)
...
...
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