Skip to content

Commit

Permalink
Change location of workshop defaults for training portal and deprecat…
Browse files Browse the repository at this point in the history
…ed old settings.
  • Loading branch information
GrahamDumpleton committed May 26, 2022
1 parent fb8616f commit 616f741
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,41 @@ spec:
type: integer
anonymous:
type: integer
#! Deprecated, use "workshop.defaults.capacity".
capacity:
type: integer
#! Deprecated, use "workshop.defaults.initial".
initial:
type: integer
#! Deprecated, use "workshop.defaults.reserved".
reserved:
type: integer
#! Deprecated, use "workshop.defaults.expires".
expires:
type: string
pattern: '^\d+(s|m|h)$'
#! Deprecated, use "workshop.defaults.orphaned".
orphaned:
type: string
pattern: '^\d+(s|m|h)$'
workshop:
type: object
properties:
defaults:
type: object
properties:
capacity:
type: integer
initial:
type: integer
reserved:
type: integer
expires:
type: string
pattern: '^\d+(s|m|h)$'
orphaned:
type: string
pattern: '^\d+(s|m|h)$'
theme:
type: object
properties:
Expand Down
25 changes: 20 additions & 5 deletions training-portal/src/project/apps/workshops/manager/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,26 @@ def process_training_portal(resource):
portal.sessions_registered = sessions_registered
portal.sessions_anonymous = sessions_anonymous

default_capacity = spec.get("portal.capacity", sessions_maximum)
default_reserved = spec.get("portal.reserved")
default_initial = spec.get("portal.initial", default_reserved)
default_expires = spec.get("portal.expires", "0")
default_orphaned = spec.get("portal.orphaned", "0")
# Workshop default settings now scoped under portal.workshop.defaults
# and old settings deprecated. Give precedence to new settings.

default_capacity = sessions_maximum
default_reserved = None
default_initial = None
default_expires = "0"
default_orphaned = "0"

default_capacity = spec.get("portal.capacity", default_capacity)
default_reserved = spec.get("portal.reserved", default_reserved)
default_initial = spec.get("portal.initial", default_initial)
default_expires = spec.get("portal.expires", default_expires)
default_orphaned = spec.get("portal.orphaned", default_orphaned)

default_capacity = spec.get("portal.workshop.defaults.capacity", default_capacity)
default_reserved = spec.get("portal.workshop.defaults.reserved", default_reserved)
default_initial = spec.get("portal.workshop.defaults.initial", default_initial)
default_expires = spec.get("portal.workshop.defaults.expires", default_expires)
default_orphaned = spec.get("portal.workshop.defaults.orphaned", default_orphaned)

portal.default_capacity = default_capacity
portal.default_reserved = default_reserved
Expand Down

0 comments on commit 616f741

Please sign in to comment.