def canImport(self): if self.name == "group": return parent = aq_inner(self.context) while not IAddressBook.providedBy(parent): parent = aq_parent(parent) return _checkPermission(ModifyPortalContent, parent)
def additional_query(self): # find address book parent = aq_parent(aq_inner(self.context)) while not IAddressBook.providedBy(parent): parent = aq_parent(parent) return {'path': '/'.join(parent.getPhysicalPath()), 'organization': self.context.UID()}
def canImport(self): if self.name == 'group': return parent = aq_inner(self.context) while not IAddressBook.providedBy(parent): parent = aq_parent(parent) return _checkPermission(ModifyPortalContent, parent)
def additional_query(self): # find address book parent = aq_parent(aq_inner(self.context)) while not IAddressBook.providedBy(parent): parent = aq_parent(parent) return { 'path': '/'.join(parent.getPhysicalPath()), 'organization': self.context.UID() }
def additional_query(self): # if we have no persons return the groups UID to force an empty result set if not self.context.persons: return {'UID': self.context.UID()} # find address book parent = aq_parent(aq_inner(self.context)) while not IAddressBook.providedBy(parent): parent = aq_parent(parent) return {'path': '/'.join(parent.getPhysicalPath()), 'UID': [person.UID() for person in self.context.persons]}
def getAddressBook(self): parent = aq_parent(self) if not parent: return None while not ISiteRoot.providedBy(parent): if IAddressBook.providedBy(parent): return parent parent = aq_parent(parent) return None
def additional_query(self): # if we have no persons return the groups UID to force an empty result set if not self.context.persons: return {'UID': self.context.UID()} # find address book parent = aq_parent(aq_inner(self.context)) while not IAddressBook.providedBy(parent): parent = aq_parent(parent) return { 'path': '/'.join(parent.getPhysicalPath()), 'UID': [person.UID() for person in self.context.persons] }
def __call__(self): self.request.set('disable_border', 1) # redirect on cancel if self.request.get('form.actions.label_cancel'): return self.request.response.redirect('%s/list_%ss' % (self.context.absolute_url(), self.name)) # redirect on import if self.request.get('form.button.import', None) is not None: parent = aq_inner(self.context) while not IAddressBook.providedBy(parent): parent = aq_parent(parent) if not _checkPermission(ModifyPortalContent, parent): raise Unauthorized return self.request.response.redirect('%s/import' % parent.absolute_url()) self.error = None self.quick = self.request.get('quicksearch', None) is not None mail = self.request.get('form.button.mailto', None) is not None export = self.request.get('form.button.export', None) is not None exportall = self.request.get('form.button.exportall', None) is not None exportsearch = self.request.get('form.button.exportsearch', None) is not None exportformat = self.request.get('form.exportformat', 'csv') advanced = self.request.get('form.button.advanced', None) is not None rows = self.table.rows() self.batch = Batch(rows, self.page_size, self.request.form.get('b_start', 0)) selection = self.get_selection() if (export or mail) and not selection: self.error = _(u'You need to select at least one person or organization') elif mail: self.mailto = self.get_mailto(selection) if not self.mailto.strip(): self.error = _(u'You need to select at least one person or organization that has an email') elif export or exportall or exportsearch: if exportsearch: selection = [row['object'] for row in rows] handler = queryAdapter(self.context, interface=IExport, name=exportformat) if handler is None: handler = queryAdapter(self.context, interface=IExport, name='%s.csv' % self.name) return handler.export(self.request, (export or exportsearch) and selection or None) elif advanced: return self.request.RESPONSE.redirect(self.advanced_url()) if self.error: statusmessage = IStatusMessage(self.request) statusmessage.addStatusMessage(self.error, 'error') return self.request.response.redirect(self.back_url()) return self.template()
def __call__(self): self.request.set('disable_border', 1) # redirect on cancel if self.request.get('form.actions.label_cancel'): return self.request.response.redirect( '%s/list_%ss' % (self.context.absolute_url(), self.name)) # redirect on import if self.request.get('form.button.import', None) is not None: parent = aq_inner(self.context) while not IAddressBook.providedBy(parent): parent = aq_parent(parent) if not _checkPermission(ModifyPortalContent, parent): raise Unauthorized return self.request.response.redirect('%s/import' % parent.absolute_url()) self.error = None self.quick = self.request.get('quicksearch', None) is not None mail = self.request.get('form.button.mailto', None) is not None export = self.request.get('form.button.export', None) is not None exportall = self.request.get('form.button.exportall', None) is not None exportsearch = self.request.get('form.button.exportsearch', None) is not None exportformat = self.request.get('form.exportformat', 'csv') advanced = self.request.get('form.button.advanced', None) is not None rows = self.table.rows() self.batch = Batch(rows, self.page_size, self.request.form.get('b_start', 0)) selection = self.get_selection() if (export or mail) and not selection: self.error = _( u'You need to select at least one person or organization') elif mail: self.mailto = self.get_mailto(selection) if not self.mailto.strip(): self.error = _( u'You need to select at least one person or organization that has an email' ) elif export or exportall or exportsearch: if exportsearch: selection = [row['object'] for row in rows] handler = queryAdapter(self.context, interface=IExport, name=exportformat) if handler is None: handler = queryAdapter(self.context, interface=IExport, name='%s.csv' % self.name) return handler.export(self.request, (export or exportsearch) and selection or None) elif advanced: return self.request.RESPONSE.redirect(self.advanced_url()) if self.error: statusmessage = IStatusMessage(self.request) statusmessage.addStatusMessage(self.error, 'error') return self.request.response.redirect(self.back_url()) return self.template()