fix things for docker compose
This commit is contained in:
@@ -91,6 +91,7 @@ def register_shellcontext(app: Flask):
|
||||
'TargetExchange': target_exchange.models.TargetExchange,
|
||||
'Target': target.models.Target,
|
||||
'Registration': registration.models.Registration,
|
||||
'config': app.config,
|
||||
}
|
||||
|
||||
app.shell_context_processor(shell_context)
|
||||
|
||||
@@ -35,11 +35,11 @@ def get_list(exchange=None, target=None):
|
||||
@use_kwargs(registration_schema)
|
||||
@marshal_with(registration_schema)
|
||||
def create(name, routing_key, targets):
|
||||
target_ids = [t.id for t in targets]
|
||||
target_ids = [t["id"] for t in targets]
|
||||
db_targets = Target.query.filter(Target.id.in_(target_ids))
|
||||
if len(db_targets) != len(targets):
|
||||
xchange_ids = [t.id for t in db_targets]
|
||||
not_found = ','.join([f'{t.name}({t.id})' for t in targets if t.id not in xchange_ids])
|
||||
xchange_ids = [t["id"] for t in db_targets]
|
||||
not_found = ','.join([f'{t["name"]}({t["id"]})' for t in targets if t["id"] not in xchange_ids])
|
||||
raise BadRequestException(f"the target {not_found} could not be found")
|
||||
registration = Registration(name=name, token=routing_key, targets=db_targets)
|
||||
registration.save()
|
||||
|
||||
@@ -32,9 +32,9 @@ def get_list(exchange=None):
|
||||
@use_kwargs(target_schema)
|
||||
@marshal_with(target_schema)
|
||||
def create(name, routing_key, exchange):
|
||||
xchange = TargetExchange.get_by_id(exchange.id)
|
||||
xchange = TargetExchange.get_by_id(exchange["id"])
|
||||
if xchange is None:
|
||||
raise BadRequestException(f"the exchange {exchange.name}({exchange.id}) could not be found")
|
||||
raise BadRequestException(f"the exchange {exchange['name']}({exchange['id']}) could not be found")
|
||||
target = Target(name=name, routing_key=routing_key, target_exchange_id=xchange.id)
|
||||
target.save()
|
||||
return target
|
||||
|
||||
Reference in New Issue
Block a user