Compare commits
19 Commits
miscellane
...
course-pag
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
343aa50f78 | ||
|
|
5a70687067 | ||
|
|
a0921f7380 | ||
|
|
413aeaccb1 | ||
|
|
88457a82ac | ||
|
|
761f36519e | ||
|
|
dc5b637ada | ||
|
|
69b3f366f4 | ||
|
|
da902d23f7 | ||
|
|
c2be23a902 | ||
|
|
da771d7830 | ||
|
|
041bed7e9d | ||
|
|
e330f45adc | ||
|
|
370d3a321b | ||
|
|
138fba66ae | ||
|
|
82faaed15d | ||
|
|
b58a685e7a | ||
|
|
18c0fb0da5 | ||
|
|
67d3ec75c8 |
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
@@ -38,10 +38,25 @@ jobs:
|
||||
with:
|
||||
node-version: '12'
|
||||
check-latest: true
|
||||
- name: setup cache for bench
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/bench-cache
|
||||
key: ${{ runner.os }}
|
||||
- name: install bench
|
||||
run: pip3 install frappe-bench
|
||||
run: |
|
||||
pip3 install frappe-bench
|
||||
which bench
|
||||
- name: bench init
|
||||
run: bench init ~/frappe-bench --skip-redis-config-generation
|
||||
run: |
|
||||
if [ -d ~/bench-cache/bench.tgz ]
|
||||
then
|
||||
(cd && tar xzf ~/bench-cache/bench.tgz)
|
||||
else
|
||||
bench init ~/frappe-bench --skip-redis-config-generation
|
||||
mkdir -p ~/bench-cache
|
||||
(cd && tar czf ~/bench-cache/bench.tgz frappe-bench)
|
||||
fi
|
||||
- name: add community app to bench
|
||||
working-directory: /home/runner/frappe-bench
|
||||
run: bench get-app community $GITHUB_WORKSPACE
|
||||
@@ -50,7 +65,7 @@ jobs:
|
||||
run: bench new-site --mariadb-root-password root --admin-password admin frappe.local
|
||||
- name: install community app
|
||||
working-directory: /home/runner/frappe-bench
|
||||
run: bench --site frappe.local install-app community
|
||||
run: bench --verbose --site frappe.local install-app community
|
||||
- name: allow tests
|
||||
working-directory: /home/runner/frappe-bench
|
||||
run: bench --site frappe.local set-config allow_tests true
|
||||
|
||||
@@ -8,6 +8,8 @@ import re
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
import random
|
||||
from frappe.utils import cint
|
||||
import hashlib
|
||||
|
||||
class CommunityMember(Document):
|
||||
|
||||
@@ -45,6 +47,24 @@ class CommunityMember(Document):
|
||||
'member_type': 'Mentor'
|
||||
})
|
||||
|
||||
def get_palette(self):
|
||||
palette = [
|
||||
['--orange-avatar-bg', '--orange-avatar-color'],
|
||||
['--pink-avatar-bg', '--pink-avatar-color'],
|
||||
['--blue-avatar-bg', '--blue-avatar-color'],
|
||||
['--green-avatar-bg', '--green-avatar-color'],
|
||||
['--dark-green-avatar-bg', '--dark-green-avatar-color'],
|
||||
['--red-avatar-bg', '--red-avatar-color'],
|
||||
['--yellow-avatar-bg', '--yellow-avatar-color'],
|
||||
['--purple-avatar-bg', '--purple-avatar-color'],
|
||||
['--gray-avatar-bg', '--gray-avatar-color0']
|
||||
]
|
||||
|
||||
encoded_name = str(self.full_name).encode("utf-8")
|
||||
hash_name = hashlib.md5(encoded_name).hexdigest()
|
||||
idx = cint((int(hash_name[4:6], 16) + 1) / 5.33)
|
||||
return palette[idx % 8]
|
||||
|
||||
def __repr__(self):
|
||||
return f"<CommunityMember: {self.email}>"
|
||||
|
||||
|
||||
12
community/community/widgets/Avatar.html
Normal file
12
community/community/widgets/Avatar.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{% set color = member.get_palette() %}
|
||||
<span class="avatar {{ avatar_class }}" title="{{ member.full_name }}">
|
||||
{% if member.photo %}
|
||||
<img class="avatar-frame standard-image" src="{{ member.photo }}" title="{{ member.full_name }}">
|
||||
</img>
|
||||
{% else %}
|
||||
<span class="avatar-frame standard-image" title="{{ member.full_name }}"
|
||||
style="background-color: var({{color[0]}}); color: var({{color[1]}});">
|
||||
{{ member.abbr }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from . import __version__ as app_version
|
||||
from .install import APP_LOGO_URL
|
||||
|
||||
app_name = "community"
|
||||
app_title = "Community"
|
||||
@@ -10,6 +11,9 @@ app_icon = "octicon octicon-file-directory"
|
||||
app_color = "grey"
|
||||
app_email = "jannat@erpnext.com"
|
||||
app_license = "AGPL"
|
||||
|
||||
app_logo_url = APP_LOGO_URL
|
||||
|
||||
# Includes in <head>
|
||||
# ------------------
|
||||
|
||||
@@ -59,7 +63,7 @@ web_include_css = "/assets/css/community.css"
|
||||
# ------------
|
||||
|
||||
# before_install = "community.install.before_install"
|
||||
# after_install = "community.install.after_install"
|
||||
after_install = "community.install.after_install"
|
||||
|
||||
# Desk Notifications
|
||||
# ------------------
|
||||
|
||||
42
community/install.py
Normal file
42
community/install.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""Hooks that are executed during and after install.
|
||||
"""
|
||||
import os
|
||||
import frappe
|
||||
|
||||
APP_LOGO_URL = os.getenv("APP_LOGO_URL") or "/files/logo.png"
|
||||
|
||||
def after_install():
|
||||
set_app_name()
|
||||
disable_signup()
|
||||
add_header_items()
|
||||
add_footer_items()
|
||||
|
||||
def set_app_name():
|
||||
app_name = os.getenv("FRAPPE_APP_NAME")
|
||||
if app_name:
|
||||
frappe.db.set_value('System Settings', None, 'app_name', app_name)
|
||||
|
||||
def disable_signup():
|
||||
frappe.db.set_value("Website Settings", None, "disable_signup", 1)
|
||||
|
||||
def add_header_items():
|
||||
items = [
|
||||
{"label": "Sketches", "url": "/sketches"},
|
||||
]
|
||||
doc = frappe.get_doc("Website Settings", None)
|
||||
doc.update({
|
||||
"top_bar_items": items
|
||||
})
|
||||
doc.save()
|
||||
|
||||
def add_footer_items():
|
||||
items = [
|
||||
{"label": "About", "url": "/about"},
|
||||
{"label": "Blog", "url": "/blog"},
|
||||
{"label": "Github", "url": "https://github.com/fossunited/community"}
|
||||
]
|
||||
doc = frappe.get_doc("Website Settings", None)
|
||||
doc.update({
|
||||
"footer_items": items
|
||||
})
|
||||
doc.save()
|
||||
@@ -46,14 +46,18 @@ class InviteRequest(Document):
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def create_invite_request(invite_email):
|
||||
try:
|
||||
frappe.get_doc({
|
||||
|
||||
if frappe.db.exists("User", invite_email):
|
||||
return "user"
|
||||
|
||||
if frappe.db.exists("Invite Request", {"invite_email": invite_email}):
|
||||
return "invite"
|
||||
|
||||
frappe.get_doc({
|
||||
"doctype": "Invite Request",
|
||||
"invite_email": invite_email
|
||||
}).save(ignore_permissions=True)
|
||||
return "OK"
|
||||
except frappe.UniqueValidationError:
|
||||
frappe.throw(_("Email {0} has already been used to request an invite").format(invite_email))
|
||||
return "OK"
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"actions": [],
|
||||
"autoname": "field:title",
|
||||
"creation": "2021-03-18 19:37:34.614796",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
@@ -51,10 +50,12 @@
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"default": "Public",
|
||||
"fieldname": "visibility",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Visibility",
|
||||
"options": "\nPublic\nUnlisted\nPrivate"
|
||||
"options": "Public\nUnlisted\nPrivate"
|
||||
},
|
||||
{
|
||||
"fieldname": "membership",
|
||||
@@ -63,16 +64,19 @@
|
||||
"options": "\nOpen\nRestricted\nInvite Only\nClosed"
|
||||
},
|
||||
{
|
||||
"default": "Active",
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Status",
|
||||
"options": "\nActive\nInactive"
|
||||
"options": "Active\nInactive"
|
||||
},
|
||||
{
|
||||
"default": "Ready",
|
||||
"fieldname": "stage",
|
||||
"fieldtype": "Select",
|
||||
"label": "Stage",
|
||||
"options": "\nReady\nIn Progress\nCompleted\nCancelled"
|
||||
"options": "Ready\nIn Progress\nCompleted\nCancelled"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_3",
|
||||
@@ -122,7 +126,7 @@
|
||||
"link_fieldname": "batch"
|
||||
}
|
||||
],
|
||||
"modified": "2021-04-30 09:52:18.941276",
|
||||
"modified": "2021-05-06 05:46:38.469120",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch",
|
||||
|
||||
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from community.www.courses.utils import get_member_with_email
|
||||
from community.query import find, find_all
|
||||
|
||||
class LMSBatch(Document):
|
||||
def validate(self):
|
||||
@@ -23,10 +24,16 @@ class LMSBatch(Document):
|
||||
"LMS Batch Membership",
|
||||
{"batch": self.name, "member_type": "Mentor"},
|
||||
["member"])
|
||||
for membership in memberships:
|
||||
member = frappe.db.get_value("Community Member", membership.member, ["full_name", "photo", "abbr"], as_dict=1)
|
||||
mentors.append(member)
|
||||
return mentors
|
||||
member_names = [m['member'] for m in memberships]
|
||||
return find_all("Community Member", name=["IN", member_names])
|
||||
|
||||
def is_member(self, email):
|
||||
"""Checks if a person is part of a batch.
|
||||
"""
|
||||
member = find("Community Member", email=email)
|
||||
return member and frappe.db.exists(
|
||||
"LMS Batch Membership",
|
||||
{"batch": self.name, "member": member.name})
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_messages(batch):
|
||||
|
||||
@@ -40,6 +40,6 @@ def create_membership(batch, course=None, member=None, member_type="Student", ro
|
||||
"member": member
|
||||
}).save(ignore_permissions=True)
|
||||
if course:
|
||||
course_slug = frappe.db.get_value("LMS Course", {"title": course}, ["slug"])
|
||||
course_slug = frappe.db.get_value("LMS Course", {"title": course}, ["name"])
|
||||
return course_slug
|
||||
return "OK"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
"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,
|
||||
@@ -89,7 +88,7 @@
|
||||
"link_fieldname": "course"
|
||||
}
|
||||
],
|
||||
"modified": "2021-05-03 05:52:30.396824",
|
||||
"modified": "2021-05-06 11:15:45.728976",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Course",
|
||||
|
||||
@@ -6,13 +6,18 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from ...utils import slugify
|
||||
from community.query import find, find_all
|
||||
|
||||
class LMSCourse(Document):
|
||||
@staticmethod
|
||||
def find(slug):
|
||||
"""Returns the course with specified slug.
|
||||
def find(name):
|
||||
"""Returns the course with specified name.
|
||||
"""
|
||||
return find("LMS Course", is_published=True, slug=slug)
|
||||
return find("LMS Course", is_published=True, name=name)
|
||||
|
||||
def autoname(self):
|
||||
if not self.name:
|
||||
self.name = self.generate_slug(title=self.title)
|
||||
|
||||
@staticmethod
|
||||
def find_all():
|
||||
@@ -20,10 +25,6 @@ class LMSCourse(Document):
|
||||
"""
|
||||
return find_all("LMS Course", is_published=True)
|
||||
|
||||
def before_save(self):
|
||||
if not self.slug:
|
||||
self.slug = self.generate_slug(title=self.title)
|
||||
|
||||
def generate_slug(self, title):
|
||||
result = frappe.get_all(
|
||||
'LMS Course',
|
||||
@@ -32,7 +33,7 @@ class LMSCourse(Document):
|
||||
return slugify(title, used_slugs=slugs)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Course#{self.name} {self.slug}>"
|
||||
return f"<Course#{self.name}>"
|
||||
|
||||
def get_topic(self, slug):
|
||||
"""Returns the topic with given slug in this course as a Document.
|
||||
@@ -123,6 +124,9 @@ class LMSCourse(Document):
|
||||
# TODO: chapters should have a way to specify the order
|
||||
return find_all("Chapter", course=self.name, order_by="creation")
|
||||
|
||||
def get_batch(self, batch_name):
|
||||
return find("LMS Batch", name=batch_name, course=self.name)
|
||||
|
||||
def get_batches(self, mentor=None):
|
||||
batches = find_all("LMS Batch", course=self.name)
|
||||
if mentor:
|
||||
@@ -139,24 +143,8 @@ class LMSCourse(Document):
|
||||
now = frappe.utils.nowdate()
|
||||
batches = find_all("LMS Batch",
|
||||
course=self.name,
|
||||
start_date=[">", now])
|
||||
start_date=[">", now],
|
||||
status="Active",
|
||||
visibility="Public")
|
||||
return batches
|
||||
|
||||
def find_all(doctype, order_by=None, **filters):
|
||||
"""Queries the database for documents of a doctype matching given filters.
|
||||
"""
|
||||
rows = frappe.db.get_all(doctype,
|
||||
filters=filters,
|
||||
fields='*',
|
||||
order_by=order_by)
|
||||
return [frappe.get_doc(dict(row, doctype=doctype)) for row in rows]
|
||||
|
||||
def find(doctype, **filters):
|
||||
"""Queries the database for a document of given doctype matching given filters.
|
||||
"""
|
||||
rows = frappe.db.get_all(doctype,
|
||||
filters=filters,
|
||||
fields='*')
|
||||
if rows:
|
||||
row = rows[0]
|
||||
return frappe.get_doc(dict(row, doctype=doctype))
|
||||
|
||||
@@ -24,7 +24,7 @@ class TestLMSCourse(unittest.TestCase):
|
||||
def test_new_course(self):
|
||||
course = self.new_course("Test Course")
|
||||
assert course.title == "Test Course"
|
||||
assert course.slug == "test-course"
|
||||
assert course.name == "test-course"
|
||||
assert course.get_mentors() == []
|
||||
|
||||
def test_find_all(self):
|
||||
@@ -41,7 +41,7 @@ class TestLMSCourse(unittest.TestCase):
|
||||
|
||||
# now we should find one course
|
||||
courses = LMSCourse.find_all()
|
||||
assert [c.slug for c in courses] == [course.slug]
|
||||
assert [c.name for c in courses] == [course.name]
|
||||
|
||||
# disabled this test as it is failing
|
||||
def _test_add_mentors(self):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="chapter-teaser">
|
||||
<div class="teaser-body">
|
||||
<h3 class="chapter-title">{{ chapter.title }}</h3>
|
||||
<h3 class="chapter-title"><span class="chapter-number">{{index}}</span> {{ chapter.title }}</h3>
|
||||
<div class="chapter-description">
|
||||
{{ chapter.description or "" }}
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<div class="course-teaser">
|
||||
<div class="course-body">
|
||||
<h3 class="course-title"><a href="/courses/{{ course.slug }}">{{ course.title }}</a></h3>
|
||||
<h3 class="course-title"><a href="/courses/{{ course.name }}">{{ course.title }}</a></h3>
|
||||
<div class="course-intro">
|
||||
{{ course.short_introduction or "" }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="course-footer">
|
||||
<div class="course-author">
|
||||
{{ course.get_instructor().full_name }}
|
||||
<img class="course-author-avatar" src="{{ course.get_instructor().avatar }}" />{{ course.get_instructor().full_name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,22 +4,37 @@
|
||||
</form>
|
||||
<script>
|
||||
frappe.ready(() => {
|
||||
$("#submit-invite-request").click(function () {
|
||||
frappe.call({
|
||||
method: "community.lms.doctype.invite_request.invite_request.create_invite_request",
|
||||
args: {
|
||||
invite_email: $("#invite_email").val()
|
||||
},
|
||||
callback: (data) => {
|
||||
if (data.message == "OK") {
|
||||
$("#submit-invite-request").click(function () {
|
||||
var invite_email = $("#invite_email").val()
|
||||
frappe.call({
|
||||
method: "community.lms.doctype.invite_request.invite_request.create_invite_request",
|
||||
args: {
|
||||
invite_email: invite_email
|
||||
},
|
||||
callback: (data) => {
|
||||
$("#invite-request-form").hide();
|
||||
var message = `<div>
|
||||
<p class="lead">Thanks for your interest in Mon School. We have recorded your interest and we will get back to you shortly.</p>
|
||||
</div>`;
|
||||
|
||||
if (data.message == "OK") {
|
||||
var message = `<div>
|
||||
<p class="lead">Thanks for your interest in Mon School. We have recorded your interest and we will get back to you shortly.</p>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
else if (data.message == "invite") {
|
||||
var message = `<div>
|
||||
<p class="lead">Email ${invite_email} has already been used to request an invitation.</p>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
else if (data.message == "user") {
|
||||
var message = `<div>
|
||||
<p class="lead">Looks like there is already an account with email ${invite_email}. Would you like to <a href="/login">login</a>.</p>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
$(".jumbotron").append(message);
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"public/css/lms.css"
|
||||
],
|
||||
"css/community.css": [
|
||||
"public/css/vars.css",
|
||||
"public/css/style.css",
|
||||
"public/css/vars.css",
|
||||
"public/css/style.less"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -32,78 +32,10 @@
|
||||
body {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.course-header {
|
||||
margin-top: 20px;
|
||||
padding: 20px;
|
||||
background: var(--header-bg);
|
||||
color: var(--header-color);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.course-header h1 {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.course-type {
|
||||
text-transform: uppercase;
|
||||
font-size: 1.0em;
|
||||
color: var(--tag-color);
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background: var(--sidebar-bg);
|
||||
margin: 20px 0px;
|
||||
border-radius: 10px;
|
||||
padding: 1px 20px 20px 20px;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.sidebar h3 {
|
||||
margin-top: 20px;
|
||||
color: var(--c2);
|
||||
}
|
||||
|
||||
.sidebar-batch {
|
||||
background: var(--sidebar-bg);
|
||||
color: var(--text-color);
|
||||
position: fixed;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sidebar-batch a {
|
||||
padding: 16px 8px 8px 16px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.instructor {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.instructor-title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.instructor-subtitle {
|
||||
font-size: 0.8em;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.sidebar .notice {
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
border: 1px dashed var(--text-color);
|
||||
}
|
||||
|
||||
.sidebar .notice a {
|
||||
color: inherit;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.course-details {
|
||||
/* .course-details {
|
||||
margin: 20px 0px;
|
||||
}
|
||||
|
||||
@@ -112,7 +44,7 @@ body {
|
||||
font-size: 1.4em;
|
||||
font-weight: bold;
|
||||
margin: 20px 0px 10px 0px;
|
||||
}
|
||||
} */
|
||||
|
||||
.chapter-plan {
|
||||
border-radius: 10px;
|
||||
@@ -127,7 +59,7 @@ body {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.chapter-number {
|
||||
/* .chapter-number {
|
||||
background: var(--text-color);
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
@@ -140,7 +72,7 @@ body {
|
||||
|
||||
.chapter-description {
|
||||
margin: 20px 0px;
|
||||
}
|
||||
} */
|
||||
|
||||
.lessons {
|
||||
padding-left: 20px;
|
||||
@@ -291,3 +223,9 @@ img.profile-photo {
|
||||
display: inline-block;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.display-4 {
|
||||
color: #2D005A;
|
||||
font-weight: 600;
|
||||
line-height: 51px;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
@primary-color: #08B74F;
|
||||
@import url('https://rsms.me/inter/inter.css');
|
||||
|
||||
body {
|
||||
font-family: "Inter", sans-serif;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 20px 0px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.teaser {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 9px;
|
||||
border: 1px solid #C4C4C4;
|
||||
|
||||
.teaser-body {
|
||||
padding: 20px;
|
||||
@@ -16,6 +26,8 @@
|
||||
.sketch-teaser {
|
||||
.teaser();
|
||||
width: 220px;
|
||||
margin-bottom: 30px;
|
||||
margin-top: 30px;
|
||||
|
||||
svg {
|
||||
width: 200px;
|
||||
@@ -25,8 +37,9 @@
|
||||
padding: 10px;
|
||||
}
|
||||
.sketch-footer {
|
||||
border-top: 1px solid#C4C4C4;
|
||||
padding: 10px;
|
||||
background: #eee;
|
||||
background: #F6F6F6;
|
||||
border-radius: 0px 0px 10px 10px;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +47,8 @@
|
||||
.course-teaser {
|
||||
.teaser();
|
||||
color: #444;
|
||||
margin-bottom: 20px;
|
||||
margin-top: 20px;
|
||||
|
||||
h3, h4 {
|
||||
color: black;
|
||||
@@ -64,10 +79,13 @@ section {
|
||||
|
||||
section h2 {
|
||||
margin-bottom: 40px;
|
||||
font-size: 48px;
|
||||
line-height: 58px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
section.lightgray {
|
||||
background: #f8f8f8;
|
||||
background: #F6F6F6;
|
||||
}
|
||||
|
||||
#hero .jumbotron {
|
||||
@@ -89,3 +107,128 @@ section.lightgray {
|
||||
width: 40%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.footer-grouped-links {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.footer-info {
|
||||
border-top: 0px;
|
||||
margin-top: 0px;
|
||||
|
||||
.footer-col-right {
|
||||
padding-top: 1.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
.web-footer {
|
||||
border-top: 1px solid #E2E6E9;
|
||||
padding: 0px;
|
||||
padding: 2rem 0px;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.course-type {
|
||||
text-transform: uppercase;
|
||||
font-size: 1.0em;
|
||||
font-weight: bold;
|
||||
color: var(--tag-color);
|
||||
}
|
||||
|
||||
.course-header {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
/*
|
||||
.course-header {
|
||||
margin-top: 20px;
|
||||
padding: 20px;
|
||||
background: var(--header-bg);
|
||||
color: var(--header-color);
|
||||
border-radius: 9px;
|
||||
}
|
||||
|
||||
.course-author-avatar {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.course-header h1 {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// .gray-section {
|
||||
// background:#F6F6F6;
|
||||
// border: 1px solid #C4C4C4;
|
||||
// padding: 20px;
|
||||
// margin: 20px 0px;
|
||||
// }
|
||||
|
||||
.instructor-title {
|
||||
font-weight: bold;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.instructor-subtitle {
|
||||
font-size: 0.8em;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
// .mentors-wrapper {
|
||||
// .gray-section();
|
||||
// }
|
||||
|
||||
|
||||
.chapter-number {
|
||||
background: var(--text-color);
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
height: 24px;
|
||||
min-width: 24px;
|
||||
align-items: center;
|
||||
padding: 5px 8px 2px 8px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background: var(--sidebar-bg);
|
||||
border: 1px solid var(--sidebar-border);
|
||||
margin: 20px 0px;
|
||||
border-radius: 10px;
|
||||
padding: 1px 20px 20px 20px;
|
||||
}
|
||||
|
||||
.sidebar h3 {
|
||||
margin-top: 20px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.sidebar-batch {
|
||||
background: var(--sidebar-bg);
|
||||
color: var(--text-color);
|
||||
position: fixed;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sidebar-batch a {
|
||||
padding: 16px 8px 8px 16px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
.sidebar .notice {
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
border: 1px dashed var(--text-color);
|
||||
}
|
||||
|
||||
.sidebar .notice a {
|
||||
color: inherit;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/* Define all your css variables here. */
|
||||
:root {
|
||||
--primary-color: #08B74F;
|
||||
--tag-color: #737373;
|
||||
--sidebar-bg: #F6F6F6;
|
||||
--sidebar-border: #C4C4C4;
|
||||
}
|
||||
|
||||
29
community/public/images/fossunited-logo.svg
Normal file
29
community/public/images/fossunited-logo.svg
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="104px" height="81px" viewBox="0 0 104 81" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 61.2 (89653) - https://sketch.com -->
|
||||
<title>Group 2</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="site" transform="translate(-160.803147, -89.000000)">
|
||||
<g id="Group-2" transform="translate(163.323899, 91.260768)">
|
||||
<g id="g1593" transform="translate(10.217829, 8.684369)" fill="black" fill-rule="nonzero">
|
||||
<g id="text1571" transform="translate(0.248104, 0.000000)">
|
||||
<polygon id="path1919" points="6.20610364 30.6588166 0.0881167018 30.6588166 0.0881167018 0.711614981 15.1331308 0.711614981 15.1331308 6.82960641 6.20610364 6.82960641 6.20610364 12.6143164 15.1331308 12.6143164 15.1331308 18.7323078 6.20610364 18.7323078"></polygon>
|
||||
<path d="M24.0601557,24.5170177 L29.8448702,24.5170177 L29.8448702,6.82960641 L24.0601557,6.82960641 L24.0601557,24.5170177 Z M20.917843,30.6588166 L20.917843,27.6593507 L17.9421688,27.6593507 L17.9421688,3.68729595 L20.917843,3.68729595 L20.917843,0.711614981 L32.9871829,0.711614981 L32.9871829,3.68729595 L35.9628571,3.68729595 L35.9628571,27.6593507 L32.9871829,27.6593507 L32.9871829,30.6588166 L20.917843,30.6588166 Z M18.108805,0.806844685 L20.917843,0.806844685 L20.917843,3.68729595 L18.108805,3.68729595 L18.108805,0.806844685 Z M32.9871829,0.711525057 L35.9628571,0.711525057 L35.9628571,3.68720602 L32.9871829,3.68720602 L32.9871829,0.711525057 Z M32.9871829,27.6592608 L35.9628571,27.6592608 L35.9628571,30.5635195 L32.9871829,30.5635195 L32.9871829,27.6592608 Z M17.9421688,27.6592608 L20.917843,27.6592608 L20.917843,30.6587267 L17.9421688,30.6587267 L17.9421688,27.6592608 Z" id="path1921"></path>
|
||||
<path d="M53.8169092,30.6588166 L38.7718951,30.6588166 L38.7718951,24.5170177 L50.6745942,24.5170177 L50.6745942,18.7323078 L41.7475693,18.7323078 L41.7475693,15.7566493 L38.7718951,15.7566493 L38.7718951,3.68729595 L41.7475693,3.68729595 L41.7475693,0.711614981 L56.7925834,0.711614981 L56.7925834,6.82960641 L44.889882,6.82960641 L44.889882,12.6143164 L53.8169092,12.6143164 L53.8169092,15.5899973 L56.7925834,15.5899973 L56.7925834,27.6593507 L53.8169092,27.6593507 L53.8169092,30.6588166 Z M38.9385313,0.806844685 L41.7475693,0.806844685 L41.7475693,3.68729595 L38.9385313,3.68729595 L38.9385313,0.806844685 Z M38.7719018,15.7566493 L41.747576,15.7566493 L41.747576,18.7323078 L38.7719018,18.7323078 L38.7719018,15.7566493 Z M53.8169159,12.6143164 L56.7925901,12.6143164 L56.7925901,15.5899973 L53.8169159,15.5899973 L53.8169159,12.6143164 Z M53.8169159,27.6593507 L56.7925901,27.6593507 L56.7925901,30.5636094 L53.8169159,30.5636094 L53.8169159,27.6593507 Z" id="path1923"></path>
|
||||
<path d="M74.64664,30.6588166 L59.6016259,30.6588166 L59.6016259,24.5170177 L71.5043273,24.5170177 L71.5043273,18.7323078 L62.5773023,18.7323078 L62.5773023,15.7566493 L59.6016259,15.7566493 L59.6016259,3.68729595 L62.5773023,3.68729595 L62.5773023,0.711614981 L77.6223164,0.711614981 L77.6223164,6.82960641 L65.7196151,6.82960641 L65.7196151,12.6143164 L74.64664,12.6143164 L74.64664,15.5899973 L77.6223164,15.5899973 L77.6223164,27.6593507 L74.64664,27.6593507 L74.64664,30.6588166 Z M59.7682644,0.806844685 L62.5773023,0.806844685 L62.5773023,3.68729595 L59.7682644,3.68729595 L59.7682644,0.806844685 Z M59.6016349,15.7566493 L62.5773113,15.7566493 L62.5773113,18.7323078 L59.6016349,18.7323078 L59.6016349,15.7566493 Z M74.646649,12.6143164 L77.6223254,12.6143164 L77.6223254,15.5899973 L74.646649,15.5899973 L74.646649,12.6143164 Z M74.646649,27.6593507 L77.6223254,27.6593507 L77.6223254,30.5636094 L74.646649,30.5636094 L74.646649,27.6593507 Z" id="path1925"></path>
|
||||
</g>
|
||||
<g id="text1575" transform="translate(0.127883, 35.473579)">
|
||||
<path d="M2.35734791,22.5432945 L2.35734791,20.3720424 L0.206884567,20.3720424 L0.206884567,0.865355398 L4.62823747,0.865355398 L4.62823747,18.0974048 L8.80873794,18.0974048 L8.80873794,0.865355398 L13.2300908,0.865355398 L13.2300908,20.3720424 L11.0796275,20.3720424 L11.0796275,22.5432945 L2.35734791,22.5432945 Z M0.206884567,20.3720424 L2.35734791,20.3720424 L2.35734791,22.5432945 L0.206884567,22.5432945 L0.206884567,20.3720424 Z M11.0796275,20.3720424 L13.2300908,20.3720424 L13.2300908,22.4743558 L11.0796275,22.4743558 L11.0796275,20.3720424 Z" id="path1928"></path>
|
||||
<polygon id="path1930" points="19.6814809 22.5432945 15.260128 22.5432945 15.260128 0.865355398 28.2833343 0.865355398 28.2833343 22.5432945 23.8619814 22.5432945 23.8619814 5.29401037 19.6814809 5.29401037"></polygon>
|
||||
<polygon id="path1932" points="34.7347243 22.5432945 30.3133714 22.5432945 30.3133714 0.865355398 34.7347243 0.865355398"></polygon>
|
||||
<polygon id="path1934" points="45.4870433 22.5432945 41.0656904 22.5432945 41.0656904 5.29401037 36.7647637 5.29401037 36.7647637 0.865355398 49.7879699 0.865355398 49.7879699 5.29401037 45.4870433 5.29401037"></polygon>
|
||||
<polygon id="path1936" points="62.6907478 22.5432945 51.8180048 22.5432945 51.8180048 0.865355398 62.6907478 0.865355398 62.6907478 5.29401037 56.2393577 5.29401037 56.2393577 9.48138012 62.6907478 9.48138012 62.6907478 13.9100351 56.2393577 13.9100351 56.2393577 18.0974048 62.6907478 18.0974048"></polygon>
|
||||
<path d="M69.1421378,18.0974048 L73.3226383,18.0974048 L73.3226383,5.29401037 L69.1421378,5.29401037 L69.1421378,18.0974048 Z M64.7207849,22.5432945 L64.7207849,0.865355398 L75.5935278,0.865355398 L75.5935278,3.01937283 L77.7439912,3.01937283 L77.7439912,20.3720424 L75.5935278,20.3720424 L75.5935278,22.5432945 L64.7207849,22.5432945 Z" id="path1938"></path>
|
||||
</g>
|
||||
</g>
|
||||
<rect id="rect1579" stroke="black" stroke-width="3.99998745" x="0" y="0" width="98.6425638" height="76.0972583"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.1 KiB |
22
community/query.py
Normal file
22
community/query.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Utilities to find docs.
|
||||
"""
|
||||
import frappe
|
||||
|
||||
def find_all(doctype, order_by=None, **filters):
|
||||
"""Queries the database for documents of a doctype matching given filters.
|
||||
"""
|
||||
rows = frappe.db.get_all(doctype,
|
||||
filters=filters,
|
||||
fields='*',
|
||||
order_by=order_by)
|
||||
return [frappe.get_doc(dict(row, doctype=doctype)) for row in rows]
|
||||
|
||||
def find(doctype, **filters):
|
||||
"""Queries the database for a document of given doctype matching given filters.
|
||||
"""
|
||||
rows = frappe.db.get_all(doctype,
|
||||
filters=filters,
|
||||
fields='*')
|
||||
if rows:
|
||||
row = rows[0]
|
||||
return frappe.get_doc(dict(row, doctype=doctype))
|
||||
14
community/templates/includes/footer/footer_info.html
Normal file
14
community/templates/includes/footer/footer_info.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="footer-info">
|
||||
<div class="row">
|
||||
<div class="footer-col-left col-sm-6 col-12">
|
||||
<img src="/assets/community/images/fossunited-logo.svg" style="width: 50px;">
|
||||
</div>
|
||||
{# powered #}
|
||||
<div class="footer-col-right col-sm-6 col-12 footer-powered">
|
||||
{% block powered %}
|
||||
{% include "templates/includes/footer/footer_powered.html" %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="footer-logo-extension">
|
||||
<div class="row">
|
||||
<div class="text-left col-6">
|
||||
<h3>Mon School</h3>
|
||||
</div>
|
||||
<div class="text-right col-6">
|
||||
{% block extension %}
|
||||
{% include "templates/includes/footer/footer_extension.html" %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -14,7 +14,8 @@ from frappe.utils.jinja import get_jenv
|
||||
# When {{widgets.SomeWidget()}} is called, it looks for
|
||||
# widgets/SomeWidgets.html in each of these modules.
|
||||
MODULES = [
|
||||
"lms"
|
||||
"lms",
|
||||
"community"
|
||||
]
|
||||
|
||||
def update_website_context(context):
|
||||
|
||||
@@ -9,19 +9,16 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ Sidebar(course_slug, batch_code) }}
|
||||
{{ Sidebar(course.name, batch.name) }}
|
||||
<div class="container">
|
||||
{{ CourseBasicDetail(course)}}
|
||||
{{ InstructorsSection(instructor) }}
|
||||
{% if batch.description %}
|
||||
{{ BatchDetails(batch.description) }}
|
||||
{% endif %}
|
||||
{{ MentorsSection(mentors, True, course.name) }}
|
||||
{{ InstructorsSection(course.get_instructor()) }}
|
||||
{{ BatchDetails(batch)}}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% macro CourseBasicDetail(course) %}
|
||||
<h2>{{course.name}}</h2>
|
||||
<h2>{{course.title}}</h2>
|
||||
<div class="course-description">
|
||||
{{course.short_introduction}}
|
||||
</div>
|
||||
@@ -36,11 +33,25 @@
|
||||
<div>{{frappe.utils.md_to_html(course.description)}}</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro BatchDetails(description) %}
|
||||
<div class="mt-5">
|
||||
<h3>About the Batch</h3>
|
||||
<div>
|
||||
{{ frappe.utils.md_to_html(description) }}
|
||||
</div>
|
||||
{% macro BatchDetails(batch) %}
|
||||
<h2>About the Batch</h2>
|
||||
|
||||
<div class="batch">
|
||||
<div class="batch-details">
|
||||
<div>Session every {{batch.sessions_on}}</div>
|
||||
<div>{{frappe.utils.format_time(batch.start_time, "short")}} -
|
||||
{{frappe.utils.format_time(batch.end_time, "short")}}</div>
|
||||
<div>Starting {{frappe.utils.format_date(batch.start_date, "medium")}}</div>
|
||||
<div class="course-type" style="color: #888; padding: 10px 0px;">mentors</div>
|
||||
|
||||
{% for m in batch.get_mentors() %}
|
||||
<div>
|
||||
{% if m.photo_url %}
|
||||
<img class="profile-photo" src="{{m.photo_url}}">
|
||||
{% endif %}
|
||||
<span class="instructor-title">{{m.full_name}}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import frappe
|
||||
from community.www.courses.utils import redirect_if_not_a_member, get_course, get_instructor, get_batch
|
||||
from community.lms.models import Course
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
context.course_slug = frappe.form_dict["course"]
|
||||
context.course = get_course(context.course_slug)
|
||||
context.batch_code = frappe.form_dict["batch"]
|
||||
redirect_if_not_a_member(context.course_slug, context.batch_code)
|
||||
|
||||
context.instructor = get_instructor(context.course.owner)
|
||||
context.batch = get_batch(context.batch_code)
|
||||
context.mentors = get_mentors(context.batch.name)
|
||||
course_name = frappe.form_dict["course"]
|
||||
batch_name = frappe.form_dict["batch"]
|
||||
|
||||
def get_mentors(batch):
|
||||
mentors = []
|
||||
memberships = frappe.get_all("LMS Batch Membership", {"batch": batch, "member_type": "Mentor"}, ["member"])
|
||||
for membership in memberships:
|
||||
member = frappe.get_doc("Community Member", membership.member)
|
||||
mentors.append(member)
|
||||
return mentors
|
||||
course = Course.find(course_name)
|
||||
if not course:
|
||||
context.template = "www/404.html"
|
||||
return
|
||||
|
||||
batch = course.get_batch(batch_name)
|
||||
if not batch:
|
||||
frappe.local.flags.redirect_location = "/courses/" + course_name
|
||||
raise frappe.Redirect
|
||||
|
||||
context.course = course
|
||||
context.batch = batch
|
||||
|
||||
@@ -11,22 +11,23 @@
|
||||
<div class="course-header">
|
||||
<div class="course-type">course</div>
|
||||
<h1 id="course-title" data-course="{{course.name}}">{{course.title}}</h1>
|
||||
<div class="course-short-intro">{{ course.short_introduction }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-9 col-md-12">
|
||||
<div class="col-lg-8 col-md-12">
|
||||
<div class="course-details">
|
||||
{{ CourseVideo(course) }}
|
||||
|
||||
{{ CourseDescription(course) }}
|
||||
{{ BatchSection(course) }}
|
||||
{{ CourseOutline(course) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3 col-md-12">
|
||||
<div class="col-lg-4 col-md-12">
|
||||
<div class="sidebar">
|
||||
{{ InstructorsSection(course.get_instructor()) }}
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
{{ MentorsSection(course.get_mentors(), course.is_mentor(frappe.session.user), course.name) }}
|
||||
</div>
|
||||
@@ -35,14 +36,7 @@
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% macro CourseDescription(course) %}
|
||||
<h2>Course Description</h2>
|
||||
|
||||
<div class="course-description">
|
||||
{{ course.short_introduction }}
|
||||
</div>
|
||||
|
||||
{% macro CourseVideo(course) %}
|
||||
{% if course.video_link %}
|
||||
<div class="preview-video">
|
||||
<iframe
|
||||
@@ -57,6 +51,14 @@
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro CourseDescription(course) %}
|
||||
<h2>Course Description</h2>
|
||||
|
||||
<div class="course-description">
|
||||
{{ course.short_introduction }}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro BatchSection(course) %}
|
||||
{% if course.is_mentor(frappe.session.user) %}
|
||||
{{ BatchSectionForMentors(course, course.get_batches(mentor=frappe.session.user)) }}
|
||||
@@ -76,9 +78,7 @@
|
||||
|
||||
{% for m in batch.get_mentors() %}
|
||||
<div>
|
||||
{% if m.photo_url %}
|
||||
<img class="profile-photo" src="{{m.photo_url}}">
|
||||
{% endif %}
|
||||
{{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }}
|
||||
<span class="instructor-title">{{m.full_name}}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -86,7 +86,7 @@
|
||||
<div class="cta">
|
||||
<div class="">
|
||||
{% if can_manage %}
|
||||
<button >Manage</button>
|
||||
<a href="/courses/{{course.name}}/{{batch.name}}/about" class="btn btn-secondary">Manage</a>
|
||||
{% else %}
|
||||
<button class="join-batch" data-batch="{{ batch.name | urlencode }}">Join this Batch</button>
|
||||
{% endif %}
|
||||
@@ -136,6 +136,6 @@
|
||||
<h2>Course Outline</h2>
|
||||
|
||||
{% for chapter in course.get_chapters() %}
|
||||
{{ widgets.ChapterTeaser(chapter=chapter)}}
|
||||
{{ widgets.ChapterTeaser(index=loop.index, chapter=chapter)}}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
@@ -7,12 +7,12 @@ def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
try:
|
||||
course_slug = frappe.form_dict["course"]
|
||||
course_name = frappe.form_dict["course"]
|
||||
except KeyError:
|
||||
frappe.local.flags.redirect_location = "/courses"
|
||||
raise frappe.Redirect
|
||||
|
||||
course = Course.find(course_slug)
|
||||
course = Course.find(course_name)
|
||||
if course is None:
|
||||
frappe.local.flags.redirect_location = "/courses"
|
||||
raise frappe.Redirect
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
{% 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>
|
||||
<h5 class="card-title"><a href="/courses/{{course.name}}">{{course.title}}</a></h5>
|
||||
{% if course.description %}
|
||||
<p class="card-text">{{ frappe.utils.md_to_html(course.description[:250]) }}</p>
|
||||
{% endif %}
|
||||
<a href="/courses/{{course.slug}}" class="card-link">See more →</a>
|
||||
<a href="/courses/{{course.name}}" class="card-link">See more →</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ Sidebar(course, batch_code) }}
|
||||
{{ Sidebar(course.name, batch.name) }}
|
||||
<div class="container">
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
import frappe
|
||||
from community.www.courses.utils import redirect_if_not_a_member
|
||||
from community.lms.models import Course
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
context.course = frappe.form_dict["course"]
|
||||
context.batch_code = frappe.form_dict["batch"]
|
||||
redirect_if_not_a_member(context.course, context.batch_code)
|
||||
|
||||
course_name = frappe.form_dict["course"]
|
||||
batch_name = frappe.form_dict["batch"]
|
||||
|
||||
course = Course.find(course_name)
|
||||
if not course:
|
||||
context.template = "www/404.html"
|
||||
return
|
||||
|
||||
batch = course.get_batch(batch_name)
|
||||
if not batch:
|
||||
frappe.local.flags.redirect_location = "/courses/" + course_name
|
||||
raise frappe.Redirect
|
||||
|
||||
context.course = course
|
||||
context.batch = batch
|
||||
|
||||
@@ -14,12 +14,14 @@ def get_member_with_name(name):
|
||||
|
||||
def get_batch(code):
|
||||
try:
|
||||
return frappe.db.get_value("LMS Batch", {"code": code}, ["name", "description"], as_dict=True)
|
||||
print("get_batch", code)
|
||||
return frappe.db.get_value("LMS Batch", {"name": code}, ["name", "description"], as_dict=True)
|
||||
except frappe.DoesNotExistError:
|
||||
print("Error: notfound")
|
||||
return
|
||||
|
||||
def is_member_of_batch(batch_code):
|
||||
membership = frappe.get_all("LMS Batch Membership", {"batch": get_batch(batch_code).name, "member": get_member_with_email()})
|
||||
membership = frappe.get_all("LMS Batch Membership", {"batch": batch_code, "member": get_member_with_email()})
|
||||
if len(membership):
|
||||
return True
|
||||
return False
|
||||
@@ -29,9 +31,9 @@ def redirect_if_not_a_member(course,batch_code):
|
||||
frappe.local.flags.redirect_location = "/courses/" + course
|
||||
raise frappe.Redirect
|
||||
|
||||
def get_course(slug):
|
||||
def get_course(name):
|
||||
try:
|
||||
return frappe.get_doc("LMS Course", {"slug": slug})
|
||||
return frappe.get_doc("LMS Course", {"name": name})
|
||||
except frappe.DoesNotExistError:
|
||||
return
|
||||
|
||||
@@ -54,4 +56,4 @@ def get_batch_members(batch):
|
||||
if membership.member_type == "Mentor":
|
||||
member.is_mentor = True
|
||||
members.append(member)
|
||||
return members
|
||||
return members
|
||||
|
||||
@@ -182,8 +182,8 @@
|
||||
{% for course in courses %}
|
||||
<div class="dashboard__course">
|
||||
<div class="dashboard__courseHeader">
|
||||
<a class="text-decoration-none" target="_blank" href="/courses/{{course.slug}}">
|
||||
<h5 class="w-75">{{ course.name }}</h5>
|
||||
<a class="text-decoration-none" target="_blank" href="/courses/{{course.name}}">
|
||||
<h5 class="w-75">{{ course.title }}</h5>
|
||||
</a>
|
||||
{% if course.member_type %}
|
||||
<div class="dashboard__badge">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<section id="hero">
|
||||
<div class="container">
|
||||
<div class="jumbotron">
|
||||
<h1 class="display-4">Guided online courses, with a mentor at your back.</h1>
|
||||
<h1 class="display-4">Guided online courses, with a <br />mentor at your back.</h1>
|
||||
<p class="lead">Hands-on online courses designed by experts, delivered by passionate mentors.</p>
|
||||
{{ widgets.RequestInvite() }}
|
||||
</div>
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
{% macro InstructorsSection(instructor) %}
|
||||
<h3>Instructor</h3>
|
||||
<div class="instructor">
|
||||
<div class="instructor-title">{{instructor.full_name}}</div>
|
||||
<div class="instructor-subtitle">Created {{instructor.get_course_count()}} courses</div>
|
||||
</div>
|
||||
<h3>Instructor</h3>
|
||||
<div class="instructor">
|
||||
<div class="instructor-title">{{instructor.full_name}}</div>
|
||||
<div class="instructor-subtitle">Created {{instructor.get_course_count()}} courses</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro MentorsSection(mentors, is_mentor, course_name) %}
|
||||
<h3>Mentors</h3>
|
||||
{% for m in mentors %}
|
||||
<div class="instructor">
|
||||
<div class="instructor-title">{{m.full_name}}</div>
|
||||
<div class="instructor-subtitle">Mentored {{m.get_batch_count()}} batches</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not is_mentor %}
|
||||
<div id="mentor-request" class="notice">
|
||||
Interested to become a mentor?
|
||||
<h3>Mentors</h3>
|
||||
{% for m in mentors %}
|
||||
<div class="instructor">
|
||||
<div class="instructor-title">{{m.full_name}}</div>
|
||||
<div class="instructor-subtitle">Mentored {{m.get_batch_count()}} batches</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not is_mentor %}
|
||||
<div id="mentor-request" class="notice">
|
||||
Interested to become a mentor?
|
||||
|
||||
<div><a id="apply-now" data-course="{{course_name | urlencode}}" href="">Apply Now!</a></div>
|
||||
</div>
|
||||
<div id="already-applied" class="notice hide">
|
||||
You've applied to become a mentor for this course. Your request is currently under review.
|
||||
<div><a id="apply-now" data-course="{{course_name | urlencode}}" href="">Apply Now!</a></div>
|
||||
</div>
|
||||
<div id="already-applied" class="notice hide">
|
||||
You've applied to become a mentor for this course. Your request is currently under review.
|
||||
|
||||
If you are not any more interested to mentor this course, you can <a id="cancel-request" data-course="{{course_name | urlencode}}" href="">cancel your application</a>.
|
||||
</div>
|
||||
{% endif %}
|
||||
If you are not any more interested to mentor this course, you can <a id="cancel-request" data-course="{{course_name | urlencode}}" href="">cancel your application</a>.
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user