#60 Blockerbug proposal form always fails validation
Closed: Fixed Opened by tflink.

With the newest version of blockerbugs, it is impossible to propose new blockers because the blocker proposal form always fails validation.

Find the issue, fix it and get new versions deployed so the proposal bits work


This ticket had assigned some Differential requests:
D1017

The problem was introduced in rBLKR1196bef.

@main.route('/propose_bug', methods=['GET', 'POST'])
@fas_login_required
def propose_bug():
    user_info = UserInfo.query.filter_by(fas_login=g.fas_user.username).first()
    if not user_info or not user_info.bz_user:
        return redirect(url_for('.fas_bugzilla'))

    current_milestone = get_current_milestone()
    bugform = BugProposeForm()
    bugform.bz_user.data = user_info.bz_user
    bugform.milestone.choices = [(m.id, m.name) for m in Milestone.query.filter_by(active=True).order_by(Milestone.id).all()]
    bugform.milestone.default = current_milestone.id
    bugform.process()

The bugform.process() is called with no data and resets all the form values. Since all the values are reset, the form always fails validation because an empty form would fail validation.

There was a second issue with the code where even if I was processing the form with the form data, the bz_user was always being set to u''

Turns out that if you render the field with disabled=true it doesn't just make the field look disabled (greyed out, immutable text) but it drops that field from the POSTed data. When you process a form with data that doesn't even mention a field, it empties any other value regardless of the defaults you may or may not have set.

By changing the field rendering to readonly=True instead of disabled=True, we lose the obvious "can't change this" but it does let the rest of the form processing and validation work the way it's supposed to.

This issue has been migrated to Fedora Forge:
https://forge.fedoraproject.org/quality/blockerbugs/issues/60

Please continue any further discussion there.

Log in to comment on this ticket.

Metadata