bugfix get_default_domain
This commit is contained in:
@@ -41,8 +41,11 @@ async def apps_list(
|
|||||||
db=Depends(get_db),
|
db=Depends(get_db),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
filtered_apps = []
|
||||||
domain = dbdomain.get_default_domain(db,user.id) #get_activedomain(db, user.id)
|
domain = dbdomain.get_default_domain(db,user.id) #get_activedomain(db, user.id)
|
||||||
|
if not domain:
|
||||||
|
return filtered_apps
|
||||||
|
|
||||||
platformapps = get_apps(db,domain.url)
|
platformapps = get_apps(db,domain.url)
|
||||||
kintoneevn = config.KINTONE_ENV(domain)
|
kintoneevn = config.KINTONE_ENV(domain)
|
||||||
headers={config.API_V1_AUTH_KEY:kintoneevn.API_V1_AUTH_VALUE}
|
headers={config.API_V1_AUTH_KEY:kintoneevn.API_V1_AUTH_VALUE}
|
||||||
@@ -61,7 +64,6 @@ async def apps_list(
|
|||||||
offset += limit
|
offset += limit
|
||||||
|
|
||||||
kintone_apps_dict = {app['appId']: app for app in all_apps}
|
kintone_apps_dict = {app['appId']: app for app in all_apps}
|
||||||
filtered_apps = []
|
|
||||||
for papp in platformapps:
|
for papp in platformapps:
|
||||||
if papp.appid in kintone_apps_dict:
|
if papp.appid in kintone_apps_dict:
|
||||||
papp.appname = kintone_apps_dict[papp.appid]["name"]
|
papp.appname = kintone_apps_dict[papp.appid]["name"]
|
||||||
@@ -205,7 +207,7 @@ async def flow_details(
|
|||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
"/flows/{appid}",
|
"/flows/{appid}",
|
||||||
response_model=List[Flow],
|
response_model=List[Flow|None],
|
||||||
response_model_exclude_none=True,
|
response_model_exclude_none=True,
|
||||||
)
|
)
|
||||||
async def flow_list(
|
async def flow_list(
|
||||||
@@ -216,6 +218,8 @@ async def flow_list(
|
|||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
domain = dbdomain.get_default_domain(db, user.id) #get_activedomain(db, user.id)
|
domain = dbdomain.get_default_domain(db, user.id) #get_activedomain(db, user.id)
|
||||||
|
if not domain:
|
||||||
|
return []
|
||||||
print("domain=>",domain)
|
print("domain=>",domain)
|
||||||
flows = get_flows_by_app(db, domain.url, appid)
|
flows = get_flows_by_app(db, domain.url, appid)
|
||||||
return flows
|
return flows
|
||||||
@@ -223,7 +227,7 @@ async def flow_list(
|
|||||||
raise APIException('platform:flow',request.url._url,f"Error occurred while get flow by appid:",e)
|
raise APIException('platform:flow',request.url._url,f"Error occurred while get flow by appid:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.post("/flow", response_model=Flow, response_model_exclude_none=True)
|
@r.post("/flow", response_model=Flow|None, response_model_exclude_none=True)
|
||||||
async def flow_create(
|
async def flow_create(
|
||||||
request: Request,
|
request: Request,
|
||||||
flow: FlowIn,
|
flow: FlowIn,
|
||||||
@@ -232,13 +236,15 @@ async def flow_create(
|
|||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
domain = dbdomain.get_default_domain(db, user.id) #get_activedomain(db, user.id)
|
domain = dbdomain.get_default_domain(db, user.id) #get_activedomain(db, user.id)
|
||||||
|
if not domain:
|
||||||
|
return None
|
||||||
return create_flow(db, domain.url, flow)
|
return create_flow(db, domain.url, flow)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:flow',request.url._url,f"Error occurred while create flow:",e)
|
raise APIException('platform:flow',request.url._url,f"Error occurred while create flow:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.put(
|
@r.put(
|
||||||
"/flow/{flowid}", response_model=Flow, response_model_exclude_none=True
|
"/flow/{flowid}", response_model=Flow|None, response_model_exclude_none=True
|
||||||
)
|
)
|
||||||
async def flow_edit(
|
async def flow_edit(
|
||||||
request: Request,
|
request: Request,
|
||||||
@@ -249,6 +255,8 @@ async def flow_edit(
|
|||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
domain = dbdomain.get_default_domain(db, user.id) #get_activedomain(db, user.id)
|
domain = dbdomain.get_default_domain(db, user.id) #get_activedomain(db, user.id)
|
||||||
|
if not domain:
|
||||||
|
return None
|
||||||
return edit_flow(db,domain.url, flow,user.id)
|
return edit_flow(db,domain.url, flow,user.id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:flow',request.url._url,f"Error occurred while edit flow:",e)
|
raise APIException('platform:flow',request.url._url,f"Error occurred while edit flow:",e)
|
||||||
@@ -400,12 +408,7 @@ async def get_defaultuserdomain(
|
|||||||
db=Depends(get_db),
|
db=Depends(get_db),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
userdomain = dbdomain.get_default_domain(db, user.id)
|
return ApiReturnModel(data =dbdomain.get_default_domain(db, user.id))
|
||||||
if userdomain:
|
|
||||||
return ApiReturnModel(data = userdomain.domain)
|
|
||||||
else:
|
|
||||||
return ApiReturnModel(data = None)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:defaultdomain',request.url._url,f"Error occurred while get user({user.id}) defaultdomain:",e)
|
raise APIException('platform:defaultdomain',request.url._url,f"Error occurred while get user({user.id}) defaultdomain:",e)
|
||||||
|
|
||||||
|
|||||||
@@ -109,8 +109,12 @@ class dbdomain(crudbase):
|
|||||||
return domain
|
return domain
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_default_domain(self,db: Session, userid: int) -> schemas.UserDomain:
|
def get_default_domain(self,db: Session, userid: int) -> schemas.DomainOut:
|
||||||
return dbuserdomain.get_user_default_domain(db,userid)
|
userdomain = dbuserdomain.get_user_default_domain(db,userid)
|
||||||
|
if userdomain:
|
||||||
|
return userdomain.domain
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def set_default_domain(self,db: Session, userid: int,domainid: int):
|
def set_default_domain(self,db: Session, userid: int,domainid: int):
|
||||||
db_domain =super().get_by_conditions(db,{"id":domainid,"is_active":True}).first()
|
db_domain =super().get_by_conditions(db,{"id":domainid,"is_active":True}).first()
|
||||||
|
|||||||
Reference in New Issue
Block a user