forked from shaba/openuds
Fixed calendar actions typo & added calencat action "ignore unused"
This commit is contained in:
parent
f888d1da61
commit
099c0d9861
@ -36,7 +36,7 @@ import typing
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from uds.models import Calendar
|
||||
from uds.models import Calendar, CalendarAction
|
||||
from uds.models.calendar_action import CALENDAR_ACTION_DICT
|
||||
from uds.core.util import log, permissions
|
||||
from uds.core.util.model import processUuid
|
||||
@ -45,7 +45,7 @@ from uds.REST.model import DetailHandler
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.models import CalendarAccess, CalendarAction, ServicePool
|
||||
from uds.models import CalendarAccess, ServicePool
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -145,7 +145,7 @@ class ActionsCalendars(DetailHandler):
|
||||
try:
|
||||
if item is None:
|
||||
return [ActionsCalendars.as_dict(i) for i in parent.calendaraction_set.all()]
|
||||
i = parent.calendaraction_set.objects.get(uuid=processUuid(item))
|
||||
i = parent.calendaraction_set.get(uuid=processUuid(item))
|
||||
return ActionsCalendars.as_dict(i)
|
||||
except Exception:
|
||||
raise self.invalidItemException()
|
||||
|
@ -44,7 +44,8 @@ from uds.models.calendar_action import (
|
||||
CALENDAR_ACTION_ADD_TRANSPORT,
|
||||
CALENDAR_ACTION_DEL_TRANSPORT,
|
||||
CALENDAR_ACTION_ADD_GROUP,
|
||||
CALENDAR_ACTION_DEL_GROUP
|
||||
CALENDAR_ACTION_DEL_GROUP,
|
||||
CALENDAR_ACTION_IGNORE_UNUSED,
|
||||
)
|
||||
|
||||
from uds.core.managers import userServiceManager
|
||||
@ -457,6 +458,9 @@ class ServicesPools(ModelHandler):
|
||||
|
||||
# Transport & groups actions
|
||||
validActions += (CALENDAR_ACTION_ADD_TRANSPORT, CALENDAR_ACTION_DEL_TRANSPORT, CALENDAR_ACTION_ADD_GROUP, CALENDAR_ACTION_DEL_GROUP)
|
||||
|
||||
# Advanced actions
|
||||
validActions += (CALENDAR_ACTION_IGNORE_UNUSED,)
|
||||
return validActions
|
||||
|
||||
def listAssignables(self, item: ServicePool) -> typing.Any:
|
||||
|
@ -65,13 +65,16 @@ CALENDAR_ACTION_ADD_TRANSPORT = {'id': 'ADD_TRANSPORT', 'description': _('Add a
|
||||
CALENDAR_ACTION_DEL_TRANSPORT = {'id': 'REMOVE_TRANSPORT', 'description': _('Remove a transport'), 'params': ({'type': 'transport', 'name': 'transport', 'description': _('Trasport'), 'default': ''},)}
|
||||
CALENDAR_ACTION_ADD_GROUP = {'id': 'ADD_GROUP', 'description': _('Add a group'), 'params': ({'type': 'group', 'name': 'group', 'description': _('Group'), 'default': ''},)}
|
||||
CALENDAR_ACTION_DEL_GROUP = {'id': 'REMOVE_GROUP', 'description': _('Remove a group'), 'params': ({'type': 'group', 'name': 'group', 'description': _('Group'), 'default': ''},)}
|
||||
CALENDAR_ACTION_IGNORE_UNUSED = {'id': 'IGNORE_UNUSED', 'description': _('Sets the ignore unused'), 'params': ({'type': 'bool', 'name': 'state', 'description': _('Ignore assigned and unused'), 'default': False},)}
|
||||
|
||||
|
||||
CALENDAR_ACTION_DICT: typing.Dict[str, typing.Dict] = {c['id']: c for c in (
|
||||
CALENDAR_ACTION_PUBLISH, CALENDAR_ACTION_CACHE_L1,
|
||||
CALENDAR_ACTION_CACHE_L2, CALENDAR_ACTION_INITIAL,
|
||||
CALENDAR_ACTION_MAX,
|
||||
CALENDAR_ACTION_ADD_TRANSPORT, CALENDAR_ACTION_DEL_TRANSPORT,
|
||||
CALENDAR_ACTION_ADD_GROUP, CALENDAR_ACTION_DEL_GROUP
|
||||
CALENDAR_ACTION_ADD_GROUP, CALENDAR_ACTION_DEL_GROUP,
|
||||
CALENDAR_ACTION_IGNORE_UNUSED
|
||||
)}
|
||||
|
||||
|
||||
@ -133,7 +136,7 @@ class CalendarAction(UUIDModel):
|
||||
logger.exception('error')
|
||||
return '(invalid action)'
|
||||
|
||||
def execute(self, save: bool = True) -> None: # pylinf: disable=too-many-branches, too-many-statements
|
||||
def execute(self, save: bool = True) -> None: # pylint: disable=too-many-branches, too-many-statements
|
||||
"""Executes the calendar action
|
||||
|
||||
Keyword Arguments:
|
||||
@ -166,6 +169,8 @@ class CalendarAction(UUIDModel):
|
||||
self.service_pool.publish(changeLog='Scheduled publication action')
|
||||
saveServicePool = False
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_IGNORE_UNUSED['id'] == self.action:
|
||||
self.service_pool.ignores_unused = params['state'] in ('true', '1', True)
|
||||
else:
|
||||
caTransports = (CALENDAR_ACTION_ADD_TRANSPORT['id'], CALENDAR_ACTION_DEL_TRANSPORT['id'])
|
||||
caGroups = (CALENDAR_ACTION_ADD_GROUP['id'], CALENDAR_ACTION_DEL_GROUP['id'])
|
||||
|
File diff suppressed because one or more lines are too long
@ -92,6 +92,6 @@
|
||||
</svg>
|
||||
</div>
|
||||
</uds-root>
|
||||
<script src="/uds/res/admin/runtime.js?stamp=1577100525" defer></script><script src="/uds/res/admin/polyfills-es5.js?stamp=1577100525" nomodule defer></script><script src="/uds/res/admin/polyfills.js?stamp=1577100525" defer></script><script src="/uds/res/admin/main.js?stamp=1577100525" defer></script></body>
|
||||
<script src="/uds/res/admin/runtime.js?stamp=1579171989" defer></script><script src="/uds/res/admin/polyfills-es5.js?stamp=1579171989" nomodule defer></script><script src="/uds/res/admin/polyfills.js?stamp=1579171989" defer></script><script src="/uds/res/admin/main.js?stamp=1579171989" defer></script></body>
|
||||
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user