included db import reference to config
This commit is contained in:
parent
588eef7f9d
commit
582c18ef0c
|
@ -12,7 +12,6 @@ from persistence.models import UserRoles
|
||||||
from hub_logger import logger
|
from hub_logger import logger
|
||||||
from imports.geometry_factory import GeometryFactory
|
from imports.geometry_factory import GeometryFactory
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from imports.db_factory import DBFactory
|
|
||||||
import os
|
import os
|
||||||
from hub_api.config import Config
|
from hub_api.config import Config
|
||||||
|
|
||||||
|
@ -74,12 +73,12 @@ class CityInfo(Resource, Config):
|
||||||
return Response(json.dumps(response), status=200)
|
return Response(json.dumps(response), status=200)
|
||||||
|
|
||||||
|
|
||||||
class City(Resource):
|
class City(Resource, Config):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
super().__init__()
|
||||||
|
|
||||||
@role_required([UserRoles.Admin.value, UserRoles.Hub_Reader.value])
|
@role_required([UserRoles.Admin.value])
|
||||||
def post(self):
|
def post(self):
|
||||||
allowed_ext = {'gml', '3dm', 'xml', 'obj', 'rhino'}
|
allowed_ext = {'gml', '3dm', 'xml', 'obj', 'rhino'}
|
||||||
try:
|
try:
|
||||||
|
@ -96,9 +95,8 @@ class City(Resource):
|
||||||
file_path = (Path(__file__).parent.parent / 'data/uploaded_city/{}'.format(city_file.filename)).resolve()
|
file_path = (Path(__file__).parent.parent / 'data/uploaded_city/{}'.format(city_file.filename)).resolve()
|
||||||
city_file.save(file_path)
|
city_file.save(file_path)
|
||||||
city = GeometryFactory(city_file_type, file_path).city
|
city = GeometryFactory(city_file_type, file_path).city
|
||||||
db_factory = DBFactory(city=city, db_name='hub_prod', app_env='PROD',
|
|
||||||
dotenv_path="{}/.env".format(os.path.expanduser('~')))
|
saved_city = self.import_db_factory.persist_city(g.user['id'], city)
|
||||||
saved_city = db_factory.persist_city(1)
|
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
if type(saved_city) is not dict:
|
if type(saved_city) is not dict:
|
||||||
|
|
|
@ -4,6 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2023 Project Peter Yefi peteryefi@gmail.com
|
Copyright © 2023 Project Peter Yefi peteryefi@gmail.com
|
||||||
"""
|
"""
|
||||||
from exports.db_factory import DBFactory as CityExportFactory
|
from exports.db_factory import DBFactory as CityExportFactory
|
||||||
|
from imports.db_factory import DBFactory
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
@ -13,6 +14,8 @@ class Config:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.factory = CityExportFactory(db_name='hub_prod', app_env='PROD',
|
self.factory = CityExportFactory(db_name='hub_prod', app_env='PROD',
|
||||||
dotenv_path="{}/.env".format(os.path.expanduser('~')))
|
dotenv_path="{}/.env".format(os.path.expanduser('~')))
|
||||||
|
self.import_db_factory = DBFactory(db_name='hub_prod', app_env='PROD',
|
||||||
|
dotenv_path="{}/.env".format(os.path.expanduser('~')))
|
||||||
|
|
||||||
def get_city(self, city_id):
|
def get_city(self, city_id):
|
||||||
city_obj = self.factory.get_city(city_id)
|
city_obj = self.factory.get_city(city_id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user