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
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
Felix Blanke
AKPlanning
Commits
8fb86109
Commit
8fb86109
authored
4 years ago
by
Nadja Geisler
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature-next-event' into 'master'
Improve event pre-population in admin views Closes
#62
See merge request
!26
parents
0d7f7870
f9032ffe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AKModel/models.py
+10
-3
10 additions, 3 deletions
AKModel/models.py
with
10 additions
and
3 deletions
AKModel/models.py
+
10
−
3
View file @
8fb86109
import
datetime
from
datetime
import
timedelta
from
django.utils.datetime_safe
import
datetime
import
itertools
import
itertools
from
django.db
import
models
from
django.db
import
models
...
@@ -47,7 +49,12 @@ class Event(models.Model):
...
@@ -47,7 +49,12 @@ class Event(models.Model):
@staticmethod
@staticmethod
def
get_next_active
():
def
get_next_active
():
return
Event
.
objects
.
filter
(
active
=
True
).
order_by
(
'
start
'
).
first
()
# Get first active event taking place
event
=
Event
.
objects
.
filter
(
active
=
True
).
order_by
(
'
start
'
).
first
()
# No active event? Return the next event taking place
if
event
is
None
:
event
=
Event
.
objects
.
order_by
(
'
start
'
).
filter
(
start__gt
=
datetime
.
now
()).
first
()
return
event
class
AKOwner
(
models
.
Model
):
class
AKOwner
(
models
.
Model
):
...
@@ -313,7 +320,7 @@ class AKSlot(models.Model):
...
@@ -313,7 +320,7 @@ class AKSlot(models.Model):
"""
"""
Retrieve end time of the AK slot
Retrieve end time of the AK slot
"""
"""
return
self
.
start
+
datetime
.
timedelta
(
hours
=
float
(
self
.
duration
))
return
self
.
start
+
timedelta
(
hours
=
float
(
self
.
duration
))
@property
@property
def
seconds_since_last_update
(
self
):
def
seconds_since_last_update
(
self
):
...
...
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