Adding Fields

33 views
Skip to first unread message

Andrew Hills (anhills)

unread,
Jul 18, 2014, 5:48:45 PM7/18/14
to reviewboard-dev
Hi all,

I’m creating an extension to add mandatory fields to reviews prior to submission. What’s the recommended way to reconcile the (thousands of) old reviews which will necessarily be missing these fields?

Thanks,
Andrew

David Trowbridge

unread,
Jul 18, 2014, 5:54:54 PM7/18/14
to reviewb...@googlegroups.com
Andrew,

If the field is marked with "is_required = True", it will show an error when trying to publish the review request. Old review requests from before the field existed won't have data, but they'll also be already published. If someone were to make a change to an old one (creating a new draft), they'd have to add the field before publishing the draft.

-David



--

---
You received this message because you are subscribed to the Google Groups "reviewboard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard-d...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Hills (anhills)

unread,
Jul 21, 2014, 3:33:43 PM7/21/14
to reviewboard-dev
That is great news, as it saves me lots of work!

Is there a way to get my custom fieldset to appear below the description, rather than over to the side, or should I just include my fields in the "main" builtin fieldset?

Thanks,
Andrew

Andrew Hills (anhills)

unread,
Jul 21, 2014, 4:27:49 PM7/21/14
to reviewboard-dev
The documentation at https://www.reviewboard.org/docs/manual/dev/extending/extensions/hooks/review-request-fields-hook/ suggests that more fields are to be found in reviewboard.reviews.fields, but I’ve only found evidence of basic text fields. Do any mechanisms for creating selection/dropdown fields exist? How can I add validation beyond is_required to my fields?

On Jul 18, 2014, at 5:54 PM, David Trowbridge <trow...@gmail.com> wrote:

Andrew Hills (anhills)

unread,
Jul 21, 2014, 5:12:35 PM7/21/14
to reviewboard-dev
It seems that the fields are added whether or not the extension is enabled. Also, when disabling the extension, I get this error on using the development server (paths redacted):

Traceback (most recent call last):
  File "..../env/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/base.py", line 112, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "..../env/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/views/decorators/cache.py", line 52, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "..../env/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/views/decorators/vary.py", line 19, in inner_func
    response = func(*args, **kwargs)
  File "..../djblets/djblets/webapi/resources.py", line 494, in __call__
    request, method, view, api_format=api_format, *args, **kwargs)
  File "..../djblets/djblets/webapi/resources.py", line 565, in call_method_view
    return view(request, *args, **kwargs)
  File "..../djblets/djblets/webapi/resources.py", line 753, in put
    return self.update(request, *args, **kwargs)
  File "..../djblets/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)
  File "..../djblets/djblets/webapi/decorators.py", line 138, in _checklogin
    return view_func(*args, **kwargs)
  File "..../djblets/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)
  File "..../djblets/djblets/webapi/decorators.py", line 164, in _checkpermissions
    response = view_func(*args, **kwargs)
  File "..../djblets/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)
  File "..../djblets/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)
  File "..../djblets/djblets/webapi/decorators.py", line 287, in _validate
    return view_func(*args, **new_kwargs)
  File "..../djblets/djblets/extensions/resources.py", line 224, in update
    self._extension_manager.disable_extension(extension_id)
  File "..../djblets/djblets/extensions/manager.py", line 344, in disable_extension
    self._uninit_extension(extension)
  File "..../djblets/djblets/extensions/manager.py", line 624, in _uninit_extension
    extension.shutdown()
  File "..../djblets/djblets/extensions/extension.py", line 240, in shutdown
    self.shutdown_hooks()
  File "..../djblets/djblets/extensions/extension.py", line 246, in shutdown_hooks
    hook.shutdown()
  File "..../reviewboard/reviewboard/extensions/hooks.py", line 302, in shutdown
    fieldset.remove_field(field_cls)
AttributeError: 'NoneType' object has no attribute 'remove_field'

