2020-03-14 20:15:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from collections import OrderedDict
|
|
|
|
|
|
|
|
from rest_framework.response import Response
|
|
|
|
|
|
|
|
|
|
|
|
class TimerFieldSupportMixin:
|
|
|
|
def options(self, request, *args, **kwargs):
|
|
|
|
"""
|
|
|
|
Add information about the optional "timer" field.
|
|
|
|
"""
|
|
|
|
meta = self.metadata_class()
|
|
|
|
data = meta.determine_metadata(request, self)
|
2022-02-10 00:00:30 +00:00
|
|
|
post = data.get("actions").get("POST") # type: OrderedDict
|
|
|
|
post["timer"] = OrderedDict(
|
|
|
|
{
|
|
|
|
"type": "integer",
|
|
|
|
"required": False,
|
|
|
|
"read_only": False,
|
|
|
|
"label": "Timer",
|
|
|
|
"details": "ID for an existing Timer, may be used in place of the "
|
|
|
|
"`start`, `end`, and/or `child` fields. ",
|
|
|
|
}
|
|
|
|
)
|
2020-03-14 20:15:14 +00:00
|
|
|
details = "Required unless a value is provided in the `timer` field."
|
2022-02-10 00:00:30 +00:00
|
|
|
post["child"]["details"] = details
|
|
|
|
post["start"]["details"] = details
|
|
|
|
post["end"]["details"] = details
|
2020-03-14 20:15:14 +00:00
|
|
|
return Response(data)
|