Added partial support for new sketches.

New Sketches can't be saved yet.
This commit is contained in:
Anand Chitipothu
2021-03-09 12:53:11 +00:00
parent deea539c7d
commit 936a3fcfff
3 changed files with 15 additions and 0 deletions

View File

@@ -12,6 +12,8 @@
<section class="top-section" style="padding: 1rem 0rem;">
<div class='container pb-5'>
<h1>Recent Sketches</h1>
<a href="/sketches/sketch?sketch=new">Create a New Sketch</a>
</div>
<div class='container'>
{% for sketch in sketches %}

View File

@@ -33,6 +33,12 @@
<div class="sketch-owner-wrapper">By <span class="sketch-owner">{{sketch.owner}}</span></div>
</div>
{% if not sketch.name %}
<div class="alert alert-warning">
Saving sketches is not yet implemented. Coming soon!
</div>
{% endif %}
{{LiveCodeEditor(sketch.name, sketch.code) }}
</section>
{% endblock %}

View File

@@ -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: