Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomasDOTwtf
hub
Commits
e975f7bf
Commit
e975f7bf
authored
7 months ago
by
Roang
Browse files
Options
Downloads
Patches
Plain Diff
Add event list annotations
- Add upcoming annotation to events
parent
ed25a079
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plainui/views/utils.py
+11
-3
11 additions, 3 deletions
src/plainui/views/utils.py
with
11 additions
and
3 deletions
src/plainui/views/utils.py
+
11
−
3
View file @
e975f7bf
...
@@ -6,7 +6,8 @@ from django.conf import settings
...
@@ -6,7 +6,8 @@ from django.conf import settings
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.auth
import
mixins
as
auth_mixins
from
django.contrib.auth
import
mixins
as
auth_mixins
from
django.core.exceptions
import
ImproperlyConfigured
,
ValidationError
from
django.core.exceptions
import
ImproperlyConfigured
,
ValidationError
from
django.db.models
import
F
,
Prefetch
,
Q
from
django.db.models
import
Case
,
F
,
Prefetch
,
Q
,
When
from
django.forms
import
BooleanField
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
from
django.urls
import
reverse
from
django.urls
import
reverse
...
@@ -215,9 +216,16 @@ def event_filter(
...
@@ -215,9 +216,16 @@ def event_filter(
events
=
Event
.
objects
.
conference_accessible
(
conf
)
events
=
Event
.
objects
.
conference_accessible
(
conf
)
events
=
events
.
filter
(
schedule_start__isnull
=
False
,
schedule_end__isnull
=
False
)
events
=
events
.
filter
(
schedule_start__isnull
=
False
,
schedule_end__isnull
=
False
)
if
upcoming
:
now
=
timezone
.
now
()
now
=
timezone
.
now
()
events
=
events
.
filter
(
Q
(
schedule_start__lt
=
now
,
schedule_end__gte
=
now
)
|
Q
(
schedule_start__gte
=
now
,
schedule_start__lt
=
now
+
UPCOMING_WINDOW
))
events
=
events
.
annotate
(
upcoming
=
Case
(
When
(
Q
(
schedule_start__lt
=
now
,
schedule_end__gte
=
now
)
|
Q
(
schedule_start__gte
=
now
,
schedule_start__lt
=
now
+
UPCOMING_WINDOW
)),
default
=
False
,
output_field
=
BooleanField
(),
)
)
if
upcoming
:
events
=
events
.
filter
(
upcoming
=
True
)
if
calendar_mode
:
if
calendar_mode
:
events
=
events
.
filter
(
room__isnull
=
False
)
events
=
events
.
filter
(
room__isnull
=
False
)
res
=
events
.
filter
(
schedule_duration__isnull
=
False
,
**
filters
).
order_by
(
'
schedule_start
'
,
'
schedule_end
'
)
res
=
events
.
filter
(
schedule_duration__isnull
=
False
,
**
filters
).
order_by
(
'
schedule_start
'
,
'
schedule_end
'
)
...
...
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