I’m using contrib/internal/devserver.py on Git master because I couldn’t immediately figure out how to get RB 2.0.3’s "rb-site manage runserver" to serve static files, so it’s possible I’m running up against development-code-instability.

On Jul 18, 2014, at 5:54 PM, David Trowbridge <trow...@gmail.com> wrote:

Andrew Hills (anhills)

unread,
Jul 22, 2014, 11:27:12 AM7/22/14
to reviewboard-dev
I’ve found a solution for using the released version of ReviewBoard, and updated to 2.0.4. When I add a value to a field and publish my changes to the review request, it chokes while trying to render the markdown on the old value, which is None (rather than an empty string, or whatever) but is still in the "info" dict:

Traceback:
File "..../env/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "..../env/lib/python2.7/site-packages/ReviewBoard-2.0.4-py2.7.egg/reviewboard/accounts/decorators.py" in _check
  23.             return view_func(*args, **kwargs)
File "..../env/lib/python2.7/site-packages/ReviewBoard-2.0.4-py2.7.egg/reviewboard/site/decorators.py" in _check
  35.         return view_func(request, local_site=local_site, *args, **kwargs)
File "..../env/lib/python2.7/site-packages/ReviewBoard-2.0.4-py2.7.egg/reviewboard/reviews/views.py" in review_detail
  660.                         changedesc.fields_changed[field_id])
File "..../env/lib/python2.7/site-packages/ReviewBoard-2.0.4-py2.7.egg/reviewboard/reviews/fields.py" in get_change_entry_sections_html
  159.             'rendered_html': mark_safe(self.render_change_entry_html(info)),
File "..../env/lib/python2.7/site-packages/ReviewBoard-2.0.4-py2.7.egg/reviewboard/reviews/fields.py" in render_change_entry_html
  484.         old_value = render_markdown(old_value)
File "..../env/lib/python2.7/site-packages/ReviewBoard-2.0.4-py2.7.egg/reviewboard/reviews/markdown_utils.py" in render_markdown
  194.     return markdown(text, **MARKDOWN_KWARGS)
File "..../env/lib/python2.7/site-packages/Markdown-2.4.1-py2.7.egg/markdown/__init__.py" in markdown
  411.     return md.convert(text)
File "..../env/lib/python2.7/site-packages/Markdown-2.4.1-py2.7.egg/markdown/__init__.py" in convert
  275.         if not source.strip():

Exception Type: AttributeError at /r/1/
Exception Value: 'NoneType' object has no attribute 'strip'

Django’s handy error page reveals that views.py:660’s changedesc.fields_changed[field_id] is {u'new': [u'Test A'], u'old': [None]}. ("Test A" is what I typed into the field.)

Andrew Hills (anhills)

unread,
Jul 22, 2014, 5:08:31 PM7/22/14
to reviewboard-dev
Further investigation shows that this error occurs for any field extending the BaseTextAreaField, but not the BaseEditableField. I’ve mitigated it for now by overriding the render_change_entry_html method (adding "or ''" to render_markdown’s argument at fields.py:484). Could someone confirm that this is a bug rather than an error on my part before I open an issue (and submit a patch)?

Andrew Hills (anhills)

unread,
Jul 22, 2014, 6:14:54 PM7/22/14
to reviewboard-dev
Interestingly, is_required seems to have no effect—publishing a review request is still possible without filling out any of my required custom fields. I tried a few variations on signal hooks, but the return value is ignored and exceptions cause a generic HTTP 500 error to appear in a dialog. Is there any way to cause either a draft publication or a review request closure to fail if these fields aren’t filled out, or (even better) if a validation check fails?

Thanks,
Andrew

On Jul 18, 2014, at 5:54 PM, David Trowbridge <trow...@gmail.com> wrote:

Priyesh Goyal

unread,
Jul 9, 2021, 2:17:38 AM7/9/21
to Review Board Development
Hi Andrew, DId you find any solution for these?
Reply all
Reply to author
Forward
0 new messages