示例#1
0
    def _doApply(self):
        """ """
        if not self.mayChangeAttendees():
            raise Unauthorized

        items_to_update = _itemsToUpdate(
            from_item_number=self.context.getItemNumber(relativeTo='meeting'),
            until_item_number=self.apply_until_item_number,
            meeting=self.meeting)

        # apply removal of redefined attendee position
        for item_to_update in items_to_update:
            item_to_update_uid = item_to_update.UID()
            item_attendees_positions = self.meeting.item_attendees_positions.get(
                item_to_update_uid, {})
            if self.person_uid in item_attendees_positions:
                del item_attendees_positions[self.person_uid]
            if not item_attendees_positions:
                del self.meeting.item_attendees_positions[item_to_update_uid]
                notifyModifiedAndReindex(item_to_update)
        first_item_number = items_to_update[0].getItemNumber(for_display=True)
        last_item_number = items_to_update[-1].getItemNumber(for_display=True)
        extras = 'item={0} hp={1} from_item_number={2} until_item_number={3}'.format(
            repr(self.context), self.person_uid, first_item_number,
            last_item_number)
        fplog('remove_redefined_item_attendee_position', extras=extras)
        api.portal.show_message(_("Redefined attendee position was removed."),
                                request=self.request)
        self._finished = True
示例#2
0
    def _doApply(self):
        """ """
        if not self.mayChangeAttendees():
            raise Unauthorized

        items_to_update = _itemsToUpdate(
            from_item_number=self.context.getItemNumber(relativeTo='meeting'),
            until_item_number=self.apply_until_item_number,
            meeting=self.meeting)

        # apply redefined position
        for item_to_update in items_to_update:
            item_to_update_uid = item_to_update.UID()
            updated = set_meeting_item_attendee_position(
                self.meeting, item_to_update_uid, self.person_uid,
                self.position_type)
            if updated:
                notifyModifiedAndReindex(item_to_update)
        first_item_number = items_to_update[0].getItemNumber(for_display=True)
        last_item_number = items_to_update[-1].getItemNumber(for_display=True)
        extras = 'item={0} hp={1} from_item_number={2} until_item_number={3}'.format(
            repr(self.context), self.person_uid, first_item_number,
            last_item_number)
        fplog('redefine_item_attendee_position', extras=extras)
        api.portal.show_message(_("Attendee position has been redefined."),
                                request=self.request)
        self._finished = True
示例#3
0
    def _doApply(self):
        """ """
        if not self.mayChangeAttendees():
            raise Unauthorized

        # check where is person_uid, item_absents or item_excused
        meeting_absent_attr = self._get_meeting_absent_attr()
        items_to_update = _itemsToUpdate(
            from_item_number=self.context.getItemNumber(relativeTo='meeting'),
            until_item_number=self.apply_until_item_number,
            meeting=self.meeting)
        for item_to_update in items_to_update:
            item_to_update_uid = item_to_update.UID()
            item_absents = meeting_absent_attr.get(item_to_update_uid, [])
            if self.person_uid in item_absents:
                item_absents.remove(self.person_uid)
                meeting_absent_attr[item_to_update_uid] = item_absents
                notifyModifiedAndReindex(item_to_update)
        first_item_number = items_to_update[0].getItemNumber(for_display=True)
        last_item_number = items_to_update[-1].getItemNumber(for_display=True)
        extras = 'item={0} hp={1} from_item_number={2} until_item_number={3}'.format(
            repr(self.context), self.person_uid, first_item_number,
            last_item_number)
        fplog('welcome_item_attendee', extras=extras)
        api.portal.show_message(self.attendee_welcome_msg,
                                request=self.request)
        self._finished = True
示例#4
0
 def remove(self, label_id):
     """Protect against removal of used labels."""
     cfg = self.context
     brains = api.content.find(portal_type=cfg.getItemTypeName(), labels=label_id)
     if brains:
         api.portal.show_message(
             _('This label can not be removed as it is used by some items, for example ${item_url}',
               mapping={'item_url': brains[0].getURL()}),
             type='error',
             request=self.context.REQUEST)
         return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST['HTTP_REFERER'])
     notifyModifiedAndReindex(self.context)
     return super(PMLabelJar, self).remove(label_id)
