| 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 | |
|---|
| 21 | from MaKaC.common.fossilize import IFossil |
|---|
| 22 | from MaKaC.common.Conversion import Conversion |
|---|
| 23 | from MaKaC.webinterface import urlHandlers |
|---|
| 24 | |
|---|
| 25 | class ICategoryFossil(IFossil): |
|---|
| 26 | |
|---|
| 27 | def getId(self): |
|---|
| 28 | """ Category Id """ |
|---|
| 29 | |
|---|
| 30 | def getName(self): |
|---|
| 31 | """ Category Name """ |
|---|
| 32 | |
|---|
| 33 | class IConferenceMinimalFossil(IFossil): |
|---|
| 34 | |
|---|
| 35 | def getId(self): |
|---|
| 36 | """Conference id""" |
|---|
| 37 | |
|---|
| 38 | def getTitle(self): |
|---|
| 39 | """Conference title""" |
|---|
| 40 | |
|---|
| 41 | class IConferenceFossil(IConferenceMinimalFossil): |
|---|
| 42 | |
|---|
| 43 | def getType(self): |
|---|
| 44 | """ Event type: 'conference', 'meeting', 'simple_event' """ |
|---|
| 45 | |
|---|
| 46 | def getDescription(self): |
|---|
| 47 | """Conference description""" |
|---|
| 48 | |
|---|
| 49 | def getLocation(self): |
|---|
| 50 | """ Location (CERN/...) """ |
|---|
| 51 | getLocation.convert = lambda l: l and l.getName() |
|---|
| 52 | |
|---|
| 53 | def getRoom(self): |
|---|
| 54 | """ Room (inside location) """ |
|---|
| 55 | getRoom.convert = lambda r: r and r.getName() |
|---|
| 56 | |
|---|
| 57 | def getRoomBookingList(self): |
|---|
| 58 | """ Reservations """ |
|---|
| 59 | getRoomBookingList.convert = Conversion.reservationsList |
|---|
| 60 | getRoomBookingList.name = "bookedRooms" |
|---|
| 61 | |
|---|
| 62 | def getStartDate(self): |
|---|
| 63 | """ Start Date """ |
|---|
| 64 | getStartDate.convert = Conversion.datetime |
|---|
| 65 | |
|---|
| 66 | def getEndDate(self): |
|---|
| 67 | """ End Date """ |
|---|
| 68 | getEndDate.convert = Conversion.datetime |
|---|
| 69 | |
|---|
| 70 | def getTimezone(self): |
|---|
| 71 | """ Time zone """ |
|---|
| 72 | |
|---|
| 73 | def getSupportEmail(self): |
|---|
| 74 | """ Support Email """ |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | class IConferenceParticipationMinimalFossil(IFossil): |
|---|
| 78 | |
|---|
| 79 | def getFirstName( self ): |
|---|
| 80 | """ Conference Participation First Name """ |
|---|
| 81 | |
|---|
| 82 | def getFamilyName( self ): |
|---|
| 83 | """ Conference Participation Family Name """ |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | class IConferenceParticipationFossil(IConferenceParticipationMinimalFossil): |
|---|
| 87 | |
|---|
| 88 | def getId( self ): |
|---|
| 89 | """ Conference Participation Id """ |
|---|
| 90 | |
|---|
| 91 | def getFullName( self ): |
|---|
| 92 | """ Conference Participation Full Name """ |
|---|
| 93 | |
|---|
| 94 | def getFullNameNoTitle(self): |
|---|
| 95 | """ Conference Participation Full Name """ |
|---|
| 96 | getFullNameNoTitle.name = "name" |
|---|
| 97 | |
|---|
| 98 | def getAffiliation(self): |
|---|
| 99 | """Conference Participation Affiliation """ |
|---|
| 100 | |
|---|
| 101 | def getAddress(self): |
|---|
| 102 | """Conference Participation Address """ |
|---|
| 103 | |
|---|
| 104 | def getEmail(self): |
|---|
| 105 | """Conference Participation Email """ |
|---|
| 106 | |
|---|
| 107 | def getFax(self): |
|---|
| 108 | """Conference Participation Fax """ |
|---|
| 109 | |
|---|
| 110 | def getTitle(self): |
|---|
| 111 | """Conference Participation Title """ |
|---|
| 112 | |
|---|
| 113 | def getPhone(self): |
|---|
| 114 | """Conference Participation Phone """ |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | class IResourceMinimalFossil(IFossil): |
|---|
| 118 | |
|---|
| 119 | def getName(self): |
|---|
| 120 | """ Name of the Resource """ |
|---|
| 121 | |
|---|
| 122 | class ILinkMinimalFossil(IResourceMinimalFossil): |
|---|
| 123 | |
|---|
| 124 | def getURL(self): |
|---|
| 125 | """ URL of the file pointed by the link """ |
|---|
| 126 | getURL.name = "url" |
|---|
| 127 | |
|---|
| 128 | class ILocalFileMinimalFossil(IResourceMinimalFossil): |
|---|
| 129 | |
|---|
| 130 | def getURL(self): |
|---|
| 131 | """ URL of the Local File """ |
|---|
| 132 | getURL.produce = lambda s: str(urlHandlers.UHFileAccess.getURL(s)) |
|---|
| 133 | getURL.name = "url" |
|---|
| 134 | |
|---|
| 135 | class IResourceFossil(IResourceMinimalFossil): |
|---|
| 136 | |
|---|
| 137 | def getId(self): |
|---|
| 138 | """ Resource Id """ |
|---|
| 139 | |
|---|
| 140 | def getDescription(self): |
|---|
| 141 | """ Resource description """ |
|---|
| 142 | |
|---|
| 143 | def getAccessProtectionLevel(self): |
|---|
| 144 | """ Resource Access Protection Level """ |
|---|
| 145 | getAccessProtectionLevel.name = "protection" |
|---|
| 146 | |
|---|
| 147 | def getReviewingState(self): |
|---|
| 148 | """ Resource reviewing state """ |
|---|
| 149 | |
|---|
| 150 | class ILinkFossil(IResourceFossil, ILinkMinimalFossil): |
|---|
| 151 | |
|---|
| 152 | def getType(self): |
|---|
| 153 | """ Type """ |
|---|
| 154 | getType.produce = lambda s: 'external' |
|---|
| 155 | |
|---|
| 156 | class ILocalFileFossil(IResourceFossil, ILocalFileMinimalFossil): |
|---|
| 157 | |
|---|
| 158 | def getType(self): |
|---|
| 159 | """ Type """ |
|---|
| 160 | getType.produce = lambda s: 'stored' |
|---|
| 161 | |
|---|
| 162 | class ILocalFileExtendedFossil(ILocalFileFossil): |
|---|
| 163 | |
|---|
| 164 | def getFileName(self): |
|---|
| 165 | """ Local File Filename """ |
|---|
| 166 | getFileName.name = "file.fileName" |
|---|
| 167 | |
|---|
| 168 | def getFileType(self): |
|---|
| 169 | """ Local File File Type """ |
|---|
| 170 | getFileType.name = "file.fileType" |
|---|
| 171 | |
|---|
| 172 | def getCreationDate(self): |
|---|
| 173 | """ Local File Creation Date """ |
|---|
| 174 | getCreationDate.convert = lambda s: s.strftime("%d.%m.%Y %H:%M:%S") |
|---|
| 175 | getCreationDate.name = "file.creationDate" |
|---|
| 176 | |
|---|
| 177 | def getSize(self): |
|---|
| 178 | """ Local File File Size """ |
|---|
| 179 | getSize.name = "file.fileSize" |
|---|
| 180 | |
|---|
| 181 | class ILocalFileAbstractMaterialFossil(ILocalFileExtendedFossil): |
|---|
| 182 | |
|---|
| 183 | def getURL(self): |
|---|
| 184 | """ URL of the Local File """ |
|---|
| 185 | getURL.produce = lambda s: str(urlHandlers.UHAbstractAttachmentFileAccess.getURL(s)) |
|---|
| 186 | getURL.name = "url" |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | class IMaterialMinimalFossil(IFossil): |
|---|
| 191 | |
|---|
| 192 | def getId(self): |
|---|
| 193 | """ Material Id """ |
|---|
| 194 | |
|---|
| 195 | def getTitle( self ): |
|---|
| 196 | """ Material Title """ |
|---|
| 197 | |
|---|
| 198 | def getResourceList(self): |
|---|
| 199 | """ Material Resource List """ |
|---|
| 200 | getResourceList.result = {"MaKaC.conference.Link": ILinkMinimalFossil, "MaKaC.conference.LocalFile": ILocalFileMinimalFossil} |
|---|
| 201 | getResourceList.name = "resources" |
|---|
| 202 | |
|---|
| 203 | class IMaterialFossil(IMaterialMinimalFossil): |
|---|
| 204 | |
|---|
| 205 | def getReviewingState(self): |
|---|
| 206 | """ Material Reviewing State """ |
|---|
| 207 | |
|---|
| 208 | def getAccessProtectionLevel(self): |
|---|
| 209 | """ Material Access Protection Level """ |
|---|
| 210 | getAccessProtectionLevel.name = "protection" |
|---|
| 211 | |
|---|
| 212 | def hasProtectedOwner(self): |
|---|
| 213 | """ Does it have a protected owner ?""" |
|---|
| 214 | |
|---|
| 215 | def getDescription(self): |
|---|
| 216 | """ Material Description """ |
|---|
| 217 | |
|---|
| 218 | def isHidden(self): |
|---|
| 219 | """ Whether the Material is hidden or not """ |
|---|
| 220 | isHidden.name = 'hidden' |
|---|
| 221 | |
|---|
| 222 | def getAccessKey(self): |
|---|
| 223 | """ Material Access Key """ |
|---|
| 224 | |
|---|
| 225 | def getResourceList(self): |
|---|
| 226 | """ Material Resource List """ |
|---|
| 227 | getResourceList.result = {"MaKaC.conference.Link": ILinkFossil, "MaKaC.conference.LocalFile": ILocalFileExtendedFossil} |
|---|
| 228 | getResourceList.name = "resources" |
|---|
| 229 | |
|---|
| 230 | def getMainResource(self): |
|---|
| 231 | """ The main resource""" |
|---|
| 232 | getMainResource.result = {"MaKaC.conference.Link": ILinkFossil, "MaKaC.conference.LocalFile": ILocalFileExtendedFossil} |
|---|
| 233 | |
|---|
| 234 | def getType(self): |
|---|
| 235 | """ The type of material""" |
|---|
| 236 | |
|---|
| 237 | def isBuiltin(self): |
|---|
| 238 | """ The material is a default one (builtin) """ |
|---|
| 239 | |
|---|
| 240 | |
|---|
| 241 | class ISessionFossil(IFossil): |
|---|
| 242 | |
|---|
| 243 | def getId(self): |
|---|
| 244 | """ Session Id """ |
|---|
| 245 | #getId.name = "sessionId" |
|---|
| 246 | |
|---|
| 247 | def getTitle(self): |
|---|
| 248 | """ Session Title """ |
|---|
| 249 | |
|---|
| 250 | def getDescription(self): |
|---|
| 251 | """ Session Description """ |
|---|
| 252 | |
|---|
| 253 | def getAllMaterialList(self): |
|---|
| 254 | """ Session List of all material """ |
|---|
| 255 | getAllMaterialList.result = IMaterialFossil |
|---|
| 256 | getAllMaterialList.name = "material" |
|---|
| 257 | |
|---|
| 258 | def getNumSlots(self): |
|---|
| 259 | """ Number of slots present in the session """ |
|---|
| 260 | getNumSlots.produce = lambda s : len(s.getSlotList()) |
|---|
| 261 | |
|---|
| 262 | def getColor(self): |
|---|
| 263 | """ Session Color """ |
|---|
| 264 | |
|---|
| 265 | def getAdjustedStartDate(self): |
|---|
| 266 | """ Session Start Date """ |
|---|
| 267 | getAdjustedStartDate.convert = Conversion.datetime |
|---|
| 268 | getAdjustedStartDate.name = "startDate" |
|---|
| 269 | |
|---|
| 270 | def getAdjustedEndDate(self): |
|---|
| 271 | """ Session End Date """ |
|---|
| 272 | getAdjustedEndDate.convert = Conversion.datetime |
|---|
| 273 | getAdjustedEndDate.name = "endDate" |
|---|
| 274 | |
|---|
| 275 | def getLocation(self): |
|---|
| 276 | """ Session Location """ |
|---|
| 277 | getLocation.convert = Conversion.locationName |
|---|
| 278 | |
|---|
| 279 | def getAddress(self): |
|---|
| 280 | """ Session Address """ |
|---|
| 281 | getAddress.produce = lambda s: s.getLocation() |
|---|
| 282 | getAddress.convert = Conversion.locationAddress |
|---|
| 283 | |
|---|
| 284 | def getRoom(self): |
|---|
| 285 | """ Session Room """ |
|---|
| 286 | getRoom.convert = Conversion.roomName |
|---|
| 287 | |
|---|
| 288 | def getConvenerList(self): |
|---|
| 289 | """ Session Conveners list """ |
|---|
| 290 | getConvenerList.result = IConferenceParticipationFossil |
|---|
| 291 | getConvenerList.name = "sessionConveners" |
|---|
| 292 | |
|---|
| 293 | def isPoster(self): |
|---|
| 294 | """ Is self a Poster Session ? """ |
|---|
| 295 | isPoster.produce = lambda s: s.getScheduleType() == 'poster' |
|---|
| 296 | |
|---|
| 297 | def getTextColor(self): |
|---|
| 298 | """ Session Text Color """ |
|---|
| 299 | |
|---|
| 300 | def getLocator(self): |
|---|
| 301 | pass |
|---|
| 302 | getLocator.convert = Conversion.url(urlHandlers.UHSessionDisplay) |
|---|
| 303 | getLocator.name = 'url' |
|---|
| 304 | |
|---|
| 305 | class ISessionSlotFossil(IFossil): |
|---|
| 306 | |
|---|
| 307 | def getSession(self): |
|---|
| 308 | """ Slot Session """ |
|---|
| 309 | getSession.result = ISessionFossil |
|---|
| 310 | |
|---|
| 311 | def getId(self): |
|---|
| 312 | """ Session Slot Id """ |
|---|
| 313 | getId.name = "sessionSlotId" |
|---|
| 314 | |
|---|
| 315 | def getTitle(self): |
|---|
| 316 | """ Session Slot Title """ |
|---|
| 317 | getTitle.name = "slotTitle" |
|---|
| 318 | |
|---|
| 319 | def getConference(self): |
|---|
| 320 | """ Session Slot Conference """ |
|---|
| 321 | getConference.result = IConferenceFossil |
|---|
| 322 | |
|---|
| 323 | def getRoom(self): |
|---|
| 324 | """ Session Slot Room """ |
|---|
| 325 | getRoom.convert = Conversion.roomName |
|---|
| 326 | |
|---|
| 327 | def getLocationName(self): |
|---|
| 328 | """ Session Slot Location Name """ |
|---|
| 329 | getLocationName.produce = lambda s: s.getLocation() |
|---|
| 330 | getLocationName.convert = Conversion.locationName |
|---|
| 331 | getLocationName.name = "location" |
|---|
| 332 | |
|---|
| 333 | def getLocationAddress(self): |
|---|
| 334 | """ Session Slot Location Address """ |
|---|
| 335 | getLocationAddress.produce = lambda s: s.getLocation() |
|---|
| 336 | getLocationAddress.convert = Conversion.locationAddress |
|---|
| 337 | getLocationAddress.name = "address" |
|---|
| 338 | |
|---|
| 339 | def inheritRoom(self): |
|---|
| 340 | """ Does the Session inherit a Room ?""" |
|---|
| 341 | inheritRoom.produce = lambda s: s.getOwnRoom() is None |
|---|
| 342 | inheritRoom.name = "inheritRoom" |
|---|
| 343 | |
|---|
| 344 | def inheritLocation(self): |
|---|
| 345 | """ Does the Session inherit a Location ?""" |
|---|
| 346 | inheritLocation.produce = lambda s: s.getOwnLocation() is None |
|---|
| 347 | inheritLocation.name = "inheritLoc" |
|---|
| 348 | |
|---|
| 349 | def getOwnConvenerList(self): |
|---|
| 350 | """ Session Slot Conveners List """ |
|---|
| 351 | getOwnConvenerList.result = IConferenceParticipationFossil |
|---|
| 352 | getOwnConvenerList.name = "conveners" |
|---|
| 353 | |
|---|
| 354 | def getStartDate(self): |
|---|
| 355 | """ """ |
|---|
| 356 | getStartDate.produce = lambda s: s.getAdjustedStartDate() |
|---|
| 357 | getStartDate.convert = Conversion.datetime |
|---|
| 358 | |
|---|
| 359 | def getEndDate(self): |
|---|
| 360 | """ """ |
|---|
| 361 | getEndDate.produce = lambda s: s.getAdjustedEndDate() |
|---|
| 362 | getEndDate.convert = Conversion.datetime |
|---|
| 363 | |
|---|
| 364 | class IConferenceEventInfoFossil(IConferenceMinimalFossil): |
|---|
| 365 | """ |
|---|
| 366 | Fossil used to format the 'eventInfo' javascript object used |
|---|
| 367 | in the timetable operations |
|---|
| 368 | """ |
|---|
| 369 | |
|---|
| 370 | def getAddress(self): |
|---|
| 371 | """ Address """ |
|---|
| 372 | getAddress.produce = lambda s: s.getLocation() |
|---|
| 373 | getAddress.convert = Conversion.locationAddress |
|---|
| 374 | |
|---|
| 375 | def getLocation(self): |
|---|
| 376 | """ Location (CERN/...) """ |
|---|
| 377 | getLocation.convert = Conversion.locationName |
|---|
| 378 | |
|---|
| 379 | def getRoom(self): |
|---|
| 380 | """ Room (inside location) """ |
|---|
| 381 | getRoom.convert = Conversion.roomName |
|---|
| 382 | |
|---|
| 383 | def getAdjustedStartDate(self): |
|---|
| 384 | """ Start Date """ |
|---|
| 385 | getAdjustedStartDate.convert = Conversion.datetime |
|---|
| 386 | getAdjustedStartDate.name = "startDate" |
|---|
| 387 | |
|---|
| 388 | def getAdjustedEndDate(self): |
|---|
| 389 | """ End Date """ |
|---|
| 390 | getAdjustedEndDate.convert = Conversion.datetime |
|---|
| 391 | getAdjustedEndDate.name = "endDate" |
|---|
| 392 | |
|---|
| 393 | def getSessions(self): |
|---|
| 394 | """ Conference Sessions """ |
|---|
| 395 | getSessions.produce = lambda s: Conversion.sessionList(s) |
|---|
| 396 | getSessions.result = ISessionFossil |
|---|
| 397 | |
|---|
| 398 | def isConference(self): |
|---|
| 399 | """ Is this event a conference ? """ |
|---|
| 400 | isConference.produce = lambda s : s.getType() == 'conference' |
|---|
| 401 | |
|---|
| 402 | def getFavoriteRooms(self): |
|---|
| 403 | """ Favorite Rooms """ |
|---|
| 404 | |
|---|
| 405 | def getRoomBookingList(self): |
|---|
| 406 | """ Reservations """ |
|---|
| 407 | getRoomBookingList.convert = Conversion.reservationsList |
|---|
| 408 | getRoomBookingList.name = "bookedRooms" |
|---|