| |
@@ -19,22 +19,20 @@
|
| |
|
| |
"""Interface for the main page"""
|
| |
|
| |
- from flask import Blueprint, render_template, redirect, url_for, abort, g, flash, make_response, request
|
| |
+ from flask import Blueprint, render_template, redirect, url_for, abort, g, make_response, request
|
| |
import datetime
|
| |
- from sqlalchemy import func, desc, or_
|
| |
- import bugzilla
|
| |
+ from sqlalchemy import or_
|
| |
from flask_fas_openid import fas_login_required
|
| |
import json
|
| |
import itertools
|
| |
|
| |
- from blockerbugs import app, db, __version__
|
| |
+ from blockerbugs import app, __version__
|
| |
from blockerbugs.util import bz_interface, pagure_bot
|
| |
from blockerbugs.models.bug import Bug
|
| |
from blockerbugs.models.milestone import Milestone
|
| |
from blockerbugs.models.update import Update
|
| |
from blockerbugs.models.release import Release
|
| |
- from blockerbugs.models.userinfo import UserInfo
|
| |
- from blockerbugs.controllers.forms import BugProposeForm, FasBugzillaForm
|
| |
+ from blockerbugs.controllers.forms import BugProposeForm
|
| |
|
| |
main = Blueprint('main', __name__)
|
| |
|
| |
@@ -414,46 +412,9 @@
|
| |
return bz_interface.create_bugzilla()
|
| |
|
| |
|
| |
- @main.route('/fas_bugzilla', methods=['GET', 'POST'])
|
| |
- @fas_login_required
|
| |
- def fas_bugzilla():
|
| |
- fas_bz_form = FasBugzillaForm()
|
| |
-
|
| |
- if fas_bz_form.validate_on_submit():
|
| |
- try:
|
| |
- # try logging into bz if user/pass are valid
|
| |
- bz = bugzilla.RHBugzilla4(url=app.config['BUGZILLA_URL'],
|
| |
- user=fas_bz_form.bz_user.data,
|
| |
- password=fas_bz_form.bz_pass.data,
|
| |
- use_creds=False,
|
| |
- force_xmlrpc=True)
|
| |
- bz.disconnect()
|
| |
-
|
| |
- #create new user_info if user with given FAS-login does not exist
|
| |
- #if user_with given FAS-login exists just update user_info.bz_user
|
| |
- user_info = UserInfo.query.filter_by(fas_login=g.fas_user.username).first()
|
| |
- if user_info:
|
| |
- user_info.bz_user = fas_bz_form.bz_user.data
|
| |
- else:
|
| |
- user_info = UserInfo(g.fas_user.username, fas_bz_form.bz_user.data)
|
| |
- db.session.add(user_info)
|
| |
- db.session.commit()
|
| |
- return redirect(url_for('.propose_bug'))
|
| |
- except bugzilla.BugzillaError as e:
|
| |
- app.logger.info(e)
|
| |
- flash(e)
|
| |
-
|
| |
- return render_template('fas_bugzilla.html', title='Link your FAS and Red Hat Bugzilla Accounts',
|
| |
- fas_bz_form=fas_bz_form)
|
| |
-
|
| |
-
|
| |
@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.milestone.choices = [(m.id, m.name) for m in Milestone.query.filter_by(active=True).order_by(Milestone.id).all()]
|
| |
@@ -461,11 +422,11 @@
|
| |
|
| |
# we have to process the form after setting the milestone default so that it is properly set
|
| |
# by passing in the request.form, anything submitted as part of a POST will be inserted as form data
|
| |
- bugform.process(request.form, bz_user = user_info.bz_user)
|
| |
+ bugform.process(request.form, fas_login=g.fas_user.username)
|
| |
|
| |
if bugform.validate_on_submit():
|
| |
app.logger.debug('bugid: %i' % bugform.bugid.data)
|
| |
- app.logger.debug('bz_user: %s' % user_info.bz_user)
|
| |
+ app.logger.debug('fas_login: %s' % bugform.fas_login.data)
|
| |
app.logger.debug('milestone: %i' % bugform.milestone.data)
|
| |
app.logger.debug('blocker: %s' % bugform.blocker.data)
|
| |
app.logger.debug('freeze_exception: %s' % bugform.freeze_exception.data)
|
| |
@@ -482,34 +443,35 @@
|
| |
# The form does basic datatype validation but we need to check for valid
|
| |
# data
|
| |
bz = get_bugzilla()
|
| |
- proposer = bz_interface.BlockerProposal(bz, bugid, trackers, bugform.blocker.data,
|
| |
- bugform.freeze_exception.data, user_info.bz_user)
|
| |
+ proposal = bz_interface.BlockerProposal(bz, bugid, trackers, bugform.blocker.data,
|
| |
+ bugform.freeze_exception.data)
|
| |
|
| |
# check bug to make sure it exists and that it isn't closed
|
| |
try:
|
| |
- proposer.check_proposed_bug()
|
| |
+ proposal.check_proposed_bug()
|
| |
except bz_interface.BZInterfaceError as e:
|
| |
bugform.bugid.errors = [e.msg]
|
| |
|
| |
# check to make sure that any proposals aren't being re-done
|
| |
if bugform.blocker.data:
|
| |
app.logger.debug('checking for valid blocker proposal')
|
| |
- if not proposer.check_blocker_proposal():
|
| |
+ if not proposal.check_blocker_proposal():
|
| |
bugform.blocker.errors = ['Bug %i is already proposed as a blocker' % bugid]
|
| |
if bugform.freeze_exception.data:
|
| |
app.logger.debug('checking for valid freeze exception proposal')
|
| |
- if not proposer.check_fe_proposal():
|
| |
+ if not proposal.check_fe_proposal():
|
| |
bugform.freeze_exception.errors = ['Bug %i is already proposed as a freeze exception' % bugid]
|
| |
|
| |
if len(bugform.errors) == 0:
|
| |
user = 'Fedora user %s' % g.fas_user.username
|
| |
app.logger.info('%s proposing %i as %s for %s' % (
|
| |
- user, bugid, proposer.get_tracker_type(), selected_milestone.name))
|
| |
+ user, bugid, proposal.get_tracker_type(), selected_milestone.name))
|
| |
try:
|
| |
- proposer.propose_bugs(user, selected_milestone.name, bugform.justification.data)
|
| |
+ proposal.propose_bugs(user, selected_milestone.name, bugform.justification.data)
|
| |
return render_template('thanks.html', bugid=bugid,
|
| |
isblocker=bugform.blocker.data,
|
| |
- isfe=bugform.freeze_exception.data)
|
| |
+ isfe=bugform.freeze_exception.data,
|
| |
+ bz_url=app.config['BUGZILLA_URL'])
|
| |
except bz_interface.BZInterfaceError as e:
|
| |
bugform.bugid.errors = [e.msg]
|
| |
app.logger.info('bug proposal form errors: %s' % e.msg)
|
| |
After Bugzilla auth changes [1] we can no longer test users' logins and passwords
for validity. Because we already have the user logged in through FAS, which
combats spam, the easiest solution is to simply drop the bugzilla login
verification process. The downside is that the user needs to manually CC himself
to that bug (if not CCed already).
This patch drops the verification process and adjusts the form templates so that
the user is advised to CC himself to the bug.
[1] https://listman.redhat.com/archives/bugzilla-announce-list/2022-February/msg00000.html
Related: https://pagure.io/fedora-qa/blockerbugs/issue/230