Skip to content

Instantly share code, notes, and snippets.

@sureshvv
Created August 7, 2015 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sureshvv/a89da9640254f403b399 to your computer and use it in GitHub Desktop.
Save sureshvv/a89da9640254f403b399 to your computer and use it in GitHub Desktop.
class IMyEditComment(Interface):
eff_date = schema.Datetime(title=_(u"Effective date"), required=False)
exp_date = schema.Datetime(title=_(u"Expiration date"), required=False)
class MyEditCommentForm(EditCommentForm):
"""Form to edit an existing comment."""
form.extends(EditCommentForm, ignoreButtons=True)
fields += field.Fields(IMyEditComment)
def updateWidgets(self):
super(MyEditCommentForm, self).updateWidgets()
val = getattr(self.context, 'eff_date', None)
if val:
self.widgets['eff_date'].value = val
val = getattr(self.context, 'exp_date', None)
if val:
self.widgets['exp_date'].value = val
@button.buttonAndHandler(_(u"edit_comment_form_button",
default=u"Edit comment"), name='comment')
def handleComment(self, action):
# Validate form
data, errors = self.extractData()
if errors:
return
self.context.eff_date = data['eff_date'].timetuple()
self.context.exp_date = data['exp_date'].timetuple()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment