PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/indico/MaKaC/plugins/Collaboration/CERNMCU/services.py

https://github.com/davidmorrison/indico
Python | 61 lines | 31 code | 11 blank | 19 comment | 6 complexity | 608dc795962b61d81b683f74c5d88f92 MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. ##
  3. ##
  4. ## This file is part of CDS Indico.
  5. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
  6. ##
  7. ## CDS Indico is free software; you can redistribute it and/or
  8. ## modify it under the terms of the GNU General Public License as
  9. ## published by the Free Software Foundation; either version 2 of the
  10. ## License, or (at your option) any later version.
  11. ##
  12. ## CDS Indico is distributed in the hope that it will be useful, but
  13. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. ## General Public License for more details.
  16. ##
  17. ## You should have received a copy of the GNU General Public License
  18. ## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
  19. ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  20. from MaKaC.services.implementation.collaboration import CollaborationPluginServiceBase,\
  21. CollaborationPluginServiceBookingModifBase
  22. from MaKaC.plugins.Collaboration.CERNMCU.common import CERNMCUException, CERNMCUError
  23. from MaKaC.i18n import _
  24. from MaKaC.common.fossilize import fossilize
  25. from MaKaC.plugins.Collaboration.fossils import ICSBookingBaseConfModifFossil
  26. class ParticipantServiceBase(CollaborationPluginServiceBookingModifBase):
  27. def __init__(self, params, aw):
  28. CollaborationPluginServiceBase.__init__(self, params, aw)
  29. self._participant = None
  30. def _checkParams(self):
  31. CollaborationPluginServiceBookingModifBase._checkParams(self)
  32. participantId = self._params.get("participantId", None)
  33. if participantId:
  34. self._participant = self._booking.getParticipantById(participantId)
  35. else:
  36. raise CERNMCUException( _("Service ") + str(self.__class__.__name__) + _(" called without a participantId parameter"))
  37. class ConnectParticipantService(ParticipantServiceBase):
  38. def _getAnswer(self):
  39. result = self._booking.startSingleParticipant(self._participant)
  40. if isinstance(result, CERNMCUError):
  41. return fossilize(result)
  42. else:
  43. return fossilize(self._booking, ICSBookingBaseConfModifFossil, tz = self._conf.getTimezone())
  44. class DisconnectParticipantService(ParticipantServiceBase):
  45. def _getAnswer(self):
  46. result = self._booking.stopSingleParticipant(self._participant)
  47. if isinstance(result, CERNMCUError):
  48. return fossilize(result)
  49. else:
  50. return fossilize(self._booking, ICSBookingBaseConfModifFossil, tz = self._conf.getTimezone())