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
7f695bad
Commit
7f695bad
authored
4 months ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Add success and failure messages
parent
3fad6919
No related branches found
No related tags found
1 merge request
!8
Avoid setting the slot duration at import
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
AKModel/models.py
+4
-1
4 additions, 1 deletion
AKModel/models.py
AKModel/views/ak.py
+1
-1
1 addition, 1 deletion
AKModel/views/ak.py
AKModel/views/manage.py
+13
-1
13 additions, 1 deletion
AKModel/views/manage.py
with
18 additions
and
3 deletions
AKModel/models.py
+
4
−
1
View file @
7f695bad
...
...
@@ -383,7 +383,7 @@ class Event(models.Model):
)
@transaction.atomic
def
schedule_from_json
(
self
,
schedule
:
str
)
->
None
:
def
schedule_from_json
(
self
,
schedule
:
str
)
->
int
:
"""
Load AK schedule from a json string.
:param schedule: A string that can be decoded to json, describing
...
...
@@ -401,6 +401,7 @@ class Event(models.Model):
for
timeslot
in
block
}
slots_updated
=
0
for
scheduled_slot
in
schedule
[
"
scheduled_aks
"
]:
scheduled_slot
[
"
timeslot_ids
"
]
=
list
(
map
(
int
,
scheduled_slot
[
"
timeslot_ids
"
]))
start_timeslot
=
timeslot_dict
[
min
(
scheduled_slot
[
"
timeslot_ids
"
])].
avail
...
...
@@ -414,6 +415,8 @@ class Event(models.Model):
assert
solver_duration
+
1e-4
>=
slot
.
duration
slot
.
save
()
slots_updated
+=
1
return
slots_updated
class
AKOwner
(
models
.
Model
):
"""
An AKOwner describes the person organizing/holding an AK.
...
...
This diff is collapsed.
Click to expand it.
AKModel/views/ak.py
+
1
−
1
View file @
7f695bad
...
...
@@ -61,7 +61,7 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
def
_test_ak_fixed_in_slot
(
self
,
ak_id
,
slot
:
Availability
,
ak_fixed
:
dict
)
->
bool
:
"""
Test if AK defined by `ak_id` is fixed to happen during slot.
"""
if
not
ak_id
in
ak_fixed
:
if
ak_id
not
in
ak_fixed
:
return
False
fixed_slot
=
Availability
(
self
.
event
,
start
=
ak_fixed
[
ak_id
].
start
,
end
=
ak_fixed
[
ak_id
].
end
)
...
...
This diff is collapsed.
Click to expand it.
AKModel/views/manage.py
+
13
−
1
View file @
7f695bad
...
...
@@ -257,6 +257,18 @@ class AKScheduleJSONImportView(EventSlugMixin, IntermediateAdminView):
title
=
_
(
"
AK Schedule JSON Import
"
)
def
form_valid
(
self
,
form
):
self
.
event
.
schedule_from_json
(
form
.
data
[
"
json_data
"
])
try
:
number_of_slots_changed
=
self
.
event
.
schedule_from_json
(
form
.
data
[
"
json_data
"
])
messages
.
add_message
(
self
.
request
,
messages
.
SUCCESS
,
_
(
"
Successfully imported {n} slot(s)
"
).
format
(
n
=
number_of_slots_changed
)
)
except
ValueError
as
ex
:
messages
.
add_message
(
self
.
request
,
messages
.
ERROR
,
_
(
"
Importing an AK schedule failed! Reason:
"
)
+
str
(
ex
),
)
return
redirect
(
"
admin:event_status
"
,
self
.
event
.
slug
)
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