示例#5
0
    def toggle(self, UID):
        if not self.context.adapted().maySignItem():
            raise Unauthorized

        # do this as Manager
        with api.env.adopt_roles([
                'Manager',
        ]):
            itemIsSigned = not self.context.getItemIsSigned()
            self.context.setItemIsSigned(itemIsSigned)
            notifyModifiedAndReindex(self.context,
                                     extra_idxs=['item_is_signed'])

        # check again if member can signItem now that it has been signed
        # by default, when an item is signed, it can not be unsigned
        maySignItem = self.context.adapted().maySignItem()
        if itemIsSigned:
            filename = 'itemIsSignedYes.png'
            name = 'itemIsSignedNo'
            if maySignItem:
                title_msgid = 'item_is_signed_yes_edit'
            else:
                title_msgid = 'item_is_signed_yes'
        else:
            filename = 'itemIsSignedNo.png'
            name = 'itemIsSignedYes'
            if maySignItem:
                title_msgid = 'item_is_signed_no_edit'
            else:
                title_msgid = 'item_is_signed_no'

        title = translate(msgid=title_msgid,
                          domain="PloneMeeting",
                          context=self.request)
        portal_state = getMultiAdapter((self.context, self.request),
                                       name=u"plone_portal_state")
        portal_url = portal_state.portal_url()
        src = "%s/%s" % (portal_url, filename)
        # manage the onclick if the user still may change the value
        # let onclick be managed by the jQuery method if we do not need to change it
        # just redefines it to "" if we really want to specify that we do not want an onclick
        onclick = not maySignItem and 'onclick=""' or ''
        # manage the applied css_class : if the user still may edit the value, use 'itemIsSignedEditable'
        # if he can no more change the value, do not use a css_class
        css_class = maySignItem and 'itemIsSignedEditable' or ''
        html = self.IMG_TEMPLATE % (css_class, src, title, name, onclick)
        return html
示例#6
0
    def _doApply(self):
        """ """
        if not self.mayChangeAttendees():
            raise Unauthorized

        items_to_update = _itemsToUpdate(
            from_item_number=self.context.getItemNumber(relativeTo='meeting'),
            until_item_number=self.apply_until_item_number,
            meeting=self.meeting)

        # return a portal_message if trying to byebye an attendee that is
        # a signatory redefined on the item
        # user will first have to select another signatory on meeting or item
        # return a portal_message if trying to set absent and item that is
        # already excused (and the other way round)
        error = self._mayByeByeAttendeePrecondition(items_to_update)
        if error:
            self._finished = True
            return

        # apply item_absents/item_excused
        meeting_not_present_attr = getattr(
            self.meeting, self.NOT_PRESENT_MAPPING[self.not_present_type])
        for item_to_update in items_to_update:
            item_to_update_uid = item_to_update.UID()
            item_not_present = meeting_not_present_attr.get(
                item_to_update_uid, [])
            if self.person_uid not in item_not_present:
                item_not_present.append(self.person_uid)
                meeting_not_present_attr[item_to_update_uid] = item_not_present
                notifyModifiedAndReindex(item_to_update)
        first_item_number = items_to_update[0].getItemNumber(for_display=True)
        last_item_number = items_to_update[-1].getItemNumber(for_display=True)
        extras = 'item={0} hp={1} not_present_type={2} from_item_number={3} until_item_number={4}'.format(
            repr(self.context), self.person_uid, self.not_present_type,
            first_item_number, last_item_number)
        fplog('byebye_item_attendee', extras=extras)
        api.portal.show_message(_("Attendee has been set ${not_present_type}.",
                                  mapping={
                                      'not_present_type':
                                      _('item_not_present_type_{0}'.format(
                                          self.not_present_type))
                                  }),
                                request=self.request)
        self._finished = True
