Add mac redirect endpoint
This commit is contained in:
parent
5965b56317
commit
943fe2e8cf
@ -4,7 +4,7 @@ import urllib
|
|||||||
from datetime import datetime, date, timedelta
|
from datetime import datetime, date, timedelta
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from bson.objectid import ObjectId
|
from bson.objectid import ObjectId
|
||||||
from flask import Blueprint, abort, g, make_response, redirect, render_template, request
|
from flask import Blueprint, abort, g, make_response, redirect, render_template, request, url_for
|
||||||
from jpegtran import JPEGImage
|
from jpegtran import JPEGImage
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
@ -21,6 +21,14 @@ page_inventory = Blueprint("inventory", __name__)
|
|||||||
db = MongoClient(const.MONGO_URI).get_default_database()
|
db = MongoClient(const.MONGO_URI).get_default_database()
|
||||||
channel = "inventory"
|
channel = "inventory"
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@page_inventory.route("/m/inventory/by-mac/<mac>", methods=['GET'])
|
||||||
|
def view_inventory_by_mac(mac):
|
||||||
|
item = db.inventory.find_one({ "mac": mac }, projection = { "_id": 1})
|
||||||
|
if not item or not item.get("_id", False):
|
||||||
|
return abort(404)
|
||||||
|
return redirect(url_for("inventory.view_inventory_view", item_id = item["_id"]))
|
||||||
|
|
||||||
@page_inventory.route("/m/inventory/<item_id>/view")
|
@page_inventory.route("/m/inventory/<item_id>/view")
|
||||||
def view_inventory_view(item_id):
|
def view_inventory_view(item_id):
|
||||||
user = read_user()
|
user = read_user()
|
||||||
|
Loading…
Reference in New Issue
Block a user