From 9f50af4ebdf867102852708d0517d9c649b8202d Mon Sep 17 00:00:00 2001 From: Anand Chitipothu Date: Sat, 12 Jun 2021 21:42:57 +0530 Subject: [PATCH] refactor: removed the portal pages for showing sketches Moved them to mon_school. --- community/www/sketches/index.html | 28 -------- community/www/sketches/index.py | 7 -- community/www/sketches/sketch.html | 112 ----------------------------- community/www/sketches/sketch.py | 46 ------------ 4 files changed, 193 deletions(-) delete mode 100644 community/www/sketches/index.html delete mode 100644 community/www/sketches/index.py delete mode 100644 community/www/sketches/sketch.html delete mode 100644 community/www/sketches/sketch.py diff --git a/community/www/sketches/index.html b/community/www/sketches/index.html deleted file mode 100644 index 074a8d1c..00000000 --- a/community/www/sketches/index.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "templates/base.html" %} -{% from "www/macros/livecode.html" import LiveCodeEditor, LiveCodeEditorJS %} - -{% block title %}Sketches{% endblock %} -{% block head_include %} - - - -{% endblock %} - -{% block content %} -
-
-

Recent Sketches

- - Create a New Sketch -
-
-
- {% for sketch in sketches %} -
- {{ widgets.SketchTeaser(sketch=sketch) }} -
- {% endfor %} -
-
-
-{% endblock %} diff --git a/community/www/sketches/index.py b/community/www/sketches/index.py deleted file mode 100644 index 88bcd47e..00000000 --- a/community/www/sketches/index.py +++ /dev/null @@ -1,7 +0,0 @@ -import frappe -from community.lms.models import Sketch - -def get_context(context): - context.no_cache = 1 - context.sketches = Sketch.get_recent_sketches() - diff --git a/community/www/sketches/sketch.html b/community/www/sketches/sketch.html deleted file mode 100644 index 44191b78..00000000 --- a/community/www/sketches/sketch.html +++ /dev/null @@ -1,112 +0,0 @@ -{% extends "templates/base.html" %} -{% from "www/macros/livecode.html" import LiveCodeEditorLarge, LiveCodeEditorJS with context %} - -{% block title %}{{sketch.title}}{% endblock %} -{% block head_include %} - - - - - - - - - - - - - -{% endblock %} - -{% block content %} -
-
- - -
- {% if editable %} -
-
- -
-
- -
-
- {% else %} -

{{sketch.title}}

-
By {{sketch.get_owner_name()}}
- {% endif %} -
- - {% if sketch.is_new() and not editable %} -
- Please login to save this sketch. -
- {% endif %} - -
- {{LiveCodeEditorLarge(sketch.name, sketch.code) }} -
-{% endblock %} - -{%- block script %} - {{ super() }} - {{ LiveCodeEditorJS() }} - - -{%- endblock %} - diff --git a/community/www/sketches/sketch.py b/community/www/sketches/sketch.py deleted file mode 100644 index ef88d7a0..00000000 --- a/community/www/sketches/sketch.py +++ /dev/null @@ -1,46 +0,0 @@ -import frappe - -def get_context(context): - context.no_cache = 1 - - try: - sketch_id = frappe.form_dict["sketch"] - except KeyError: - context.template = "www/404.html" - return - - sketch = get_sketch(sketch_id) - if not sketch: - context.template = "www/404.html" - return - - context.sketch = sketch - context.livecode_url = get_livecode_url() - context.editable = is_editable(context.sketch, frappe.session.user) - -def is_editable(sketch, user): - if sketch.is_new(): - # new sketches can be editable by any logged in user - return user != "Guest" - else: - # existing sketches are editable by the owner - return sketch.owner == user - -def get_livecode_url(): - doc = frappe.get_doc("LMS Settings") - return doc.livecode_url - -def get_sketch(sketch_id): - if sketch_id == 'new': - sketch = frappe.new_doc('LMS Sketch') - sketch.name = "new" - sketch.title = "New Sketch" - sketch.code = "circle(100, 100, 50)" - return sketch - - try: - name = "SKETCH-" + sketch_id - return frappe.get_doc('LMS Sketch', name) - except frappe.exceptions.DoesNotExistError: - return -