示例#7
0
    def _doApplyItemAssembly(self):
        """
          The method actually do the job, set the itemAssembly on self.context
          and following items if defined
        """
        self._check_auth()
        # only update if default proposed value was changed
        item_assembly_def = item_assembly_default()
        item_excused_def = item_excused_default()
        item_absents_def = item_absents_default()
        item_guests_def = item_guests_default()
        from_item_number = self.context.getItemNumber(relativeTo='meeting')
        until_item_number = self.apply_until_item_number
        items_to_update = _itemsToUpdate(
            from_item_number=from_item_number,
            until_item_number=until_item_number,
            meeting=self.meeting)
        for itemToUpdate in items_to_update:
            # only update if we changed default value
            if self.item_assembly != item_assembly_def:
                itemToUpdate.setItemAssembly(self.item_assembly)
            if self.item_excused != item_excused_def:
                itemToUpdate.setItemAssemblyExcused(self.item_excused)
            if self.item_absents != item_absents_def:
                itemToUpdate.setItemAssemblyAbsents(self.item_absents)
            if self.item_guests != item_guests_def:
                itemToUpdate.setItemAssemblyGuests(self.item_guests)
            notifyModifiedAndReindex(itemToUpdate)

        # invalidate assembly async load on item
        invalidate_cachekey_volatile_for(
            'Products.PloneMeeting.browser.async.AsyncLoadItemAssemblyAndSignaturesRawFields',
            get_again=True)

        first_item_number = items_to_update[0].getItemNumber(for_display=True)
        last_item_number = items_to_update[-1].getItemNumber(for_display=True)
        extras = 'item={0} from_item_number={1} until_item_number={2}'.format(
            repr(self.context), first_item_number, last_item_number)
        fplog('manage_item_assembly', extras=extras)
        api.portal.show_message(_("Item assemblies have been updated."), request=self.request)
        self._finished = True
示例#8
0
    def _doApply(self):
        """ """
        if not self.mayChangeAttendees():
            raise Unauthorized

        items_to_update = _itemsToUpdate(
            from_item_number=self.context.getItemNumber(relativeTo='meeting'),
            until_item_number=self.apply_until_item_number,
            meeting=self.meeting)

        # apply signatory
        for item_to_update in items_to_update:
            item_to_update_uid = item_to_update.UID()
            item_signatories = self.meeting.item_signatories.get(
                item_to_update_uid, {})
            signature_number = [
                k for k, v in item_signatories.items()
                if v['hp_uid'] == self.person_uid
            ]
            if signature_number:
                del item_signatories[signature_number[0]]
                # if no more redefined item signatories,
                # remove item UID from meeting.item_signatories
                if item_signatories:
                    self.meeting.item_signatories[
                        item_to_update_uid] = item_signatories
                else:
                    del self.meeting.item_signatories[item_to_update_uid]
                notifyModifiedAndReindex(item_to_update)
        first_item_number = items_to_update[0].getItemNumber(for_display=True)
        last_item_number = items_to_update[-1].getItemNumber(for_display=True)
        extras = 'item={0} hp={1} from_item_number={2} until_item_number={3}'.format(
            repr(self.context), self.person_uid, first_item_number,
            last_item_number)
        fplog('remove_redefined_item_signatory', extras=extras)
        api.portal.show_message(
            _("Attendee is no more defined as item signatory."),
            request=self.request)
        self._finished = True
