Populate HLDS data version field
This commit is contained in:
parent
a62e2bd9f7
commit
646858aac3
2 changed files with 9 additions and 3 deletions
|
@ -2,15 +2,20 @@
|
|||
|
||||
from os import path
|
||||
from typing import List
|
||||
import subprocess
|
||||
from .parser import parse_all_directory
|
||||
from .models import Location
|
||||
|
||||
|
||||
__all__ = ["location_definitions"]
|
||||
__all__ = ["location_definitions", "location_definition_version"]
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
# TODO Use proper way to get resources, see https://stackoverflow.com/a/10935674
|
||||
DATA_DIR = path.join(path.dirname(__file__), "..", "..", "data")
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
location_definitions: List[Location] = parse_all_directory(DATA_DIR)
|
||||
location_definitions.sort(key=lambda l: l.name)
|
||||
|
||||
proc = subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=True)
|
||||
location_definition_version = proc.stdout
|
||||
|
|
|
@ -11,7 +11,7 @@ from flask_login import current_user, login_required
|
|||
|
||||
from forms import AnonOrderItemForm, OrderForm, OrderItemForm
|
||||
from models import Order, OrderItem, User, db
|
||||
from hlds.definitions import location_definitions
|
||||
from hlds.definitions import location_definitions, location_definition_version
|
||||
from notification import post_order_to_webhook
|
||||
from utils import ignore_none
|
||||
|
||||
|
@ -157,6 +157,7 @@ def order_item_create(order_id: int) -> typing.Any:
|
|||
|
||||
item = OrderItem()
|
||||
form.populate_obj(item)
|
||||
item.hlds_data_version = location_definition_version
|
||||
item.order_id = order_id
|
||||
if not current_user.is_anonymous():
|
||||
item.user_id = current_user.id
|
||||
|
|
Loading…
Reference in a new issue