PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/indico/MaKaC/plugins/Collaboration/WebcastRequest/common.py

https://github.com/flannery/indico-flannery
Python | 127 lines | 98 code | 8 blank | 21 comment | 1 complexity | 2f050a75899560fa73db157ca5dab887 MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. ##
  3. ##
  4. ## This file is par{t 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.plugins.Collaboration.base import CollaborationServiceException,\
  21. CSErrorBase
  22. from MaKaC.webinterface.common.contribFilters import PosterFilterField
  23. from MaKaC.plugins.Collaboration.collaborationTools import CollaborationTools
  24. from MaKaC.plugins.Collaboration.WebcastRequest.fossils import IWebcastRequestErrorFossil
  25. from MaKaC.common.fossilize import fossilizes
  26. lectureOptions = [
  27. ("none", "None"),
  28. ("slides", "Slides"),
  29. ("chalkboard", "Chalkboard"),
  30. ("slidesAndChalkboard" , "Slides and Chalkboard")
  31. ]
  32. typeOfEvents = [
  33. ("lecturePresentation" , "Lecture / Presentation"),
  34. ("courseTutorial", "Course / Tutorial"),
  35. ("panelDiscussion" , "Panel discussion"),
  36. ("noAudience", "Remote teaching or candidate interview")
  37. ]
  38. postingUrgency = [
  39. ("never", "Do not need it"),
  40. ("withinHours" , "Within hours"),
  41. ("withinDay" , "Within a day"),
  42. ("withinWeek" , "Within a week")
  43. ]
  44. webcastPurpose = [
  45. ("historicPreservation" , "Preservation of a historically valuable talk"),
  46. ("remoteParticipants" , "Dissemination to participants unable to attend in person"),
  47. ("trainingCourse" , "Training course"),
  48. ("candidateInterview" , "Candidate interview"),
  49. ("remoteTeaching" , "Remote teaching"),
  50. ("savingTravel" , "Saving money on travel"),
  51. ("publicOutreach" , "Public outreach")
  52. ]
  53. intendedAudience = [
  54. ("collaborationMembers" , "Members of a particular collaboration or experiment"),
  55. ("groupMembers" , "Members of a particular section or group"),
  56. ("studentsGrad" , "Graduate students"),
  57. ("studentsUndergrad" , "Undergraduate students"),
  58. ("studentsHighSchool" , "High school students"),
  59. ("studentsElementary" , "Elementary school students"),
  60. ("CERNUsers" , "CERN users"),
  61. ("CERNStaff" , "CERN staff"),
  62. ("technicalPersonnel" , "Technical personnel"),
  63. ("teachersHighSchool" , "High school teachers"),
  64. ("generalPublic" , "General public")
  65. ]
  66. subjectMatter = [
  67. ("physics" , "Physics"),
  68. ("computerScience" , "Computer Science"),
  69. ("engineering" , "Engineering"),
  70. ("safety" , "Safety"),
  71. ("techTraining" , "Technical Training")
  72. ]
  73. def getCommonTalkInformation(conference):
  74. """ Returns a tuple of 3 lists:
  75. -List of talks (Contribution objects which are not in a Poster session)
  76. -List of webcast capable rooms, as a list of "locationName:roomName" strings
  77. -List of webcast-able talks (list of Contribution objects who take place in a webcast capable room)
  78. """
  79. #a talk is defined as a non-poster contribution
  80. filter = PosterFilterField(conference, False, False)
  81. talks = [cont for cont in conference.getContributionList() if filter.satisfies(cont)]
  82. #list of "locationName:roomName" strings
  83. webcastCapableRooms = CollaborationTools.getOptionValue('WebcastRequest', "webcastCapableRooms")
  84. #a webcast-able talk is defined as a talk talking place in a webcast-able room
  85. webcastAbleTalks = []
  86. for t in talks:
  87. location = t.getLocation()
  88. room = t.getRoom()
  89. if location and room and (location.getName() + ":" + room.getName() in webcastCapableRooms):
  90. webcastAbleTalks.append(t)
  91. return (talks, webcastCapableRooms, webcastAbleTalks)
  92. class WebcastRequestError(CSErrorBase): #already fossilizable
  93. fossilizes(IWebcastRequestErrorFossil)
  94. def __init__(self, operation, inner):
  95. CSErrorBase.__init__(self)
  96. self._operation = operation
  97. self._inner = inner
  98. def getOperation(self):
  99. return self._operation
  100. def getInner(self):
  101. return str(self._inner)
  102. def getUserMessage(self):
  103. return ''
  104. def getLogMessage(self):
  105. return "Webcast Request error for operation: " + str(self._operation) + ", inner exception: " + str(self._inner)
  106. class WebcastRequestException(CollaborationServiceException):
  107. pass