Skip to content

Commit 0920d25

Browse files
committed
wip #164
1 parent f378bd4 commit 0920d25

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

coderbot/api.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -345,21 +345,11 @@ def deleteMusicPackage(name):
345345

346346
## Programs
347347

348-
def saveAsNewProgram(body):
349-
overwrite = body.get("overwrite")
350-
existing_program = prog_engine.load(body.get("name"))
351-
if existing_program and not overwrite:
352-
return "askOverwrite"
353-
elif existing_program and existing_program.is_default() == True:
354-
return "defaultOverwrite"
355-
program = Program(name=body.get("name"), code=body.get("code"), dom_code=body.get("dom_code"))
356-
prog_engine.save(program)
357-
return 200
358-
359348
def saveProgram(name, body):
360349
overwrite = body.get("overwrite")
361350
existing_program = prog_engine.load(name)
362-
if existing_program and not overwrite:
351+
logging.info("saving - name: %s, body: %s", name, str(existing_program))
352+
if existing_program is not None and not overwrite:
363353
return "askOverwrite"
364354
elif existing_program and existing_program.is_default() == True:
365355
return "defaultOverwrite"

coderbot/v1.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -159,23 +159,7 @@ paths:
159159
responses:
160160
200:
161161
description: "ok"
162-
post:
163-
operationId: "api.saveAsNewProgram"
164-
summary: "Save a new program"
165-
tags:
166-
- Program management
167-
requestBody:
168-
description: Optional description in *Markdown*
169-
required: true
170-
content:
171-
application/json:
172-
schema:
173-
$ref: '#/components/schemas/Program'
174-
responses:
175-
200:
176-
description: "ok"
177-
400:
178-
description: "Failed to save the program"
162+
179163
/programs/{name}:
180164
get:
181165
operationId: "api.loadProgram"
@@ -217,7 +201,7 @@ paths:
217201
schema:
218202
type: string
219203
requestBody:
220-
description: Optional description in *Markdown*
204+
description: Program object
221205
required: true
222206
content:
223207
application/json:
@@ -242,7 +226,7 @@ paths:
242226
schema:
243227
type: string
244228
requestBody:
245-
description: Optional description in *Markdown*
229+
description: Program object
246230
required: true
247231
content:
248232
application/json:
@@ -683,7 +667,7 @@ components:
683667
minLength: 1
684668
dom_code:
685669
type: string
686-
isDefualt:
670+
default:
687671
type: boolean
688672
overwrite:
689673
type: boolean

0 commit comments

Comments
 (0)