source: indico/indico/MaKaC/services/implementation/conference.py @ 138bf2

burotelhello-world-walkthroughipv6new-webexv0.97-seriesv0.98-seriesv0.98.2v0.98.3v0.98b1v0.98b2v0.99v1.0v1.1
Last change on this file since 138bf2 was 138bf2, checked in by Jose Benito <jose.benito.gonzalez@…>, 3 years ago

[FIX] Room booking in timetable

  • booked rooms are now displayed at the very top of the dropdown list in the roombooking widget
  • if there's a collision in roombooking (selected room is already booked in this event at the same time) name of the room turns red, otherwise it's green.
  • checking collision is affected by changes of the contribution time
  • room and location can be edited in timetable management popups
  • room booking widget is now positioned by css, not by table, to avoid IE problem with colspan atrribute
  • room inheritance problems with session slots were solved - fossils were modified, parent's room is displayed properly
  • interface improvements in inline room/location edit in timetable popups
  • entry in user guide added
  • user is inform when trying to use rooms outside their booking time
  • session intervals are also taken into account while checking room availabilty
  • contribution data modification website now works correctly for intervals - contribution id wasn't passed correctly
  • dateField widget now informs about state changes while clicking at the calendar
  • icons in popups added
  • booked rooms are separated from the rest in a room list widget
  • some colors changed
  • roombooking widget works fine while roombooking module is deactiveted
  • repetetive bookings working correctly
  • creating new booking in contributon listing fixed
  • fix#472
  • Property mode set to 100644
