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