Fix flake8 unused import

This commit is contained in:
Santiago L 2022-03-08 10:05:32 +01:00
parent 5158340523
commit c67bd93ef6

View file

@ -4,14 +4,15 @@ from io import StringIO
import flask import flask
import flask_weasyprint import flask_weasyprint
from flask import Blueprint, g, make_response, request, url_for, app from flask import Blueprint, g, make_response, request, url_for
from flask.views import View from flask.views import View
from flask_login import current_user, login_required from flask_login import current_user, login_required
from werkzeug.exceptions import NotFound
from sqlalchemy import or_
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
from sqlalchemy import or_
from werkzeug.exceptions import NotFound
from ereuse_devicehub import messages from ereuse_devicehub import messages
from ereuse_devicehub.db import db
from ereuse_devicehub.inventory.forms import ( from ereuse_devicehub.inventory.forms import (
AllocateForm, AllocateForm,
DataWipeForm, DataWipeForm,
@ -32,7 +33,6 @@ from ereuse_devicehub.resources.documents.device_row import ActionRow, DeviceRow
from ereuse_devicehub.resources.hash_reports import insert_hash from ereuse_devicehub.resources.hash_reports import insert_hash
from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.lot.models import Lot
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
from ereuse_devicehub.db import db
# TODO(@slamora): rename base 'inventory.devices' --> 'inventory' # TODO(@slamora): rename base 'inventory.devices' --> 'inventory'
devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory') devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory')
@ -48,10 +48,17 @@ class DeviceListMix(View):
# TODO @cayop adding filter # TODO @cayop adding filter
# https://github.com/eReuse/devicehub-teal/blob/testing/ereuse_devicehub/resources/device/views.py#L56 # https://github.com/eReuse/devicehub-teal/blob/testing/ereuse_devicehub/resources/device/views.py#L56
filter_types = ['Desktop', 'Laptop', 'Server'] filter_types = ['Desktop', 'Laptop', 'Server']
lots = Lot.query.outerjoin(Trade) \ lots = (
.filter(or_(Trade.user_from == g.user, Lot.query.outerjoin(Trade)
.filter(
or_(
Trade.user_from == g.user,
Trade.user_to == g.user, Trade.user_to == g.user,
Lot.owner_id == g.user.id)).distinct() Lot.owner_id == g.user.id,
)
)
.distinct()
)
lot = None lot = None
tags = ( tags = (
Tag.query.filter(Tag.owner_id == current_user.id) Tag.query.filter(Tag.owner_id == current_user.id)
@ -303,9 +310,13 @@ class TagAddUnnamedView(View):
try: try:
form.save() form.save()
except ConnectionError as e: except ConnectionError as e:
logger.error("Error while trying to connect to tag server: {}".format(e)) logger.error(
msg = ("Sorry, we cannot create the unnamed tags requested because " "Error while trying to connect to tag server: {}".format(e)
"some error happens while connecting to the tag server!") )
msg = (
"Sorry, we cannot create the unnamed tags requested because "
"some error happens while connecting to the tag server!"
)
messages.error(msg) messages.error(msg)
next_url = url_for('inventory.devices.taglist') next_url = url_for('inventory.devices.taglist')