First cut at the course doctype.

- Added "Community Course" doctype
- Added Form Scripts to set the route on first save
- Customized row and view templates

Yet to figure out how to entire course listing page.
This commit is contained in:
Anand Chitipothu
2021-03-02 01:33:12 +00:00
parent 0f539aabcc
commit 6bad28463a
7 changed files with 130 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
// Copyright (c) 2021, Frappe and contributors
// For license information, please see license.txt
frappe.ui.form.on('Community Course', {
before_submit: function (form) {
if (!form.doc.route) {
form.doc.route = "/courses/" + form.doc.name
}
}
});

View File

@@ -0,0 +1,72 @@
{
"actions": [],
"allow_guest_to_view": 1,
"allow_rename": 1,
"autoname": "field:title",
"creation": "2021-03-01 16:49:33.622422",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"title",
"description",
"route",
"is_published"
],
"fields": [
{
"fieldname": "title",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Title",
"reqd": 1,
"unique": 1
},
{
"fieldname": "description",
"fieldtype": "Markdown Editor",
"label": "Description"
},
{
"fieldname": "route",
"fieldtype": "Data",
"label": "Route"
},
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
}
],
"has_web_view": 1,
"index_web_pages_for_search": 1,
"is_published_field": "is_published",
"links": [],
"modified": "2021-03-02 06:40:37.282673",
"modified_by": "Administrator",
"module": "Community",
"name": "Community Course",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"route": "courses",
"search_fields": "title",
"sort_field": "creation",
"sort_order": "DESC",
"title_field": "title",
"track_changes": 1,
"track_views": 1
}

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.website.website_generator import WebsiteGenerator
class CommunityCourse(WebsiteGenerator):
pass

View File

@@ -0,0 +1,21 @@
{% extends "templates/web.html" %}
{% block page_content %}
<ol class="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem" class="breadcrumb-item">
<a itemprop="item" href="/courses">
<span itemprop="name">&larr; Courses</span>
<meta itemprop="position" content="1">
</a>
<span itemprop="item">
</li>
</ol>
<h1>{{ title }}</h1>
{{description}}
{% endblock %}
<!-- this is a sample default web page template -->

View File

@@ -0,0 +1,7 @@
<div class="card" style="width: 100%; margin: 5px 0px">
<div class="card-body">
<h5 class="card-title"><a href="{{doc.route}}">{{doc.title}}</a></h5>
<p class="card-text">{{doc.description}}</p>
<a href="{{doc.route}}" class="card-link">See more &rarr;</a>
</div>
</div>

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and Contributors
# See license.txt
from __future__ import unicode_literals
# import frappe
import unittest
class TestCommunityCourse(unittest.TestCase):
pass