Changeset a217dc in indico
- Timestamp:
- 05/12/10 15:30:42 (3 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, new-webex, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
- Children:
- b25817
- Parents:
- 1881c6
- git-author:
- Ian Rolewicz <ian.rolewicz@…> (03/26/10 16:37:59)
- git-committer:
- Jose Benito <jose.benito.gonzalez@…> (05/12/10 15:30:42)
- Location:
- indico
- Files:
-
- 1 added
- 16 edited
-
MaKaC/common/Conversion.py (modified) (3 diffs)
-
MaKaC/common/fossilize.py (modified) (14 diffs)
-
MaKaC/conference.py (modified) (14 diffs)
-
MaKaC/fossils/conference.py (modified) (2 diffs)
-
MaKaC/fossils/contribution.py (modified) (3 diffs)
-
MaKaC/fossils/schedule.py (added)
-
MaKaC/plugins/Collaboration/RecordingRequest/tpls/Indexing.js (modified) (1 diff)
-
MaKaC/plugins/Collaboration/RecordingRequest/tpls/Main.js (modified) (1 diff)
-
MaKaC/plugins/Collaboration/WebcastRequest/tpls/Indexing.js (modified) (1 diff)
-
MaKaC/plugins/Collaboration/WebcastRequest/tpls/Main.js (modified) (6 diffs)
-
MaKaC/schedule.py (modified) (12 diffs)
-
MaKaC/services/implementation/schedule.py (modified) (3 diffs)
-
MaKaC/webinterface/meeting.py (modified) (1 diff)
-
MaKaC/webinterface/pages/conferences.py (modified) (5 diffs)
-
MaKaC/webinterface/pages/sessions.py (modified) (1 diff)
-
MaKaC/webinterface/timetable.py (modified) (39 diffs)
-
htdocs/js/indico/Timetable/Base.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/common/Conversion.py
r021579 ra217dc 63 63 def parentSlot(cls, entry): 64 64 from MaKaC.schedule import ContribSchEntry, BreakTimeSchEntry 65 from MaKaC.conference import SessionSlot , Session65 from MaKaC.conference import SessionSlot#, Session 66 66 67 67 slot = None 68 68 69 if type(entry) == ContribSchEntry: 70 contrib = entry.getOwner() 71 session = contrib.getSession() 72 73 # If the contribution is not owned by a session return nothing 74 if type(session) != Session: 75 return None 76 77 # TODO: This should be fixed. There's currently no easy way 78 # of knowing in which session slot a contribution belongs. 79 # Loop through all the session slots and look if the contribution 80 # exists in the schedule. 81 for sl in session.getSlotList(): 82 for e in sl.getEntries(): 83 if e.getOwner() == contrib: 84 slot = sl 85 break 69 if type(entry) == ContribSchEntry and entry.getSchedule() is not None: 70 slot = entry.getSchedule().getOwner() 86 71 87 72 elif type(entry) == BreakTimeSchEntry: … … 102 87 @classmethod 103 88 def locatorString(cls, obj): 89 104 90 locator = obj.getOwner().getLocator() 105 91 if not locator.has_key('sessionId'): … … 119 105 """ 120 106 return int(obj.seconds / 60) 107 108 # @classmethod 109 # def resourceType(cls, obj): 110 # 111 # from MaKaC.conference import Link 112 # if type(obj) == Link: 113 # return 'external' 114 # else: 115 # return 'stored' -
indico/MaKaC/common/fossilize.py
r1881c6 ra217dc 33 33 import zope.interface 34 34 from types import NoneType, ClassType, TypeType 35 from persistent.interfaces import IPersistent36 35 37 36 … … 86 85 __fossilNameRE = re.compile('^I(\w+)Fossil$') 87 86 __methodNameRE = re.compile('^get(\w+)|(has\w+)|(is\w+)$') 88 __methodNameRE = re.compile('^get(.*)|(has.+)|(is.+)$')89 87 __methodNameCache = {} 90 88 __fossilNameCache = {} 89 __fossilAttrsCache = {} # Attribute Cache for Fossils with 90 # fields that are repeated 91 91 92 92 @classmethod … … 148 148 if interfaceArg is None: 149 149 #we try to take the 1st interface declared with fossilizes 150 implementedInterfaces = list( zope.interface.implementedBy(self.__class__))151 if not implementedInterfaces or implementedInterfaces[0] == IPersistent:150 implementedInterfaces = list(i for i in zope.interface.implementedBy(self.__class__) if i.extends(IFossil)) 151 if not implementedInterfaces: 152 152 raise NonFossilizableException("Object %s of class %s cannot be fossilized," 153 153 "no fossils were declared for it" % … … 159 159 elif type(interfaceArg) is dict: 160 160 161 found = False 162 clazz = self.__class__ 163 164 for key in interfaceArg.iterkeys(): 165 if (key == clazz.__name__ or #class name 166 key == "%s.%s" % (clazz.__module__, clazz.__name__) or #full class name 167 key == clazz or #class 168 (type(key) == ClassType or type(key) == TypeType or type(key) == tuple) and isinstance(self, key)): #class (including base classes) 169 170 interface = interfaceArg[key] 171 found = True 172 break 173 174 if not found: 161 className = self.__class__.__module__ + '.' + \ 162 self.__class__.__name__ 163 164 # interfaceArg is a dictionary of class:Fossil pairs 165 if className in interfaceArg: 166 interface = interfaceArg[className] 167 else: 175 168 raise NonFossilizableException("Object %s of class %s cannot be fossilized; " 176 169 "its class was not a key in the provided fossils dictionary" % … … 181 174 182 175 if not interface.providedBy(self): 176 183 177 raise WrongFossilTypeException("Interface '%s' not provided" 184 178 " by '%s'" % … … 190 184 191 185 @classmethod 192 def _fossilizeIterable(cls, target, interface, **kwargs):186 def _fossilizeIterable(cls, target, interface, useAttrCache = False, **kwargs): 193 187 """ 194 188 Fossilizes an object, be it a 'direct' fossilizable … … 197 191 198 192 if isinstance(target, Fossilizable): 199 return target.fossilize(interface, **kwargs)193 return target.fossilize(interface, useAttrCache, **kwargs) 200 194 else: 201 195 ttype = type(target) … … 205 199 container = [] #we turn sets and tuples into lists since JSON does not have sets / tuples 206 200 for elem in target: 207 container.append(fossilize(elem, interface, **kwargs))201 container.append(fossilize(elem, interface, useAttrCache, **kwargs)) 208 202 return container 209 203 elif ttype is dict: 210 204 container = {} 211 205 for key, value in target.iteritems(): 212 container[key] = fossilize(value, interface, **kwargs)206 container[key] = fossilize(value, interface, useAttrCache, **kwargs) 213 207 return container 214 208 else: 215 209 raise NonFossilizableException() 216 210 217 return fossilize(target, interface) 218 219 220 def fossilize(self, interfaceArg = None, **kwargs): 211 return fossilize(target, interface, useAttrCache) 212 213 def fossilize(self, interfaceArg = None, useAttrCache = False, **kwargs): 221 214 """ 222 215 Fossilizes the object, using the fossil provided by `interface`. … … 224 217 :param interfaceArg: the target fossile type 225 218 :type interfaceArg: IFossil, NoneType, or dict 219 :param useAttrCache: use caching of attributes if same fields are 220 repeated for a fossil 221 :type useAttrCache: boolean 226 222 """ 227 223 … … 236 232 237 233 tags = interface[method].getTaggedValueTags() 238 #Please use 'produce' as little as possible; there is almost always a more elegant and modular solution! 239 if 'produce' in tags: 240 methodResult = interface[method].getTaggedValue('produce')(self) 241 else: 242 methodResult = getattr(self, method)() 234 235 # In some cases it is better to use the attribute cache to 236 # speed up the fossilization 237 cacheUsed = False 238 if useAttrCache: 239 try: 240 methodResult = self.__fossilAttrsCache[self._p_oid][method] 241 cacheUsed = True 242 except KeyError: 243 pass 244 if not cacheUsed: 245 #Please use 'produce' as little as possible; there is almost always a more elegant and modular solution! 246 if 'produce' in tags: 247 methodResult = interface[method].getTaggedValue('produce')(self) 248 else: 249 methodResult = getattr(self, method)() 250 251 if hasattr(self, "_p_oid"): 252 try: 253 self.__fossilAttrsCache[self._p_oid] 254 except KeyError: 255 self.__fossilAttrsCache[self._p_oid] = {} 256 self.__fossilAttrsCache[self._p_oid][method] = methodResult 243 257 244 258 # Result conversion … … 246 260 targetInterface = interface[method].getTaggedValue('result') 247 261 #targetInterface = globals()[targetInterfaceName] 262 248 263 methodResult = Fossilizable._fossilizeIterable( 249 264 methodResult, targetInterface, **kwargs) … … 264 279 attrName = self.__extractName(method) 265 280 266 result[attrName] = methodResult 281 # In case the name contains dots, each of the 'domains' but the 282 # last one are translated into nested dictionnaries. For example, 283 # if we want to re-name an attribute into "foo.bar.tofu", the 284 # corresponding fossilized attribute will be of the form: 285 # {"foo":{"bar":{"tofu": res,...},...},...} 286 # instead of: 287 # {"foo.bar.tofu": res, ...} 288 289 current = result 290 attrList = attrName.split('.') 291 292 while len(attrList) > 1: 293 attr = attrList.pop(0) 294 try: 295 current = current[attr] 296 except KeyError: 297 current[attr] = {} 298 current = current[attr] 299 300 # For the last attribute level 301 current[attrList[0]] = methodResult 267 302 268 303 if "_type" in result or "_fossil" in result: … … 279 314 280 315 281 def fossilize(target, interfaceArg = None, **kwargs):316 def fossilize(target, interfaceArg = None, useAttrCache = False, **kwargs): 282 317 """ 283 318 Method that allows the "fossilization" process to … … 289 324 :param interfaceArg: target fossil type 290 325 :type interfaceArg: IFossil, NoneType, or dict 291 """ 292 return Fossilizable._fossilizeIterable(target, interfaceArg, **kwargs) 326 :param useAttrCache: use the attribute caching 327 :type useAttrCache: boolean 328 """ 329 return Fossilizable._fossilizeIterable(target, interfaceArg, useAttrCache, **kwargs) -
indico/MaKaC/conference.py
r0b2441 ra217dc 25 25 ISubContributionFossil, ISubContributionWithSpeakersFossil 26 26 from MaKaC.fossils.contribution import IContributionParticipationFossil,\ 27 IContributionFossil, IContributionWithSpeakersFossil,\ 28 IContributionWithSubContribsFossil 29 from MaKaC.fossils.conference import IConferenceMinimalFossil 27 IContributionFossil, IContributionWithSpeakersFossil, IContributionParticipationMinimalFossil, \ 28 IContributionWithSubContribsFossil,\ 29 IContributionParticipationTTDisplayFossil, \ 30 IContributionParticipationTTMgmtFossil 31 from MaKaC.fossils.conference import IConferenceMinimalFossil,\ 32 ISessionFossil, ISessionSlotFossil, IMaterialFossil,\ 33 IConferenceParticipationFossil, IResourceFossil, ILinkFossil,\ 34 ILocalFileFossil 30 35 from MaKaC.common.fossilize import fossilizes, Fossilizable 31 36 … … 1505 1510 1506 1511 1507 class ConferenceParticipation(Persistent): 1512 class ConferenceParticipation(Persistent, Fossilizable): 1513 1514 fossilizes(IConferenceParticipationFossil) 1508 1515 1509 1516 @Retrieves(['MaKaC.conference.ConferenceParticipation', … … 5351 5358 5352 5359 5353 class Session(Persistent ):5360 class Session(Persistent, Fossilizable): 5354 5361 """This class implements a conference session, being the different parts 5355 5362 in which the conference can be divided and the contributions can be … … 5360 5367 """ 5361 5368 5369 fossilizes(ISessionFossil) 5362 5370 5363 5371 @Retrieves(['MaKaC.conference.Session'], 'numSlots', lambda x : len(x.getSlotList())) … … 6841 6849 _cmpTitle=staticmethod(_cmpTitle) 6842 6850 6843 class SessionSlot(Persistent): 6851 class SessionSlot(Persistent, Fossilizable): 6852 6853 fossilizes(ISessionSlotFossil) 6844 6854 6845 6855 def __init__(self,session,**sessionSlotData): … … 7488 7498 class ContributionParticipation(Persistent, Fossilizable): 7489 7499 7490 fossilizes(IContributionParticipationFossil) 7500 fossilizes(IContributionParticipationFossil, IContributionParticipationMinimalFossil,\ 7501 IContributionParticipationTTDisplayFossil,\ 7502 IContributionParticipationTTMgmtFossil) 7491 7503 7492 7504 def __init__( self ): … … 7902 7914 """ 7903 7915 7904 fossilizes(IContributionFossil, IContributionWithSpeakersFossil, IContributionWithSubContribsFossil) 7916 fossilizes(IContributionFossil, IContributionWithSpeakersFossil,\ 7917 IContributionWithSubContribsFossil) 7905 7918 7906 7919 def __init__(self,**contribData): … … 9799 9812 return maxDatetime() 9800 9813 9814 @Retrieves(['MaKaC.conference.Contribution'], 'color') 9815 def getColor(self): 9816 res="" 9817 if self.getSession() is not None: 9818 res=self.getSession().getColor() 9819 return res 9820 9821 @Retrieves(['MaKaC.conference.Contribution'], 'textColor') 9822 def getTextColor(self): 9823 res="" 9824 if self.getSession() is not None: 9825 res=self.getSession().getTextColor() 9826 return res 9801 9827 9802 9828 class AcceptedContribution( Contribution ): … … 10840 10866 self._reportNumberHolder=rnh 10841 10867 10842 class Material(Persistent ):10868 class Material(Persistent, Fossilizable): 10843 10869 """This class represents a set of electronic documents (resources) which can 10844 10870 be attached to a conference, a session or a contribution. … … 10860 10886 by their unique relative id. 10861 10887 """ 10888 10889 fossilizes(IMaterialFossil) 10862 10890 10863 10891 def __init__( self, materialData=None ): … … 11585 11613 11586 11614 11587 class Resource(Persistent ):11615 class Resource(Persistent, Fossilizable): 11588 11616 """This is the base class for representing individual resources which can 11589 11617 be included in material containers for lately being attached to … … 11604 11632 """ 11605 11633 11634 fossilizes(IResourceFossil) 11635 11606 11636 @Retrieves (['MaKaC.conference.Link', 11607 11637 'MaKaC.conference.LocalFile'], 'type', lambda r: if_else(type(r) == Link , 'external', 'stored')) … … 11944 11974 url -- (string) Contains the URL to the internet target resource. 11945 11975 """ 11976 11977 fossilizes(ILinkFossil) 11946 11978 11947 11979 def __init__( self, resData = None ): … … 11982 12014 """ 11983 12015 12016 fossilizes(ILocalFileFossil) 12017 11984 12018 def __init__( self, resData = None ): 11985 12019 Resource.__init__( self, resData ) -
indico/MaKaC/fossils/conference.py
r5a8326 ra217dc 21 21 from MaKaC.common.fossilize import IFossil 22 22 from MaKaC.common.Conversion import Conversion 23 from MaKaC.webinterface import urlHandlers 23 24 24 25 class IConferenceMinimalFossil(IFossil): … … 55 56 """ Support Email """ 56 57 58 class IConferenceParticipationFossil(IFossil): 57 59 60 def getFirstName( self ): 61 """ Conference Participation First Name """ 62 63 def getFamilyName( self ): 64 """ Conference Participation Family Name """ 65 66 67 class IResourceFossil(IFossil): 68 69 def getName(self): 70 """ Name of the Resource """ 71 72 73 class ILinkFossil(IResourceFossil): 74 75 def getURL(self): 76 """ URL of the file pointed by the link """ 77 getURL.name = "url" 78 79 class ILocalFileFossil(IResourceFossil): 80 81 def getURL(self): 82 """ URL of the Local File """ 83 getURL.produce = lambda s: str(urlHandlers.UHFileAccess.getURL(s)) 84 getURL.name = "url" 85 86 87 class IMaterialFossil(IFossil): 88 89 def getTitle( self ): 90 """ Material Title """ 91 92 def getResourceList(self): 93 """ Material Resource List """ 94 getResourceList.result = {"MaKaC.conference.Link": ILinkFossil, "MaKaC.conference.LocalFile": ILocalFileFossil} 95 getResourceList.name = "resources" 96 97 98 class ISessionFossil(IFossil): 99 100 def getTitle(self): 101 """ Session Title """ 102 103 def getId(self): 104 """ Session Id """ 105 getId.name = "sessionId" 106 107 def getDescription(self): 108 """ Session Description """ 109 110 def getAllMaterialList(self): 111 """ Session List of all material """ 112 getAllMaterialList.result = IMaterialFossil 113 getAllMaterialList.name = "material" 114 115 def getColor(self): 116 """ Session Color """ 117 118 def getTextColor(self): 119 """ Session Text Color """ 120 121 def isPoster(self): 122 """ Is self a Poster Session ? """ 123 isPoster.produce = lambda s: s.getScheduleType() == 'poster' 124 125 126 class ISessionSlotFossil(IFossil): 127 128 def getSession(self): 129 """ Slot Session """ 130 getSession.result = ISessionFossil 131 132 def getId(self): 133 """ Session Slot Id """ 134 getId.name = "sessionSlotId" 135 136 def getTitle(self): 137 """ Session Slot Title """ 138 getTitle.name = "slotTitle" 139 140 def getConference(self): 141 """ Session Slot Conference """ 142 getConference.result = IConferenceMinimalFossil 143 144 def getRoom(self): 145 """ Session Slot Room """ 146 getRoom.convert = Conversion.roomName 147 148 def getLocationName(self): 149 """ Session Slot Location Name """ 150 getLocationName.produce = lambda s: s.getLocation() 151 getLocationName.convert = Conversion.locationName 152 getLocationName.name = "location" 153 154 def getLocationAddress(self): 155 """ Session Slot Location Address """ 156 getLocationAddress.produce = lambda s: s.getLocation() 157 getLocationAddress.convert = Conversion.locationAddress 158 getLocationAddress.name = "address" 159 160 def inheritRoom(self): 161 """ Does the Session inherit a Room ?""" 162 inheritRoom.produce = lambda s: s.getOwnRoom() is None 163 inheritRoom.name = "inheritRoom" 164 165 def inheritLocation(self): 166 """ Does the Session inherit a Location ?""" 167 inheritLocation.produce = lambda s: s.getOwnLocation() is None 168 inheritLocation.name = "inheritLoc" 169 170 def getOwnConvenerList(self): 171 """ Session Slot Conveners List """ 172 getOwnConvenerList.result = IConferenceParticipationFossil 173 getOwnConvenerList.name = "conveners" -
indico/MaKaC/fossils/contribution.py
r2adefc ra217dc 51 51 getDuration.convert = Conversion.duration 52 52 53 class IContributionParticipationFossil(IFossil): 53 def getDescription(self): 54 pass 55 56 57 class IContributionParticipationTTDisplayFossil(IFossil): 58 """ 59 Minimal Fossil for Contribution Participation to be 60 used by the timetable display 61 """ 62 63 def getAffiliation(self): 64 pass 65 66 def getFullNameNoTitle(self): 67 pass 68 getFullNameNoTitle.name = "name" 69 70 71 class IContributionParticipationTTMgmtFossil(IFossil): 72 """ 73 Minimal Fossil for Contribution Participation to be 74 used by the timetable management 75 """ 76 77 def getFullNameNoTitle(self): 78 pass 79 getFullNameNoTitle.name = "name" 80 81 class IContributionParticipationMinimalFossil(IFossil): 54 82 55 83 def getId(self): 56 84 pass 85 86 def getFullName(self): 87 pass 88 89 class IContributionParticipationFossil(IContributionParticipationMinimalFossil): 57 90 58 91 def getTitle(self): … … 63 96 64 97 def getFamilyName(self): 65 pass66 67 def getFullName(self):68 98 pass 69 99 … … 84 114 85 115 86 87 116 class IContributionWithSpeakersFossil(IContributionFossil): 88 117 89 118 def getSpeakerList(self): 90 119 pass 91 getSpeakerList.result = IContributionParticipation Fossil120 getSpeakerList.result = IContributionParticipationMinimalFossil 92 121 93 122 class IContributionWithSubContribsFossil(IContributionFossil): -
indico/MaKaC/plugins/Collaboration/RecordingRequest/tpls/Indexing.js
r57b8a9 ra217dc 1 1 { 2 2 "customText": function(booking, viewBy) { 3 if (booking.statusMessage == "Request rejected by responsible" && booking.reject ionReason && trim(booking.rejectionReason)) {4 return "Rejection reason: " + trim(booking.reject ionReason);3 if (booking.statusMessage == "Request rejected by responsible" && booking.rejectReason && trim(booking.rejectReason)) { 4 return "Rejection reason: " + trim(booking.rejectReason); 5 5 } 6 6 } -
indico/MaKaC/plugins/Collaboration/RecordingRequest/tpls/Main.js
rbe7613 ra217dc 43 43 44 44 customText : function(booking) { 45 if (booking.acceptRejectStatus === false && trim(booking.reject ionReason)) {46 return $T("Rejection reason: ") + trim(booking.reject ionReason);45 if (booking.acceptRejectStatus === false && trim(booking.rejectReason)) { 46 return $T("Rejection reason: ") + trim(booking.rejectReason); 47 47 } 48 48 }, -
indico/MaKaC/plugins/Collaboration/WebcastRequest/tpls/Indexing.js
r57b8a9 ra217dc 1 1 { 2 2 "customText": function(booking, viewBy) { 3 if (booking.statusMessage == "Request rejected by responsible" && booking.reject ionReason && trim(booking.rejectionReason)) {4 return "Rejection reason: " + trim(booking.reject ionReason);3 if (booking.statusMessage == "Request rejected by responsible" && booking.rejectReason && trim(booking.rejectReason)) { 4 return "Rejection reason: " + trim(booking.rejectReason); 5 5 } 6 6 } -
indico/MaKaC/plugins/Collaboration/WebcastRequest/tpls/Main.js
r626e2c ra217dc 1 { 1 { 2 2 checkParams : function () { 3 3 return { … … 25 25 } 26 26 }, 27 27 28 28 errorHandler: function(event, error) { 29 29 if (error.operation == "create") { … … 40 40 } 41 41 }, 42 42 43 43 customText : function(booking) { 44 if (booking.acceptRejectStatus === false && trim(booking.reject ionReason)) {45 return $T("Rejection reason: ") + trim(booking.reject ionReason);44 if (booking.acceptRejectStatus === false && trim(booking.rejectReason)) { 45 return $T("Rejection reason: ") + trim(booking.rejectReason); 46 46 } 47 47 }, 48 48 49 49 clearForm : function () { 50 50 var formNodes = IndicoUtil.findFormFields($E('WebcastRequestForm')); … … 54 54 IndicoUI.Effect.disappear($E('contributionsDiv')); 55 55 } 56 56 57 57 $E('permissionYesRB').dom.checked = false; 58 58 $E('permissionNoRB').dom.checked = false; … … 61 61 $E('postingUrgency').dom.value = "never"; 62 62 }, 63 63 64 64 onLoad : function() { 65 65 66 66 WRUpdateContributionList(); 67 67 68 68 IndicoUtil.enableDisableForm($E("WRForm"), WRWebcastCapable); 69 69 70 70 if (!isLecture) { 71 71 if (singleBookings['WebcastRequest'] && singleBookings['WebcastRequest'].bookingParams.talks == 'choose') { … … 73 73 } 74 74 } 75 75 76 76 if(!singleBookings['WebcastRequest']) { 77 77 callFunction('WebcastRequest', 'clearForm'); -
indico/MaKaC/schedule.py
r0b2441 ra217dc 36 36 from MaKaC.common.Conversion import Conversion 37 37 from MaKaC.common.contextManager import ContextManager 38 from MaKaC.common.fossilize import Fossilizable, fossilizes 39 from MaKaC.fossils.schedule import IContribSchEntryDisplayFossil,\ 40 IContribSchEntryMgmtFossil, IBreakTimeSchEntryFossil,\ 41 IBreakTimeSchEntryMgmtFossil,\ 42 ILinkedTimeSchEntryDisplayFossil, ILinkedTimeSchEntryMgmtFossil 38 43 39 44 class Schedule: … … 464 469 465 470 466 class SchEntry(Persistent ):471 class SchEntry(Persistent, Fossilizable): 467 472 """base schedule entry class. Do NOT instantiate 468 473 """ … … 555 560 pass 556 561 557 class ConferenceSchedule(TimeSchedule ):562 class ConferenceSchedule(TimeSchedule, Fossilizable): 558 563 """ 559 564 """ 565 566 # fossilizes(IConferenceScheduleDisplayFossil, IConferenceScheduleMgmtFossil) 560 567 561 568 def __init__(self,conf): … … 585 592 #not very smart, should be improved: contribs with same start date, 586 593 # can cause overlapings 594 587 595 if not tz: 588 596 tz = self.getTimezone() … … 931 939 class LinkedTimeSchEntry(TimeSchEntry): 932 940 941 fossilizes(ILinkedTimeSchEntryDisplayFossil, 942 ILinkedTimeSchEntryMgmtFossil) 933 943 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'title', lambda x: x.getOwner().getSession().getTitle()) 934 944 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'slotTitle', lambda x: x.getOwner().getTitle()) … … 938 948 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'entryType', lambda x: 'Session') 939 949 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'material', lambda x: DictPickler.pickle(x.getOwner().getSession().getAllMaterialList())) 940 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'color', lambda x: x.getOwner().get Session().getColor())941 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'textColor', lambda x: x.getOwner().get Session().getTextColor())950 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'color', lambda x: x.getOwner().getColor()) 951 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'textColor', lambda x: x.getOwner().getTextColor()) 942 952 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'isPoster', lambda x: x.getOwner().getSession().getScheduleType() == 'poster') 943 953 @Retrieves (['MaKaC.schedule.LinkedTimeSchEntry'], 'room', lambda x: Conversion.roomName(x.getOwner().getRoom())) … … 1119 1129 class BreakTimeSchEntry(IndTimeSchEntry): 1120 1130 1131 fossilizes(IBreakTimeSchEntryFossil, IBreakTimeSchEntryMgmtFossil) 1121 1132 @Retrieves(['MaKaC.schedule.BreakTimeSchEntry'], 'entryType', lambda x: 'Break') 1122 1133 @Retrieves(['MaKaC.schedule.BreakTimeSchEntry'], 'conferenceId', lambda x: x.getOwner().getConference().getId()) … … 1418 1429 class ContribSchEntry(LinkedTimeSchEntry): 1419 1430 1431 fossilizes(IContribSchEntryDisplayFossil, 1432 IContribSchEntryMgmtFossil ) 1433 1420 1434 @Retrieves (['MaKaC.schedule.ContribSchEntry'], 'entryType', lambda x: 'Contribution') 1421 1435 @Retrieves (['MaKaC.schedule.ContribSchEntry'], 'sessionId', Conversion.parentSession) … … 1455 1469 1456 1470 @staticmethod 1457 def processEntry(obj, tz, aw): 1458 1459 #raise "duration: " + (datetime(1900,1,1)+obj.getDuration()).strftime("%Hh%M'") + '' 1460 entry = DictPickler.pickle(obj, timezone=tz) 1471 def processEntry(obj, tz, aw, mgmtMode = False, useAttrCache = False): 1472 1473 if mgmtMode: 1474 if isinstance(obj, BreakTimeSchEntry): 1475 entry = obj.fossilize(IBreakTimeSchEntryMgmtFossil, useAttrCache = useAttrCache) 1476 elif isinstance(obj, ContribSchEntry): 1477 entry = obj.fossilize(IContribSchEntryMgmtFossil, useAttrCache = useAttrCache) 1478 elif isinstance(obj, LinkedTimeSchEntry): 1479 entry = obj.fossilize(ILinkedTimeSchEntryMgmtFossil, useAttrCache = useAttrCache) 1480 else: 1481 entry = obj.fossilize(useAttrCache = useAttrCache) 1482 else: 1483 # the fossils used for the display of entries 1484 # will be taken by default, since they're first 1485 # in the list of their respective Fossilizable 1486 # objects 1487 entry = obj.fossilize(useAttrCache = useAttrCache) 1461 1488 1462 1489 genId = entry['id'] … … 1471 1498 for contrib in sessionSlot.getSchedule().getEntries(): 1472 1499 if ScheduleToJson.checkProtection(contrib, aw): 1473 contribData = DictPickler.pickle(contrib, timezone=tz) 1500 if mgmtMode: 1501 if isinstance(contrib, ContribSchEntry): 1502 contribData = contrib.fossilize(IContribSchEntryMgmtFossil, useAttrCache = useAttrCache) 1503 elif isinstance(contrib, BreakTimeSchEntry): 1504 contribData = contrib.fossilize(IBreakTimeSchEntryMgmtFossil, useAttrCache = useAttrCache) 1505 else: 1506 contribData = contrib.fossilize(useAttrCache = useAttrCache) 1507 else: 1508 # the fossils used for the display of entries 1509 # will be taken by default, since they're first 1510 # in the list of their respective Fossilizable 1511 # objects 1512 contribData = contrib.fossilize(useAttrCache = useAttrCache) 1513 1474 1514 entries[contribData['id']] = contribData 1475 1515 … … 1497 1537 return canBeDisplayed 1498 1538 1499 1500 1539 @staticmethod 1501 def process(schedule, tz, aw, days = None ):1540 def process(schedule, tz, aw, days = None, mgmtMode = False, useAttrCache = False): 1502 1541 1503 1542 scheduleDict={} … … 1506 1545 days = daysBetween(schedule.getAdjustedStartDate(tz), schedule.getAdjustedEndDate(tz)) 1507 1546 1508 for day in days: 1509 dayEntry = {} 1510 1511 for obj in schedule.getEntriesOnDay(day): 1512 1513 if ScheduleToJson.checkProtection(obj, aw): 1514 genId, pickledData = ScheduleToJson.processEntry(obj, tz, aw) 1515 1516 # exclude entries that start in the day before 1517 if obj.getAdjustedStartDate(tz).date() == day.date(): 1518 dayEntry[genId] = pickledData 1519 1520 scheduleDict[day.strftime("%Y%m%d")] = dayEntry 1547 dates = [d.strftime("%Y%m%d") for d in days] 1548 1549 # Generating the days dictionnary 1550 for d in dates: 1551 scheduleDict[d] = {} 1552 1553 # Filling the day dictionnary with entries 1554 for obj in schedule.getEntries(): 1555 1556 if ScheduleToJson.checkProtection(obj, aw): 1557 genId, resultData = ScheduleToJson.processEntry(obj, tz, aw, mgmtMode, useAttrCache) 1558 day = obj.getAdjustedStartDate(tz).strftime("%Y%m%d") 1559 # verify that start date is in dates 1560 if day in dates: 1561 scheduleDict[day][genId] = resultData 1521 1562 1522 1563 return scheduleDict -
indico/MaKaC/services/implementation/schedule.py
r021579 ra217dc 535 535 536 536 # retrieve results 537 pickledData = schedule.ScheduleToJson.process(self._schEntry.getSchedule(), self._conf.getTimezone(), None, days = [self._schEntry.getAdjustedStartDate()]) 537 pickledData = schedule.ScheduleToJson.process(self._schEntry.getSchedule(), self._conf.getTimezone(), 538 None, days = [self._schEntry.getAdjustedStartDate()], 539 mgmtMode = True) 538 540 entryId = pickledData.keys()[0] 539 541 pickledData = pickledData.values()[0] 540 542 else: 541 entryId, pickledData = schedule.ScheduleToJson.processEntry(self._schEntry, self._conf.getTimezone(), None) 543 entryId, pickledData = schedule.ScheduleToJson.processEntry(self._schEntry, self._conf.getTimezone(), 544 None, mgmtMode = True) 542 545 543 546 return {'day': self._schEntry.getAdjustedStartDate().strftime("%Y%m%d"), … … 663 666 else: 664 667 schEntry = self._slot.getConfSchEntry() 665 entryId, pickledData = schedule.ScheduleToJson.processEntry(schEntry, self._conf.getTimezone(), None) 668 entryId, pickledData = schedule.ScheduleToJson.processEntry(schEntry, self._conf.getTimezone(), 669 None, mgmtMode = True) 666 670 667 671 return {'day': schEntry.getAdjustedStartDate().strftime("%Y%m%d"), … … 1050 1054 sched.moveDownEntry(schEntry) 1051 1055 1052 return schedule.ScheduleToJson.process(sched, self._conf.getTimezone(), None, days = [ schEntry.getAdjustedStartDate() ]) 1056 return schedule.ScheduleToJson.process(sched, self._conf.getTimezone(), None, 1057 days = [ schEntry.getAdjustedStartDate() ], 1058 mgmtMode = True) 1053 1059 1054 1060 -
indico/MaKaC/webinterface/meeting.py
rbdd862 ra217dc 884 884 class WPMConfModifSchedule(conferences.WPConfModifScheduleGraphic): 885 885 pass 886 887 class WMConfModifSchedule(conferences.WConfModifScheduleGraphic):888 889 def __init__(self, conf, aw, timetable, days):890 conferences.WConfModifScheduleGraphic.__init__(self, conf, aw, timetable, days, tpl_name='ConfModifScheduleGraphic')891 886 892 887 ## Add Contributions to main meeting ## -
indico/MaKaC/webinterface/pages/conferences.py
r0a4b4c ra217dc 1154 1154 vars = wcomponents.WTemplated.getVars( self ) 1155 1155 tz = DisplayTZ(self._aw,self._conf).getDisplayTZ() 1156 vars["ttdata"] = simplejson.dumps(schedule.ScheduleToJson.process(self._conf.getSchedule(), tz, self._aw)) 1156 vars["ttdata"] = simplejson.dumps(schedule.ScheduleToJson.process(self._conf.getSchedule(), 1157 tz, self._aw, 1158 useAttrCache = True)) 1157 1159 vars['eventInfo'] = simplejson.dumps(DictPickler.pickle(self._conf, timezone=tz)) 1158 1160 return vars … … 3143 3145 class WConfModifScheduleGraphic(wcomponents.WTemplated): 3144 3146 3145 def __init__(self, conference, aw, timetable, dayList,**params):3147 def __init__(self, conference, **params): 3146 3148 wcomponents.WTemplated.__init__(self, **params) 3147 3149 self._conf = conference 3148 self._aw = aw3149 self._timetable = timetable3150 self._dayList = dayList3151 3150 3152 3151 def getVars( self ): … … 3164 3163 vars["editURL"]=quoteattr(str(urlHandlers.UHConfModScheduleDataEdit.getURL(self._conf))) 3165 3164 3166 # the list of days specified by the user through the option box 3167 vars["daysParam"] = self._dayList 3168 # the list of days from the timetable 3169 vars["dayList"]=self._timetable.getDayList() 3170 # the first day of the list 3171 vars["dayDate"]=self._dayList[0].getDate() 3172 3173 vars["addSessionURL"]=urlHandlers.UHConfAddSession.getURL(self._conf) 3174 vars["addBreakURL"]=urlHandlers.UHConfAddBreak.getURL(self._conf) 3175 3176 originURL = urlHandlers.UHConfModifSchedule.getURL(self._conf) 3177 newContribURL = urlHandlers.UHConfModScheduleNewContrib.getURL(self._conf) 3178 newContribURL.addParam("originURL",originURL) 3179 newContribURL.addParam("eventType","meeting") 3180 vars["newContribURL"] = newContribURL 3181 vars['rbActive'] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getRoomBookingModuleActive() 3182 3183 vars['ttdata'] = simplejson.dumps(schedule.ScheduleToJson.process(self._conf.getSchedule(), tz, None)) 3165 vars['ttdata'] = simplejson.dumps(schedule.ScheduleToJson.process(self._conf.getSchedule(), tz, None, 3166 days = None, mgmtMode = True)) 3184 3167 vars['eventInfo'] = simplejson.dumps(DictPickler.pickle(self._conf, timezone=tz)) 3185 3168 … … 3192 3175 def __init__(self, rh, conf): 3193 3176 WPConferenceModifBase.__init__(self, rh, conf) 3194 self._session = None3195 3177 self._contrib = None 3196 3178 … … 3202 3184 self._includeJSPackage('Timetable') 3203 3185 3204 def _generateTimetable(self):3205 tz = self._conf.getTimezone()3206 timeTable = timetable.TimeTable(self._conf.getSchedule(), tz)3207 #######################################3208 # Fermi timezone awareness #3209 #######################################3210 sDate = self._conf.getSchedule().getStartDate(tz)3211 eDate = self._conf.getSchedule().getEndDate(tz)3212 #######################################3213 # Fermi timezone awareness(end) #3214 #######################################3215 timeTable.setStartDate(sDate)3216 timeTable.setEndDate(eDate)3217 #timeTable.setStartDayTime(7,0)3218 #timeTable.setEndDayTime(21,59)3219 timeTable.mapEntryList(self._conf.getSchedule().getEntries())3220 3221 return timeTable3222 3223 def _getSchedule(self):3224 return WConfModifScheduleGraphic( self._conf, self._getAW(), self._timetable, self._days)3225 3226 3186 def _getTTPage( self, params ): 3227 3228 params["session"] = self._session 3229 3230 days = params.get("days", None) 3231 3232 timeTable= self._generateTimetable() 3233 3234 if days == None or days == 'all': 3235 dayList = timeTable.getDayList() 3236 else: 3237 dayList = [timeTable.getDayList()[int(days)]] 3238 3239 self._days = dayList 3240 self._timetable = timeTable 3241 3242 wc = self._getSchedule() 3187 wc = WConfModifScheduleGraphic( self._conf) 3243 3188 return wc.getHTML(params) 3244 3189 -
indico/MaKaC/webinterface/pages/sessions.py
r8989f6 ra217dc 1498 1498 vars['rbActive'] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getRoomBookingModuleActive() 1499 1499 1500 vars['ttdata'] = simplejson.dumps(schedule.ScheduleToJson.process(self._session.getSchedule(), tz, None)) 1500 vars['ttdata'] = simplejson.dumps(schedule.ScheduleToJson.process(self._session.getSchedule(), tz, 1501 None, days = None, mgmtMode = True)) 1501 1502 1502 1503 eventInfo = DictPickler.pickle(self._session.getConference(), timezone=tz) -
indico/MaKaC/webinterface/timetable.py
rbdd862 ra217dc 29 29 30 30 class TimeTable(object): 31 31 32 32 def __init__( self, schedule, tz = 'UTC'): 33 33 self.setSlotLengthInMin(5) … … 37 37 self._sch = schedule 38 38 #self.listEntries = schedule.getEntries() 39 self._tz = tz 39 self._tz = tz 40 40 self.mapEntryList(self._sch.getEntries()) 41 41 42 42 43 44 45 43 44 45 46 46 def setStartDate( self, date): 47 47 self.__startDate = date … … 49 49 def getStartDate( self ): 50 50 return self.__startDate 51 51 52 52 def setEndDate( self, date ): 53 53 self.__endDate = date 54 54 55 55 def getEndDate( self ): 56 56 return self.__endDate … … 64 64 def setSlotLengthInMin( self, minutes ): 65 65 self._slotLength = timedelta( minutes=int(minutes) ) 66 66 67 67 def getSlotLength( self ): 68 68 return self._slotLength … … 71 71 self._days = [] 72 72 iDate = self.getStartDate() 73 eDate = self.getEndDate() 73 eDate = self.getEndDate() 74 74 dayDict = {} 75 75 dayList = [] 76 76 77 77 while iDate.date()<=eDate.date(): 78 78 sTime = timedelta(hours=8) 79 79 eTime = timedelta(hours=18, minutes=59) 80 if self._sch: 80 if self._sch: 81 81 s = self._sch.calculateDayStartDate(iDate) 82 82 schSTime = timedelta(hours=s.hour) … … 95 95 def reGenerate( self ): 96 96 self.__initialise() 97 97 98 98 def getDayList( self ): 99 99 return self._days … … 103 103 for day in self.getDayList(): 104 104 day.clean() 105 #to be optimised 106 for day in self.getDayList(): 107 day.mapEntryList( entryList ) 108 105 day.mapEntryList( entryList ) 109 106 110 107 def mapContainerList( self, containerList ): … … 128 125 129 126 class Day(object): 130 127 131 128 # def __init__( self, date, startTime, endTime, slotLength): 132 129 # self.__date = date.replace(hour=0,minute=0,second=0) … … 150 147 # self.__slots.append( TimeSlot( sDate, eDate ) ) 151 148 # iTime = iTime + slotLength 152 149 153 150 154 151 # def getStartHour( self ): … … 157 154 # except: 158 155 # return 23 159 156 160 157 # def getEndHour( self ): 161 158 # try: … … 186 183 # def mapContainerList( self, l ): 187 184 ##to be MUCH optimised 188 185 189 186 # for sesSlot in l: 190 187 # entryList = [] … … 193 190 # container = Container(sesSlot) 194 191 # container.setEntries(entryList) 195 # if entryList: 192 # if entryList: 196 193 # for entry in entryList: 197 194 # for slot in self.getSlotList(): … … 233 230 # if slot.getEntryList() != []: 234 231 # slot.mapContainer(container) 235 # else: 232 # else: 236 233 # for slot in self.getSlotList(): 237 234 # slot.mapEntry(session) … … 270 267 # return self.getSlotList()[i+1] 271 268 # return None 272 269 273 270 274 271 # def hasEntryOverlaps(self,entry): … … 367 364 # max = num 368 365 # return max 369 366 370 367 def __init__( self, date, startTime, endTime, slotLength): 371 368 self.__date = date.replace(hour=0,minute=0,second=0) … … 392 389 self.__slots.append( TimeSlot( sDate, eDate ) ) 393 390 iTime = iTime + slotLength 394 391 395 392 396 393 def getStartHour( self ): … … 399 396 except: 400 397 return 23 401 398 402 399 def getEndHour( self ): 403 400 try: … … 422 419 def getEntryList(self ): 423 420 return self.__entries 424 421 425 422 426 423 def addEntry(self, entry): … … 444 441 def mapContainerList( self, l ): 445 442 # to be MUCH optimised 446 443 447 444 for sesSlot in l: 448 445 entryList = [] … … 451 448 container = Container(sesSlot) 452 449 container.setEntries(entryList) 453 if entryList: 450 if entryList: 454 451 for entry in entryList: 455 452 for slot in self.getSlotList(): … … 491 488 if slot.getEntryList() != []: 492 489 slot.mapContainer(container) 493 else: 490 else: 494 491 for slot in self.getSlotList(): 495 492 slot.mapEntry(session) … … 528 525 return self.getSlotList()[i+1] 529 526 return None 530 527 531 528 532 529 def hasEntryOverlaps(self,entry): … … 624 621 if max < num: 625 622 max = num 626 return max 623 return max 627 624 628 625 class TimeSlot(object): 629 626 630 627 def __init__( self, startDateTime, endDateTime ): 631 628 self.__start = startDateTime … … 634 631 self._containers = [] 635 632 self._header = False 636 self._footer = False 633 self._footer = False 637 634 self._tz = startDateTime.tzinfo 638 635 639 636 def getStartDate( self ): 640 637 return self.__start 641 638 642 639 def getAdjustedStartDate( self, tz=None ): 643 640 if not tz: … … 646 643 tz = timezone(tz) 647 644 return self.__start.astimezone(tz) 648 645 649 646 def getEndDate( self ): 650 647 return self.__end … … 656 653 tz = timezone(tz) 657 654 return self.__end.astimezone(tz) 658 655 659 656 def getTZ( self ): 660 657 return self._tz … … 696 693 l.append( entry.getTitle() ) 697 694 return "; ".join( l ) 698 695 699 696 def getNumEntriesOverlaped(self): 700 697 return len(self.__entries) … … 743 740 def hasHeaders(self): 744 741 return self._header 745 742 746 743 def hasFooters(self): 747 744 return self._footer … … 769 766 770 767 class Container(object): 771 768 772 769 def __init__(self, sesSlot ): 773 770 self._sesSlot = sesSlot … … 800 797 def getStartDate(self): 801 798 return self._sesSlot.getStartDate() 802 799 803 800 def getAdjustedStartDate(self, tz=None): 804 801 return self._sesSlot.getAdjustedStartDate(tz) 805 802 806 803 def getEndDate(self): 807 804 return self._sesSlot.getEndDate() … … 809 806 def getAdjustedEndDate(self, tz=None): 810 807 return self._sesSlot.getAdjustedEndDate(tz) 811 808 812 809 def getRoom(self): 813 810 return self._sesSlot.getRoom() … … 845 842 # lastSlot is a day object which is not timezone aware. 846 843 d = lastSlot.getStartDate().astimezone(timezone(tz)) 847 lastSlotStartDate = d.astimezone(timezone(tz)) 844 lastSlotStartDate = d.astimezone(timezone(tz)) 848 845 if lastSlot: 849 846 return entry.getEndDate() > lastSlotStartDate … … 870 867 871 868 class PlainTimeTable(object): 872 869 873 870 def __init__( self, schedule=None, tz = 'UTC' ): 874 871 self._tz = tz … … 879 876 def getTZ(self): 880 877 return self._tz 881 878 882 879 def setStartDate( self, date): 883 880 self._startDate = date … … 885 882 def getStartDate( self ): 886 883 return self._startDate 887 884 888 885 def setEndDate( self, date): 889 886 self._endDate = date 890 887 891 888 def getEndDate( self ): 892 889 return self._endDate … … 915 912 916 913 class PlainDay(object): 917 914 918 915 def __init__( self, date ): 919 916 self._date = date … … 936 933 # to be MUCH optimised 937 934 addedSessions = [] 938 lastIndex=-1 935 lastIndex=-1 939 936 tz = self.getTZ() 940 937 for entry in l: … … 955 952 956 953 class SessionSlot(object): 957 954 958 955 def __init__(self,sesSlot,day): 959 956 self._sesSlot=sesSlot … … 1034 1031 1035 1032 class ConfEntry(object): 1036 1033 1037 1034 def __init__(self, entry): 1038 1035 self._entry = entry -
indico/htdocs/js/indico/Timetable/Base.js
r2d7696 ra217dc 869 869 (result.entry.endDate.time.replaceAll(':','') > 870 870 this.eventInfo.endDate.time.replaceAll(':',''))) { 871 this.eventInfo.endDate.time = result.en dTime;871 this.eventInfo.endDate.time = result.entry.endDate.time; 872 872 } 873 873
Note: See TracChangeset
for help on using the changeset viewer.
