21 lines
602 B
Python
21 lines
602 B
Python
import os
|
|
import glob
|
|
import json
|
|
|
|
from django.conf import settings
|
|
|
|
from .schemas import Warehouse
|
|
|
|
|
|
def get_warehouses(request=None):
|
|
warehouses = []
|
|
for pattern in settings.BIJOE_SCHEMAS:
|
|
for path in glob.glob(pattern):
|
|
warehouses.append(Warehouse.from_json(json.load(open(path))))
|
|
if hasattr(request, 'tenant'):
|
|
pattern = os.path.join(request.tenant.get_directory(), 'schemas', '*.model')
|
|
raise Exception(pattern)
|
|
for path in glob.glob(pattern):
|
|
warehouses.append(Warehouse.from_json(json.load(open(path))))
|
|
return warehouses
|