diff --git a/server/mergin/sync/commands.py b/server/mergin/sync/commands.py index dc0aec28..dab796cc 100644 --- a/server/mergin/sync/commands.py +++ b/server/mergin/sync/commands.py @@ -25,11 +25,21 @@ def project(): @project.command() @click.argument("name") @click.argument("namespace") - @click.argument("user") - def create(name, namespace, user): # pylint: disable=W0612 + @click.argument("username") + def create(name, namespace, username): # pylint: disable=W0612 """Create blank project""" workspace = current_app.ws_handler.get_by_name(namespace) - user = User.query.get(int(user)) + if not workspace: + print("ERROR: Workspace not found") + return + user = User.query.filter_by(username=username).first() + if not user: + print("ERROR: User not found") + return + p = Project.query.filter_by(name=name, workspace_id=workspace.id).first() + if p: + print("ERROR: Project name already exists") + return project_params = dict( creator=user, name=name,