def fields(self): fields = Fields(IComment) if not getattr(self.context, 'authorName'): fields = fields.omit('captcha', 'authorName') else: fields = fields.omit('captcha') return fields
def fields(self): fields = Fields(IComment) fields['approved'].mode = HIDDEN_MODE if 'social_type' in fields: fields['social_type'].mode = HIDDEN_MODE fields = fields.omit('social_avatar_url', 'social_name') if self.isPrincipal(): fields = fields.omit('captcha', 'authorName') return fields
def fields(self): fields = Fields(ITaskAttributes) content = self.getContent() voc = getUtility(IVocabularyFactory, 'project.task.severity')(content) if not voc: fields = fields.omit('severity') voc = getUtility(IVocabularyFactory, 'project.task.categories')(content) if not voc: fields = fields.omit('category') return fields
def fields(self): content = self.getContent() item = IItem(content, None) if item is None: return Fields() fields = Fields(IItem) if not canWrite(content, 'title'): fields = fields.omit('title') if not canWrite(content, 'description'): fields = fields.omit('description') return fields
def fields(self): if self.networks and self.discussion.status == 4: fields = Fields(ISocialComment).omit( 'social_avatar_url', 'social_name') fields['approved'].mode = HIDDEN_MODE fields['social_type'].mode = HIDDEN_MODE fields['facebook_id'].mode = HIDDEN_MODE fields['twitter_id'].mode = HIDDEN_MODE fields['captcha'].field.title = u'Caption' if self.isPrincipal(): fields = fields.omit( 'captcha', 'authorName', 'facebook_id', 'social_type', 'twitter_id') else: fields = Fields(IComment) fields['approved'].mode = HIDDEN_MODE if self.isPrincipal(): fields = fields.omit('captcha', 'authorName') return fields
class BaseAcknowledged(object): result = None exportFields = Fields(IPrincipalExported).select( 'title', 'firstname', 'lastname', 'email') filename = 'Acknowledged.csv' def __call__(self): request = self.request excel = self.prepare() if excel: request.response.setHeader('Content-Type', 'text/csv') request.response.setHeader( 'Content-Disposition', 'attachment; filename=%s' % self.filename) return excel IStatusMessage(request).add(_("No results")) request.response.redirect(absoluteURL(self.context, request)) return def export(self, data): res = StringIO.StringIO() fields = self.exportFields.items() names = [value.field.title for key, value in fields] + \ [u'Location', u'Department', u'Manager'] writer = csv.writer(res, delimiter=';') writer.writerow(names) for value in data: location = value.getProfileData().get('location') department = value.getProfileData().get('department') manager = value.getProfileData().get('manager') writer.writerow( [unicode(getattr(value, fname, '') or '') for fname, field in fields] + [location, department, manager]) res.seek(0) return res.read()
def fields(self): fields = Fields( ITaskCommentAdapter, ITaskAttributes, ITaskAssignee['assigned']).omit('category') if not self.status: fields = fields.omit('status') if not self.severity: fields = fields.omit('severity') if not self.allowAssign: fields = fields.omit('assigned') if not self.allowAttributes: fields = fields.omit('priority') if not self.allowAttachments: fields = fields.omit('file') if not self.wfinfo.getTransitions(): fields = fields.omit('transition') return fields
class AcknowledgementEditForm(PageletEditSubForm): fields = Fields(IContentAcknowledgement)