From 936a3fcfffd5516035223470b7910375a3076a9a Mon Sep 17 00:00:00 2001 From: Anand Chitipothu Date: Tue, 9 Mar 2021 12:53:11 +0000 Subject: [PATCH] Added partial support for new sketches. New Sketches can't be saved yet. --- community/www/sketches/index.html | 2 ++ community/www/sketches/sketch.html | 6 ++++++ community/www/sketches/sketch.py | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/community/www/sketches/index.html b/community/www/sketches/index.html index 167fb0de..c9db0f4d 100644 --- a/community/www/sketches/index.html +++ b/community/www/sketches/index.html @@ -12,6 +12,8 @@

Recent Sketches

+ + Create a New Sketch
{% for sketch in sketches %} diff --git a/community/www/sketches/sketch.html b/community/www/sketches/sketch.html index 57b08c53..98a9274a 100644 --- a/community/www/sketches/sketch.html +++ b/community/www/sketches/sketch.html @@ -33,6 +33,12 @@
By {{sketch.owner}}
+ {% if not sketch.name %} +
+ Saving sketches is not yet implemented. Coming soon! +
+ {% endif %} + {{LiveCodeEditor(sketch.name, sketch.code) }}
{% endblock %} diff --git a/community/www/sketches/sketch.py b/community/www/sketches/sketch.py index 68750024..691f55d0 100644 --- a/community/www/sketches/sketch.py +++ b/community/www/sketches/sketch.py @@ -18,6 +18,13 @@ def get_queryparam(name, redirect_when_not_found): raise frappe.Redirect def get_sketch(name): + if name == 'new': + sketch = frappe.new_doc('LMS Sketch') + sketch.title = "New Sketch" + sketch.code = "circle(100, 100, 50)" + sketch.owner = frappe.session.user.split("@")[0] + return sketch + try: sketch = frappe.get_doc('LMS Sketch', name) except frappe.exceptions.DoesNotExistError: