refactor: sketches page

- Added new widget SketchTeaser
- Moved get_recent_sketches as static method in LMSSketch
- Added `models.py` to make it easy to import Course and Sketch class
- Updated the sketches template to use the SketchTeaser widget
This commit is contained in:
Anand Chitipothu
2021-04-29 10:44:05 +05:30
parent e78c6020e7
commit 20ccc09869
6 changed files with 70 additions and 68 deletions

View File

@@ -16,37 +16,13 @@
<a href="/sketches/new">Create a New Sketch</a>
</div>
<div class='container'>
<div class="row row-cols-1 row-cols-xl-5 row-cols-lg-4 row-cols-md-3 row-cols-sm-2 ">
{% for sketch in sketches %}
<div class="col mb-4">
<div class="card sketch-card" style="width: 200px;">
<div class="card-img-top">
<a href="/sketches/{{sketch.sketch_id}}">
{{ sketch.to_svg() }}
</a>
</div>
<div class="card-footer">
<div class="sketch-title">
<a href="sketches/{{sketch.sketch_id}}">{{sketch.title}}</a>
<div class="row">
{% for sketch in sketches %}
<div class="col-md-3">
{{ widgets.SketchTeaser(sketch=sketch) }}
</div>
<div class="sketch-author">
by {{sketch.get_owner_name()}}
</div>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
</div>
</section>
{% endblock %}
{% block style %}
{{super()}}
<style type="text/css">
svg {
width: 200px;
height: 200px;
}
</style>
{% endblock %}

View File

@@ -1,7 +1,7 @@
import frappe
from ...lms.doctype.lms_sketch.lms_sketch import get_recent_sketches
from community.lms.models import Sketch
def get_context(context):
context.no_cache = 1
context.sketches = get_recent_sketches()
context.sketches = Sketch.get_recent_sketches()