From 3ceb9e1e4f160d48a164c813c285ba60332b7003 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 18 Jan 2010 19:47:46 +0000 Subject: [PATCH] use widget.addClass instead of overwriting an entire class for setting a CSS class. svn path=/plone.app.discussion/trunk/; revision=33222 --- plone/app/discussion/browser/comments.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index e8f1253..ae460db 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -41,17 +41,6 @@ from plone.z3cform import layout, z2 from plone.z3cform.fieldsets import extensible -class AutoResizeTextArea(TextAreaWidget): - """Textarea with autoresize CSS class. - """ - klass = u'autoresize' - -def AutoResizeTextAreaFieldWidget(field, request): - """IFieldWidget factory for AutoResizeTextAreaWidget. - """ - return widget.FieldWidget(field, AutoResizeTextArea(request)) - - class CommentButtonAction(button.ButtonAction): """Comment button with Plone CSS style. """ @@ -89,12 +78,12 @@ class CommentForm(extensible.ExtensibleForm, form.Form): 'creation_date', 'modification_date', 'author_username') - fields['text'].widgetFactory = AutoResizeTextAreaFieldWidget def updateWidgets(self): super(CommentForm, self).updateWidgets() self.widgets['in_reply_to'].mode = interfaces.HIDDEN_MODE portal_membership = getToolByName(self.context, 'portal_membership') + self.widgets['text'].addClass("autoresize") if not portal_membership.isAnonymousUser(): self.widgets['author_name'].mode = interfaces.HIDDEN_MODE self.widgets['author_email'].mode = interfaces.HIDDEN_MODE @@ -241,12 +230,9 @@ class CommentsViewlet(ViewletBase, layout.FormWrapper): def has_replies(self, workflow_actions=False): """Returns true if there are replies. """ - try: - if self.get_replies(workflow_actions): - self.get_replies(workflow_actions).next() - return True - except StopIteration: - return None + if self.get_replies(workflow_actions): + self.get_replies(workflow_actions).next() + return True def get_replies(self, workflow_actions=False): """Returns all replies to a content object.