fix: conflicts
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}{{ 'Courses' }}{% endblock %}
|
||||
{% from "www/courses/macros/card.html" import course_card, topic_card %}
|
||||
{% block head_include %}
|
||||
<meta name="description" content="Courses" />
|
||||
<meta name="keywords" content="Courses {{course.title}}" />
|
||||
@@ -38,13 +37,12 @@
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade py-4 show active" role="tabpanel" id="home">
|
||||
<div>{{ frappe.utils.md_to_html(course.description) }}</div>
|
||||
<div class='container'>
|
||||
<div>{{ frappe.utils.md_to_html(course.description) }}</div>
|
||||
<div class="list-group">
|
||||
{% for topic in course.topics %}
|
||||
<div class="list-group-item">
|
||||
<h5><a href="/courses/topic?course={{course.name}}&topic={{topic.name}}">{{topic.title}}</a>
|
||||
</h5>
|
||||
<h5><a href="/courses/{{course.slug}}/{{topic.slug}}">{{topic.title}}</a></h5>
|
||||
<div>{{topic.preview | markdown }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -16,14 +16,15 @@ def get_context(context):
|
||||
context.current_batch = context.memberships[0].batch
|
||||
context.author = context.memberships[0].member
|
||||
|
||||
def get_course(name):
|
||||
course = frappe.db.get_value('LMS Course', name,
|
||||
['name', 'title', 'description'], as_dict=1)
|
||||
def get_course(slug):
|
||||
course = frappe.db.get_value('LMS Course', {"slug": slug},
|
||||
['name', 'slug', 'title', 'description'], as_dict=1)
|
||||
|
||||
course['topics'] = frappe.db.get_all('LMS Topic',
|
||||
filters={
|
||||
'course': name
|
||||
'course': course['name']
|
||||
},
|
||||
fields=['name', 'title', 'preview'],
|
||||
fields=['name', 'slug', 'title', 'preview'],
|
||||
order_by='creation'
|
||||
)
|
||||
return course
|
||||
|
||||
@@ -1,24 +1,34 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}{{ 'Courses' }}{% endblock %}
|
||||
{% from "www/courses/macros/card.html" import course_card %}
|
||||
{% block head_include %}
|
||||
<meta name="description" content="{{ 'Courses' }}" />
|
||||
<meta name="keywords" content="Courses" />
|
||||
<style>
|
||||
</style>
|
||||
<meta name="description" content="{{ 'Courses' }}" />
|
||||
<meta name="keywords" content="Courses" />
|
||||
<style>
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="top-section" style="padding: 1rem 0rem;">
|
||||
<div class='container pb-5'>
|
||||
<h1>{{ 'Courses' }}</h1>
|
||||
</div>
|
||||
<div class='container'>
|
||||
<div class="row mt-5">
|
||||
{% for course in courses %}
|
||||
{{ course_card(course) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class='container pb-5'>
|
||||
<h1>{{ 'Courses' }}</h1>
|
||||
</div>
|
||||
<div class='container'>
|
||||
<div class="row mt-5">
|
||||
{% for course in courses %}
|
||||
{{ course_card(course) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% macro course_card(course) %}
|
||||
<div class="card mb-5 w-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><a href="/courses/{{course.slug}}">{{course.title}}</a></h5>
|
||||
<p class="card-text">{{ frappe.utils.md_to_html(course.description[:250]) }}</p>
|
||||
<a href="/courses/{{course.slug}}" class="card-link">See more →</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -7,6 +7,6 @@ def get_context(context):
|
||||
def get_courses():
|
||||
courses = frappe.get_all(
|
||||
"LMS Course",
|
||||
fields=['name', 'title', 'description']
|
||||
fields=['name', 'slug', 'title', 'description']
|
||||
)
|
||||
return courses
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
{% macro course_card(course) %}
|
||||
<div class="card mb-5 w-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><a href="/courses/course?course={{course.name}}">{{course.title}}</a></h5>
|
||||
<p class="card-text">{{ frappe.utils.md_to_html(course.description[:250]) }}</p>
|
||||
<a href="/courses/course?course={{course.name}}" class="card-link">See more →</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro topic_card(course, topic) %}
|
||||
<div class="card mb-5 w-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><a href="/courses/topic?course={{course.name}}&topic={{topic.name}}">{{topic.title}}</a></h5>
|
||||
<p class="card-text">{{topic.description}}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item" aria-current="page"><a href="/courses">Courses</a></li>
|
||||
<li class="breadcrumb-item" aria-current="page"><a href="/courses/course?course={{course.name}}">{{course.title}}</a></li>
|
||||
<li class="breadcrumb-item" aria-current="page"><a href="/courses/{{course.slug}}">{{course.title}}</a></li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
|
||||
@@ -2,36 +2,32 @@ import frappe
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
course_name = get_queryparam("course", '/courses')
|
||||
context.course = get_course(course_name)
|
||||
|
||||
topic_name = get_queryparam("topic", '/courses?course=' + course_name)
|
||||
context.topic = get_topic(course_name, topic_name)
|
||||
try:
|
||||
course_slug = frappe.form_dict['course']
|
||||
topic_slug = frappe.form_dict['topic']
|
||||
except KeyError:
|
||||
context.template = 'www/404.html'
|
||||
return
|
||||
|
||||
course = get_course(course_slug)
|
||||
topic = course and course.get_topic(topic_slug)
|
||||
|
||||
if not topic:
|
||||
context.template = 'www/404.html'
|
||||
return
|
||||
|
||||
context.course = course
|
||||
context.topic = topic
|
||||
context.livecode_url = get_livecode_url()
|
||||
|
||||
def notfound(context):
|
||||
context.template = 'www/404.html'
|
||||
|
||||
def get_livecode_url():
|
||||
doc = frappe.get_doc("LMS Settings")
|
||||
return doc.livecode_url
|
||||
|
||||
def get_queryparam(name, redirect_when_not_found):
|
||||
try:
|
||||
return frappe.form_dict[name]
|
||||
except KeyError:
|
||||
frappe.local.flags.redirect_location = redirect_when_not_found
|
||||
raise frappe.Redirect
|
||||
|
||||
def get_course(name):
|
||||
try:
|
||||
course = frappe.get_doc('LMS Course', name)
|
||||
except frappe.exceptions.DoesNotExistError:
|
||||
raise frappe.NotFound
|
||||
return course
|
||||
|
||||
def get_topic(course_name, topic_name):
|
||||
try:
|
||||
topic = frappe.get_doc('LMS Topic', topic_name)
|
||||
except frappe.exceptions.DoesNotExistError:
|
||||
raise frappe.NotFound
|
||||
if topic.course != course_name:
|
||||
raise frappe.NotFound
|
||||
return topic
|
||||
def get_course(slug):
|
||||
course = frappe.db.get_value('LMS Course', {"slug": slug}, ["name"], as_dict=1)
|
||||
return course and frappe.get_doc('LMS Course', course['name'])
|
||||
|
||||
25
community/www/profiles/profile.html
Normal file
25
community/www/profiles/profile.html
Normal file
@@ -0,0 +1,25 @@
|
||||
{% extends "templates/web.html" %}
|
||||
{% block page_content %}
|
||||
<div class="py-20 row">
|
||||
{% if user.photo %}
|
||||
<div class="col-sm-2 border border-dark">
|
||||
<img src="{{ user.photo }}" alt="{{ user.full_name }}">
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-sm-2">
|
||||
<div class="standard-image" style="font-size: 30px;">{{ user.abbr }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col">
|
||||
<h1>{{ user.full_name }}</h1>
|
||||
{% if user.short_intro %}
|
||||
<p class="lead"> {{ user.short_intro }} </p>
|
||||
{% endif %}
|
||||
{% if user.bio %}
|
||||
<p class="markdown-style"> {{ frappe.utils.md_to_html(user.bio) }} </p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
<!-- this is a sample default web page template -->
|
||||
18
community/www/profiles/profile.py
Normal file
18
community/www/profiles/profile.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import frappe
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
username = frappe.form_dict.get('username')
|
||||
user = username and get_user(username)
|
||||
if not user:
|
||||
context.template = "www/404.html"
|
||||
|
||||
user.abbr = "".join([s[0] for s in user.full_name.split()])
|
||||
context.user = user
|
||||
|
||||
def get_user(username):
|
||||
try:
|
||||
return frappe.get_doc("Community Member", username)
|
||||
except frappe.DoesNotExistError:
|
||||
return
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class='container pb-5'>
|
||||
<h1>Recent Sketches</h1>
|
||||
|
||||
<a href="/sketches/sketch?sketch=new">Create a New Sketch</a>
|
||||
<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 ">
|
||||
@@ -21,13 +21,13 @@
|
||||
<div class="col mb-4">
|
||||
<div class="card sketch-card" style="width: 200px;">
|
||||
<div class="card-img-top">
|
||||
<a href="/sketches/sketch?sketch={{sketch.name}}">
|
||||
<a href="/sketches/{{sketch.sketch_id}}">
|
||||
{{ sketch.to_svg() }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="sketch-title">
|
||||
<a href="sketches/sketch?sketch={{sketch.name}}">{{sketch.title}}</a>
|
||||
<a href="sketches/{{sketch.sketch_id}}">{{sketch.title}}</a>
|
||||
</div>
|
||||
<div class="sketch-author">
|
||||
by {{sketch.get_owner_name()}}
|
||||
|
||||
@@ -2,8 +2,19 @@ import frappe
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
course_name = get_queryparam("sketch", '/sketches')
|
||||
context.sketch = get_sketch(course_name)
|
||||
|
||||
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)
|
||||
|
||||
@@ -19,15 +30,8 @@ def get_livecode_url():
|
||||
doc = frappe.get_doc("LMS Settings")
|
||||
return doc.livecode_url
|
||||
|
||||
def get_queryparam(name, redirect_when_not_found):
|
||||
try:
|
||||
return frappe.form_dict[name]
|
||||
except KeyError:
|
||||
frappe.local.flags.redirect_location = redirect_when_not_found
|
||||
raise frappe.Redirect
|
||||
|
||||
def get_sketch(name):
|
||||
if name == 'new':
|
||||
def get_sketch(sketch_id):
|
||||
if sketch_id == 'new':
|
||||
sketch = frappe.new_doc('LMS Sketch')
|
||||
sketch.name = "new"
|
||||
sketch.title = "New Sketch"
|
||||
@@ -35,7 +39,8 @@ def get_sketch(name):
|
||||
return sketch
|
||||
|
||||
try:
|
||||
name = "SKETCH-" + sketch_id
|
||||
return frappe.get_doc('LMS Sketch', name)
|
||||
except frappe.exceptions.DoesNotExistError:
|
||||
raise frappe.NotFound
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user