示例#9
0
class ChangeItemListTypeView(BrowserView):
    '''This manage the item listType changes.'''
    def __init__(self, context, request):
        super(BrowserView, self).__init__(context, request)
        self.context = context
        self.request = request

    def __call__(self, new_value):
        '''Change listType value.'''
        self._changeListType(new_value)

    def _changeListType(self, new_value):
        '''Helper method that changes listType value and check that :
           - new_value is among selectable listType values;
           - user actually mayChangeListType.'''
        # make sure new_value exists
        factory = queryUtility(
            IVocabularyFactory,
            'Products.PloneMeeting.vocabularies.listtypesvocabulary')
        if new_value not in factory(self.context):
            raise KeyError(
                "New value '{0}' does not correspond to a value of MeetingItem.listType"
                .format(new_value))

        if not self.context.adapted().mayChangeListType():
            raise Unauthorized

        # save old_listType so we can pass it the the ItemListTypeChangedEvent
        # set the new listType and notify events
        old_listType = self.context.getListType()
        self.context.setListType(new_value)
        self.context._update_after_edit(idxs=['listType'])
        try:
            notify(ItemListTypeChangedEvent(self.context, old_listType))
        except PloneMeetingError, msg:
            # back to original state
            self.context.setListType(old_listType)
            self.context._update_after_edit(idxs=['listType'])
            plone_utils = api.portal.get_tool('plone_utils')
            plone_utils.addPortalMessage(msg, type='warning')

        # an item's listType has been changed, notify meeting
        if self.context.hasMeeting():
            meeting = self.context.getMeeting()
            notifyModifiedAndReindex(meeting)
示例#10
0
class ChangeItemPollTypeView(BrowserView):
    '''This manage the item pollType changes.'''
    def __init__(self, context, request):
        super(BrowserView, self).__init__(context, request)
        self.context = context
        self.request = request

    def __call__(self, new_value):
        '''Change pollType value.'''
        self._changePollType(new_value)

    def validate_new_poll_type(self, old_pollType, new_value):
        '''Make sure the new selected value can be selected.'''
        # make sure new_value exists
        factory = queryUtility(
            IVocabularyFactory,
            'Products.PloneMeeting.vocabularies.polltypesvocabulary')
        if new_value not in factory(self.context):
            raise KeyError(
                "New value '{0}' does not correspond to a value of MeetingItem.pollType"
                .format(new_value))

        if not self.context.adapted().mayChangePollType():
            raise Unauthorized

        # if user tries to switch from a public pollType to a secret
        # and vice-versa, it can not be done if some votes are encoded
        is_switching_vote_mode = (old_pollType.startswith('secret') and
                                  not new_value.startswith('secret')) or \
                                 (not old_pollType.startswith('secret') and
                                  new_value.startswith('secret'))
        if (new_value == 'no_vote' or is_switching_vote_mode) and \
           self.context.get_item_votes(include_unexisting=False):
            can_not_switch_polltype_msg = _(
                'can_not_switch_polltype_votes_encoded')
            return can_not_switch_polltype_msg

    def _changePollType(self, new_value):
        '''Helper method that changes pollType value and check that :
           - new_value is among selectable pollType values;
           - user actually mayChangePollType;
           - adapt Meeting.item_votes values.'''
        old_pollType = self.context.getPollType()
        validation_msg = self.validate_new_poll_type(old_pollType, new_value)
        if validation_msg:
            api.portal.show_message(validation_msg,
                                    request=self.request,
                                    type='warning')
            return

        # save old_pollType so we can pass it the the ItemPollTypeChangedEvent
        # set the new pollType and notify events
        self.context.setPollType(new_value)
        self.context._update_after_edit(idxs=['pollType'])
        try:
            notify(ItemPollTypeChangedEvent(self.context, old_pollType))
        except PloneMeetingError, msg:
            # back to original state
            self.context.setPollType(old_pollType)
            self.context._update_after_edit(idxs=['pollType'])
            api.portal.show_message(msg, type='warning')

        # an item's pollType has been changed, notify meeting
        if self.context.hasMeeting():
            meeting = self.context.getMeeting()
            notifyModifiedAndReindex(meeting)
示例#11
0
 def update(self, label_id, title, color, by_user):
     """ """
     notifyModifiedAndReindex(self.context)
     return super(PMLabelJar, self).update(label_id, title, color, by_user)
示例#12
0
 def add(self, title, color, by_user):
     """Override to invalidate relevant cache."""
     notifyModifiedAndReindex(self.context)
     return super(PMLabelJar, self).add(title, color, by_user)