File size: 26.5 KB
Line 
1"""
2Asynchronous request handlers for conference-related data modification.
3"""
4
5from MaKaC.services.implementation.base import ProtectedModificationService,\
6    ListModificationBase, ParameterManager
7from MaKaC.services.implementation.base import ProtectedDisplayService, ServiceBase
8
9import MaKaC.webinterface.displayMgr as displayMgr
10
11from MaKaC.common.Configuration import Config
12from MaKaC.common import filters
13from MaKaC.common.utils import validMail, setValidEmailSeparators
14from MaKaC.common.fossilize import fossilize
15from MaKaC.common import indexes, info
16from MaKaC.common.fossilize import fossilize
17
18from MaKaC.conference import ConferenceHolder
19import MaKaC.conference as conference
20from MaKaC.services.implementation.base import TextModificationBase
21from MaKaC.services.implementation.base import HTMLModificationBase
22from MaKaC.services.implementation.base import DateTimeModificationBase
23from MaKaC.webinterface.rh.reviewingModif import RCReferee, RCPaperReviewManager
24from MaKaC.webinterface.common import contribFilters
25import MaKaC.webinterface.wcomponents as wcomponents
26import MaKaC.webinterface.urlHandlers as urlHandlers
27import MaKaC.common.timezoneUtils as timezoneUtils
28from MaKaC.common.contextManager import ContextManager
29from MaKaC.user import PrincipalHolder, Avatar, Group
30
31import datetime
32from pytz import timezone
33
34from MaKaC.errors import TimingError
35from MaKaC.common.logger import Logger
36from MaKaC.i18n import _
37
38from MaKaC.services.interface.rpc.common import ServiceError, Warning, \
39        ResultWithWarning, TimingNoReportError, ServiceAccessError
40from MaKaC.fossils.contribution import IContributionFossil
41
42class ConferenceBase(object):
43    """
44    Base class for conference modification
45    """
46
47    def _checkParams( self ):
48
49        try:
50            self._target = self._conf = ConferenceHolder().getById(self._params["conference"]);
51        except:
52            try:
53                self._target = self._conf = ConferenceHolder().getById(self._params["confId"]);
54            except:
55                raise ServiceError("ERR-E4", "Invalid conference id.")
56            if self._target == None:
57                Logger.get('rpc.conference').debug('self._target is null')
58                raise Exception("Null target.")
59
60
61    def _getCheckFlag(self):
62        """
63        Returns the "check" flag, a value that specifies what kind of
64        checking should be done before modifying. Classes that wish
65        to change this behavior should overload it.
66        """
67
68        # automatically adapt everything
69        return 2
70
71
72class ConferenceModifBase(ProtectedModificationService, ConferenceBase):
73    def _checkParams(self):
74        ConferenceBase._checkParams(self)
75        ProtectedModificationService._checkParams(self)
76
77class ConferenceScheduleModifBase(ConferenceModifBase):
78    def _checkParams(self):
79        ConferenceModifBase._checkParams(self)
80
81        self._schEntry = self._conf.getSchedule().getEntryById(self._params["scheduleEntry"])
82        if self._schEntry == None:
83            raise ServiceError("ERR-E4", "Invalid scheduleEntry id.")
84
85    def _checkProtection( self ):
86        self._target = self._schEntry.getOwner()
87        ConferenceModifBase._checkProtection(self)
88
89class ConferenceDisplayBase(ProtectedDisplayService, ConferenceBase):
90
91    def _checkParams(self):
92        ConferenceBase._checkParams(self)
93        ProtectedDisplayService._checkParams(self)
94
95class ConferenceTextModificationBase(TextModificationBase, ConferenceModifBase):
96    #Note: don't change the order of the inheritance here!
97    pass
98
99class ConferenceHTMLModificationBase(HTMLModificationBase, ConferenceModifBase):
100    #Note: don't change the order of the inheritance here!
101    pass
102
103class ConferenceDateTimeModificationBase (DateTimeModificationBase, ConferenceModifBase):
104    #Note: don't change the order of the inheritance here!
105    pass
106
107class ConferenceListModificationBase (ListModificationBase, ConferenceModifBase):
108    #Note: don't change the order of the inheritance here!
109    pass
110
111
112class ConferenceTitleModification( ConferenceTextModificationBase ):
113    """
114    Conference title modification
115    """
116    def _handleSet(self):
117        title = self._value
118        if (title ==""):
119            raise ServiceError("ERR-E2",
120                               "The title cannot be empty")
121        self._target.setTitle(self._value)
122
123    def _handleGet(self):
124        return self._target.getTitle()
125
126
127class ConferenceDescriptionModification( ConferenceHTMLModificationBase ):
128    """
129    Conference description modification
130    """
131    def _handleSet(self):
132        self._target.setDescription(self._value)
133
134    def _handleGet(self):
135        return self._target.getDescription()
136
137class ConferenceAdditionalInfoModification( ConferenceHTMLModificationBase ):
138    """
139    Conference additional info (a.k.a contact info) modification
140    """
141    def _handleSet(self):
142        self._target.setContactInfo(self._value)
143
144    def _handleGet(self):
145        return self._target.getContactInfo()
146
147class ConferenceTypeModification( ConferenceTextModificationBase ):
148    """
149    Conference title modification
150    """
151    def _handleSet(self):
152        curType = self._target.getType()
153        newType = self._value
154        if newType != "" and newType != curType:
155            import MaKaC.webinterface.webFactoryRegistry as webFactoryRegistry
156            wr = webFactoryRegistry.WebFactoryRegistry()
157            factory = wr.getFactoryById(newType)
158            wr.registerFactory(self._target, factory)
159
160            styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
161
162            dispMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target)
163            dispMgr.setDefaultStyle(styleMgr.getDefaultStylesheetForEventType(newType))
164
165    def _handleGet(self):
166        return self._target.getType()
167
168
169class ConferenceBookingModification( ConferenceTextModificationBase ):
170    """
171    Conference location name modification
172    """
173    def _handleSet(self):
174        room = self._target.getRoom()
175
176        if  room == None:
177            room = conference.CustomRoom()
178            self._target.setRoom(room)
179
180        # if a room name is not passed, it is assumed
181        # as empty
182        if 'room' in self._value:
183            room.setName( self._value['room'] )
184
185        loc = self._target.getLocation()
186        if not loc:
187            loc = conference.CustomLocation()
188            self._target.setLocation(loc)
189
190        if 'location' in self._value:
191            loc.setName( self._value['location'] )
192
193        loc.setAddress( self._value['address'] )
194
195    def _handleGet(self):
196
197        loc = self._target.getLocation()
198        room = self._target.getRoom()
199        if loc:
200            locName = loc.getName()
201            locAddress = loc.getAddress()
202        else:
203            locName = None
204            locAddress = ''
205        if room:
206            roomName = room.name
207        else:
208            roomName = None
209
210        return { 'location': locName,
211                 'room': roomName,
212                 'address': locAddress }
213
214class ConferenceBookingDisplay( ConferenceDisplayBase ):
215    """
216        Conference location
217    """
218    def _getAnswer(self):
219        loc = self._target.getLocation()
220        room = self._target.getRoom()
221        if loc:
222            locName = loc.getName()
223            locAddress = loc.getAddress()
224        else:
225            locName = ''
226            locAddress = ''
227        if room:
228            roomName = room.name
229        else:
230            roomName = ''
231
232        return { 'location': locName,
233                 'room': roomName,
234                 'address': locAddress }
235
236class ConferenceSpeakerTextModification( ConferenceTextModificationBase ):
237    """ Conference chairman text modification (for conferences and meetings)
238    """
239    def _handleSet(self):
240        self._target.setChairmanText(self._value)
241
242    def _handleGet(self):
243        return self._target.getChairmanText()
244
245class ConferenceOrganiserTextModification( ConferenceTextModificationBase ):
246    """ Conference organiser text modification (for lectures)
247    """
248    def _handleSet(self):
249        self._target.setOrgText(self._value)
250
251    def _handleGet(self):
252        return self._target.getOrgText()
253
254class ConferenceSupportEmailModification( ConferenceTextModificationBase ):
255    """
256    Conference support e-mail modification
257    """
258    def _handleSet(self):
259        # handling the case of a list of emails with separators different than ","
260        emailstr = setValidEmailSeparators(self._value)
261
262        if validMail(emailstr) or emailstr == '':
263            self._target.setSupportEmail(emailstr)
264        else:
265            raise ServiceError('ERR-E0', 'E-mail address %s is not valid!' %
266                               self._value)
267
268    def _handleGet(self):
269        return self._target.getSupportEmail()
270
271class ConferenceSupportModification( ConferenceTextModificationBase ):
272    """
273    Conference support caption and e-mail modification
274    """
275    def _handleSet(self):
276        dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target)
277        caption = self._value.get("caption","")
278        email = self._value.get("email")
279
280        if caption == "":
281            raise ServiceError("ERR-E2", "The caption cannot be empty")
282        dMgr.setSupportEmailCaption(caption)
283
284        # handling the case of a list of emails with separators different than ","
285        email = setValidEmailSeparators(email)
286
287        if validMail(email) or email == "":
288            self._target.setSupportEmail(email)
289        else:
290            raise ServiceError('ERR-E0', 'E-mail address %s is not valid!' %
291                               self._value)
292
293    def _handleGet(self):
294        dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target)
295        caption = dMgr.getSupportEmailCaption()
296        email = self._target.getSupportEmail()
297
298        return { "caption": caption,
299                 "email": email }
300
301class ConferenceDefaultStyleModification( ConferenceTextModificationBase ):
302    """
303    Conference default style modification
304    """
305    def _handleSet(self):
306        dispManReg = displayMgr.ConfDisplayMgrRegistery()
307        dispManReg.getDisplayMgr(self._target).setDefaultStyle(self._value)
308
309    def _handleGet(self):
310        dispManReg = displayMgr.ConfDisplayMgrRegistery()
311        return dispManReg.getDisplayMgr(self._target).getDefaultStyle()
312
313class ConferenceVisibilityModification( ConferenceTextModificationBase ):
314    """
315    Conference visibility modification
316    """
317
318    def _handleSet(self):
319        try:
320            val = int(self._value)
321        except ValueError:
322            raise ServiceError("ERR-E1","Invalid value type for property")
323        self._target.setVisibility(val)
324
325    def _handleGet(self):
326        return self._target.getVisibility()
327
328class ConferenceStartEndDateTimeModification( ConferenceModifBase ):
329    """
330    Conference start date/time modification
331
332    When changing the start date / time, the _setParam method will be called
333    by DateTimeModificationBase's _handleSet method.
334    The _setParam method will return None (if there are no problems),
335    or a Warning object if the event start date change was OK but there were
336    side problems, such as an object observing the event start date change
337    could not perform its task
338    (Ex: a videoconference booking could not be moved in time according with
339    the conference's time change)
340    For this, it will check the 'dateChangeNotificationProblems' context variable.
341    """
342
343    def _checkParams(self):
344
345        ConferenceModifBase._checkParams(self)
346
347        pm = ParameterManager(self._params.get('value'), timezone=self._conf.getTimezone())
348
349        self._startDate = pm.extract('startDate', pType=datetime.datetime)
350        self._endDate = pm.extract('endDate', pType=datetime.datetime)
351        self._shiftTimes = pm.extract('shiftTimes', pType=bool)
352
353    def _getAnswer(self):
354
355        ContextManager.set('dateChangeNotificationProblems', {})
356
357        if (self._shiftTimes):
358            moveEntries = 1
359        else:
360            moveEntries = 0
361
362        # first sanity check
363        if (self._startDate > self._endDate):
364            raise ServiceError("ERR-E3",
365                               "Date/time of start cannot "
366                               "be greater than date/time of end")
367
368        # catch TimingErrors that can be returned by the algorithm
369        try:
370            self._target.setDates(self._startDate,
371                                  self._endDate,
372                                  moveEntries = moveEntries)
373        except TimingError,e:
374            raise TimingNoReportError("ERR-E2", e.getMsg(),
375                                      title = _("Cannot set event dates"),
376                                      explanation = e.getExplanation())
377
378        dateChangeNotificationProblems = ContextManager.get('dateChangeNotificationProblems')
379
380        if dateChangeNotificationProblems:
381
382            warningContent = []
383            for problemGroup in dateChangeNotificationProblems.itervalues():
384                warningContent.extend(problemGroup)
385
386            w = Warning(_('Warning'), [_('The start date of your event was changed correctly. '
387                                       'However, there were the following problems:'),
388                                       warningContent])
389
390            return ResultWithWarning(self._params.get('value'), w).fossilize()
391
392        else:
393            return self._params.get('value')
394
395class ConferenceListUsedRooms( ConferenceDisplayBase ):
396    """
397    Get rooms that are used in the context of the conference:
398     * Booked in CRBS
399     * Already chosen in sessions
400    """
401    def _getAnswer( self ):
402        """
403        Calls _handle() on the derived classes, in order to make it happen. Provides
404        them with self._value.
405        """
406        roomList = []
407        roomList.extend(self._target.getRoomList())
408        roomList.extend(map(lambda x: x._getName(), self._target.getBookedRooms()))
409
410        return roomList
411
412
413class ConferenceDateTimeEndModification( ConferenceDateTimeModificationBase ):
414    """ Conference end date/time modification
415        When changing the end date / time, the _setParam method will be called by DateTimeModificationBase's _handleSet method.
416        The _setParam method will return None (if there are no problems),
417        or a FieldModificationWarning object if the event start date change was OK but there were side problems,
418        such as an object observing the event start date change could not perform its task
419        (Ex: a videoconference booking could not be moved in time according with the conference's time change)
420    """
421    def _setParam(self):
422
423        ContextManager.set('dateChangeNotificationProblems', {})
424
425        if (self._pTime < self._target.getStartDate()):
426            raise ServiceError("ERR-E3",
427                               "Date/time of end cannot "+
428                               "be lower than data/time of start")
429        self._target.setDates(self._target.getStartDate(),
430                              self._pTime.astimezone(timezone("UTC")),
431                              moveEntries=0)
432
433        dateChangeNotificationProblems = ContextManager.get('dateChangeNotificationProblems')
434
435        if dateChangeNotificationProblems:
436            warningContent = []
437            for problemGroup in dateChangeNotificationProblems.itervalues():
438                warningContent.extend(problemGroup)
439
440            return Warning(_('Warning'), [_('The end date of your event was changed correctly.'),
441                                          _('However, there were the following problems:'),
442                                          warningContent])
443        else:
444            return None
445
446
447    def _handleGet(self):
448        return datetime.datetime.strftime(self._target.getAdjustedEndDate(),
449                                          '%d/%m/%Y %H:%M')
450
451
452class ConferenceListContributions (ConferenceListModificationBase):
453    """ Returns a list of all contributions of a conference, ordered by id
454    """
455    def _checkParams(self):
456        ConferenceListModificationBase._checkParams(self)
457        pm = ParameterManager(self._params)
458        self._selTypes = pm.extract("selTypes", pType=list, allowEmpty = True) #ids of selected types
459        self._selTracks = pm.extract("selTracks", pType=list, allowEmpty = True) #ids of selected tracks
460        self._selSessions = pm.extract("selSessions", pType=list, allowEmpty = True) #ids of selected sessions
461
462        self._typeShowNoValue = self._params.get("typeShowNoValue", True)
463        self._trackShowNoValue = self._params.get("trackShowNoValue", True)
464        self._sessionShowNoValue = self._params.get("sessionShowNoValue", True)
465
466        self._showWithReferee = self._params.get("showWithReferee", False)
467        self._showWithEditor = self._params.get("showWithEditor", False)
468        self._showWithReviewer = self._params.get("showWithReviewer", False)
469
470        self._poster = self._params.get("poster", False)
471        self._posterShowNoValue = self._params.get("posterShowNoValue", True)
472
473    def _checkProtection(self):
474        if not RCPaperReviewManager.hasRights(self) and not RCReferee.hasRights(self):
475            ProtectedModificationService._checkProtection(self)
476
477    def _handleGet(self):
478        contributions = self._conf.getContributionList()
479
480        filter = {}
481
482        #filtering if the active user is a referee: he can only see his own contribs
483        isOnlyReferee = RCReferee.hasRights(self) \
484                        and not RCPaperReviewManager.hasRights(self) \
485                        and not self._conf.canModify(self.getAW())
486        if isOnlyReferee:
487            filter["referee"] = self._getUser()
488        elif self._showWithReferee:
489            filter["referee"] = "any"
490        else:
491            filter["referee"] = None
492
493        if self._showWithEditor:
494            filter["editor"] = "any"
495        else:
496            filter["editor"] = None
497        if self._showWithReviewer:
498            filter["reviewer"] = "any"
499        else:
500            filter["reviewer"] = None
501
502
503        #note by David: I added "if self._selTypes..." and the other ifs after this line,
504        #in order to make the recording request load contributions work
505        #but, it may break the paper reviewing module -> assign contributions filter
506        if self._selTypes:
507            filter["type"] = self._selTypes
508        if self._selTracks:
509            filter["track"] = self._selTracks
510        if self._selSessions:
511            filter["session"] = self._selSessions
512        if self._poster:
513            filter["poster"] = self._poster
514
515        filterCrit = ContributionsReviewingFilterCrit(self._conf, filter)
516        sortingCrit = contribFilters.SortingCriteria(["number"])
517
518        if self._selTypes:
519            filterCrit.getField("type").setShowNoValue( self._typeShowNoValue )
520        if self._selTracks:
521            filterCrit.getField("track").setShowNoValue( self._trackShowNoValue )
522        if self._selSessions:
523            filterCrit.getField("session").setShowNoValue( self._sessionShowNoValue )
524        if self._poster:
525            filterCrit.getField("poster").setShowNoValue( self._posterShowNoValue )
526
527        filterCrit.getField("referee").setShowNoValue( not isOnlyReferee )
528
529        f= filters.SimpleFilter(filterCrit, sortingCrit)
530        contributions = f.apply(contributions)
531
532        return fossilize(contributions, IContributionFossil)
533
534#########################
535# Contribution filtering
536#########################
537
538class ContributionsReviewingFilterCrit(filters.FilterCriteria):
539    _availableFields = {
540        contribFilters.RefereeFilterField.getId() : contribFilters.RefereeFilterField,
541        contribFilters.EditorFilterField.getId() : contribFilters.EditorFilterField,
542        contribFilters.ReviewerFilterField.getId() : contribFilters.ReviewerFilterField,
543        contribFilters.TypeFilterField.getId() : contribFilters.TypeFilterField,
544        contribFilters.TrackFilterField.getId() : contribFilters.TrackFilterField,
545        contribFilters.SessionFilterField.getId() : contribFilters.SessionFilterField,
546        contribFilters.PosterFilterField.getId() : contribFilters.PosterFilterField
547    }
548
549#############################
550# Conference Modif Display  #
551#############################
552
553class ConferencePicDelete(ConferenceModifBase):
554
555    def _checkParams(self):
556        ConferenceModifBase._checkParams(self)
557
558        pm = ParameterManager(self._params)
559
560        self._id = pm.extract("picId", pType=str, allowEmpty=False)
561
562    def _getAnswer(self):
563        im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getImagesManager()
564        im.removePic(self._id)
565
566#############################
567# Conference cretion        #
568#############################
569
570class ShowConcurrentEvents(ServiceBase):
571
572    def _checkParams(self):
573        ServiceBase._checkParams(self)
574
575        pm = ParameterManager(self._params)
576
577        self._tz = pm.extract("timezone", pType=str, allowEmpty=False)
578        pm.setTimezone(self._tz)
579        self._sDate = pm.extract("sDate", pType=datetime.datetime, allowEmpty=False)
580        self._eDate = pm.extract("eDate", pType=datetime.datetime, allowEmpty=False)
581
582    def _getAnswer( self ):
583        im = indexes.IndexesHolder()
584        ch = ConferenceHolder()
585        calIdx = im.getIndex("calendar")
586        evtIds = calIdx.getObjectsIn(self._sDate, self._eDate)
587
588        evtsByCateg={}
589        for evtId in evtIds:
590            try:
591                evt = ch.getById(evtId)
592                categs =evt.getOwnerList()
593                categname =categs[0].getName()
594                if not evtsByCateg.has_key(categname):
595                    evtsByCateg[categname] = []
596                evtsByCateg[categname].append((evt.getTitle().strip(),evt.getAdjustedStartDate().strftime('%d/%m/%Y %H:%M '),evt.getAdjustedEndDate().strftime('%d/%m/%Y %H:%M '), evt.getTimezone()))
597
598            except Exception:
599                continue
600        return evtsByCateg
601
602
603class ConferenceGetFieldsAndContribTypes(ConferenceDisplayBase):
604    def _getAnswer( self ):
605        afm = self._target.getAbstractMgr().getAbstractFieldsMgr()
606        afmDict =  dict([(f.getId(), f.getName()) for f in afm.getFields()])
607        cTypes = self._target.getContribTypeList()
608        cTypesDict =  dict([(ct.getId(), ct.getName()) for ct in cTypes])
609        return [afmDict, cTypesDict]
610
611
612class ConferenceParticipationForm(ConferenceDisplayBase):
613    def _getAnswer(self):
614
615        params = {}
616
617        if self._conf.getStartDate() < timezoneUtils.nowutc() :
618            return """This event began on %s, you cannot apply for
619                      participation after the event began."""%self._conf.getStartDate()
620
621        if not self._conf.getParticipation().isAllowedForApplying() :
622            return """Participation in this event is restricted to persons invited.
623                      If you insist on taking part in this event, please contact the event manager."""
624
625        p = wcomponents.WNewPerson()
626
627        params["formAction"] = str(urlHandlers.UHConfParticipantsAddPending.getURL(self._conf))
628        params["formTitle"] = None
629        params["cancelButtonParams"] = """ type="button" id="cancelRegistrationButton" """
630
631        params["titleValue"] = ""
632        params["surNameValue"] = ""
633        params["nameValue"] = ""
634        params["emailValue"] = ""
635        params["addressValue"] = ""
636        params["affiliationValue"] = ""
637        params["phoneValue"] = ""
638        params["faxValue"] = ""
639
640        user = self._getUser()
641        if user is not None :
642            params["titleValue"] = user.getTitle()
643            params["surNameValue"] = user.getFamilyName()
644            params["nameValue"] = user.getName()
645            params["emailValue"] = user.getEmail()
646            params["addressValue"] = user.getAddress()
647            params["affiliationValue"] = user.getAffiliation()
648            params["phoneValue"] = user.getTelephone()
649            params["faxValue"] = user.getFax()
650
651            params["disabledTitle"] = params["disabledSurName"] = True
652            params["disabledName"] = params["disabledEmail"] = True
653            params["disabledAddress"] = params["disabledPhone"] = True
654            params["disabledFax"] = params["disabledAffiliation"] = True
655
656        return p.getHTML(params)
657
658class ConferenceProtectionUserList(ConferenceModifBase):
659
660    def _getAnswer(self):
661        #will use IAvatarFossil or IGroupFossil
662        return fossilize(self._conf.getAllowedToAccessList())
663
664class ConferenceProtectionAddUsers(ConferenceModifBase):
665
666    def _checkParams(self):
667        ConferenceModifBase._checkParams(self)
668
669        self._usersData = self._params['value']
670        self._user = self.getAW().getUser()
671
672    def _getAnswer(self):
673
674        for user in self._usersData :
675
676            userToAdd = PrincipalHolder().getById(user['id'])
677
678            if not userToAdd :
679                raise ServiceError("ERR-U0","User does not exist!")
680
681            self._conf.grantAccess(userToAdd)
682
683class ConferenceProtectionRemoveUser(ConferenceModifBase):
684
685    def _checkParams(self):
686        ConferenceModifBase._checkParams(self)
687
688        self._userData = self._params['value']
689
690        self._user = self.getAW().getUser()
691
692    def _getAnswer(self):
693
694        userToRemove = PrincipalHolder().getById(self._userData['id'])
695
696        if not userToRemove :
697            raise ServiceError("ERR-U0","User does not exist!")
698        elif isinstance(userToRemove, Avatar) or isinstance(userToRemove, Group) :
699            self._conf.revokeAccess(userToRemove)
700
701
702methodMap = {
703    "main.changeTitle": ConferenceTitleModification,
704    "main.changeSupportEmail": ConferenceSupportEmailModification,
705    "main.changeSupport": ConferenceSupportModification,
706    "main.changeSpeakerText": ConferenceSpeakerTextModification,
707    "main.changeOrganiserText": ConferenceOrganiserTextModification,
708    "main.changeDefaultStyle": ConferenceDefaultStyleModification,
709    "main.changeVisibility": ConferenceVisibilityModification,
710    "main.changeType": ConferenceTypeModification,
711    "main.changeDescription": ConferenceDescriptionModification,
712    "main.changeAdditionalInfo": ConferenceAdditionalInfoModification,
713    "main.changeDates": ConferenceStartEndDateTimeModification,
714    "main.changeBooking": ConferenceBookingModification,
715    "main.displayBooking": ConferenceBookingModification,
716    "rooms.list" : ConferenceListUsedRooms,
717    "contributions.list" : ConferenceListContributions,
718    "pic.delete": ConferencePicDelete,
719    "showConcurrentEvents": ShowConcurrentEvents,
720#    "getFields": ConferenceGetFields,
721    "getFieldsAndContribTypes": ConferenceGetFieldsAndContribTypes,
722    "getParticipationForm": ConferenceParticipationForm,
723    "protection.getAllowedUsersList": ConferenceProtectionUserList,
724    "protection.addAllowedUsers": ConferenceProtectionAddUsers,
725    "protection.removeAllowedUser": ConferenceProtectionRemoveUser
726    }
Note: See TracBrowser for help on using the repository browser.