Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9deaa182b7 | ||
|
|
4bc05bfda8 | ||
|
|
0cfd6d7634 | ||
|
|
f7434f376f | ||
|
|
905f51ee76 | ||
|
|
e207320721 | ||
|
|
20ccc09869 | ||
|
|
e78c6020e7 | ||
|
|
4874d99e44 | ||
|
|
a022804381 | ||
|
|
7a40b3e7a5 | ||
|
|
7b142fd72d | ||
|
|
fc8ff9c7fd | ||
|
|
c6bd47eb62 | ||
|
|
d68f1de796 |
48
README.md
48
README.md
@@ -9,7 +9,51 @@ The App has following components:
|
|||||||
|
|
||||||
Community is built on the [Frappe Framework](https://github.com/frappe/frappe), a full-stack web app framework built with Python & JavaScript.
|
Community is built on the [Frappe Framework](https://github.com/frappe/frappe), a full-stack web app framework built with Python & JavaScript.
|
||||||
|
|
||||||
### Local Setup
|
## Development Setup
|
||||||
|
|
||||||
|
**Step 1:** Clone the repo
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git clone https://github.com/fossunited/community.git
|
||||||
|
|
||||||
|
$ cd community
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 2:** Run docker-compose
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 3:** Visit the website at http://localhost:8000/
|
||||||
|
|
||||||
|
You'll have to go through the setup wizard to setup the website for the first time you access it. Login using the following credentiasl to complete the setup wizard.
|
||||||
|
|
||||||
|
```
|
||||||
|
Username: Administrator
|
||||||
|
password: admin
|
||||||
|
```
|
||||||
|
|
||||||
|
TODO: Explain how to load sample data
|
||||||
|
|
||||||
|
## Stopping the server
|
||||||
|
|
||||||
|
Press `ctrl+c` in the terminal to stop the server. You can also run `docker-compose down` in another terminal to stop it.
|
||||||
|
|
||||||
|
To completely reset the instance, do the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker-compose down --volumes
|
||||||
|
$ docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
## Making Code Changes
|
||||||
|
|
||||||
|
The dev setup is configured to reload whenever any code is changed. Just edit the code and reload the webpage.
|
||||||
|
|
||||||
|
Commit the changes in a branch and send a pull request.
|
||||||
|
|
||||||
|
## Local Setup - The Hard Way
|
||||||
|
|
||||||
To setup the repository locally follow the steps mentioned below:
|
To setup the repository locally follow the steps mentioned below:
|
||||||
|
|
||||||
@@ -21,7 +65,7 @@ To setup the repository locally follow the steps mentioned below:
|
|||||||
1. Map your site to localhost with the command ```bench --site community.test add-to-hosts```
|
1. Map your site to localhost with the command ```bench --site community.test add-to-hosts```
|
||||||
1. Now open the URL http://community.test:8000/docs in your browser, you should see the app running.
|
1. Now open the URL http://community.test:8000/docs in your browser, you should see the app running.
|
||||||
|
|
||||||
### Contribution Guidelines
|
### Contribution Guidelines (for The Hard Way)
|
||||||
|
|
||||||
1. Go to the apps/community directory of your installation and execute git pull --unshallow to ensure that you have the full git repository. Also fork the fossunited/community repository on GitHub.
|
1. Go to the apps/community directory of your installation and execute git pull --unshallow to ensure that you have the full git repository. Also fork the fossunited/community repository on GitHub.
|
||||||
1. Check out a working branch in git (e.g. git checkout -b my-new-branch).
|
1. Check out a working branch in git (e.g. git checkout -b my-new-branch).
|
||||||
|
|||||||
@@ -11,15 +11,15 @@
|
|||||||
"email",
|
"email",
|
||||||
"enabled",
|
"enabled",
|
||||||
"column_break_4",
|
"column_break_4",
|
||||||
"role",
|
"username",
|
||||||
"short_intro",
|
"email_preference",
|
||||||
"section_break_7",
|
"section_break_7",
|
||||||
"bio",
|
"bio",
|
||||||
"section_break_9",
|
"section_break_9",
|
||||||
"username",
|
"role",
|
||||||
"photo",
|
"photo",
|
||||||
"column_break_12",
|
"column_break_12",
|
||||||
"email_preference",
|
"short_intro",
|
||||||
"route",
|
"route",
|
||||||
"abbr"
|
"abbr"
|
||||||
],
|
],
|
||||||
@@ -77,8 +77,10 @@
|
|||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_in_quick_entry": 1,
|
||||||
"fieldname": "username",
|
"fieldname": "username",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "User Name",
|
"label": "User Name",
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
@@ -111,10 +113,9 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 1,
|
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-04-16 10:22:46.837311",
|
"modified": "2021-04-28 11:22:35.402217",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Community",
|
"module": "Community",
|
||||||
"name": "Community Member",
|
"name": "Community Member",
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.website.website_generator import WebsiteGenerator
|
|
||||||
import re
|
import re
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.rename_doc import rename_doc
|
from frappe.model.document import Document
|
||||||
|
import random
|
||||||
|
|
||||||
class CommunityMember(WebsiteGenerator):
|
class CommunityMember(Document):
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_username()
|
self.validate_username()
|
||||||
@@ -18,6 +18,9 @@ class CommunityMember(WebsiteGenerator):
|
|||||||
self.route = self.username
|
self.route = self.username
|
||||||
|
|
||||||
def validate_username(self):
|
def validate_username(self):
|
||||||
|
if not self.username:
|
||||||
|
self.username = create_username_from_email(self.email)
|
||||||
|
|
||||||
if self.username:
|
if self.username:
|
||||||
if len(self.username) < 4:
|
if len(self.username) < 4:
|
||||||
frappe.throw(_("Username must be atleast 4 characters long."))
|
frappe.throw(_("Username must be atleast 4 characters long."))
|
||||||
@@ -29,12 +32,33 @@ class CommunityMember(WebsiteGenerator):
|
|||||||
return f"<CommunityMember: {self.email}>"
|
return f"<CommunityMember: {self.email}>"
|
||||||
|
|
||||||
def create_member_from_user(doc, method):
|
def create_member_from_user(doc, method):
|
||||||
|
username = doc.username
|
||||||
|
|
||||||
|
if ( doc.username and username_exists(doc.username)) or not doc.username:
|
||||||
|
username = create_username_from_email(doc.email)
|
||||||
|
|
||||||
|
elif len(doc.username) < 4:
|
||||||
|
username = adjust_username(doc.username)
|
||||||
|
|
||||||
|
if username_exists(username):
|
||||||
|
username = username + str(random.randint(0,9))
|
||||||
|
|
||||||
member = frappe.get_doc({
|
member = frappe.get_doc({
|
||||||
"doctype": "Community Member",
|
"doctype": "Community Member",
|
||||||
"full_name": doc.full_name,
|
"full_name": doc.full_name,
|
||||||
"username": doc.username if len(doc.username) > 3 else ("").join([ s for s in doc.full_name.split() ]),
|
"username": username,
|
||||||
"email": doc.email,
|
"email": doc.email,
|
||||||
"route": doc.username,
|
"route": doc.username,
|
||||||
"owner": doc.email
|
"owner": doc.email
|
||||||
})
|
})
|
||||||
member.save(ignore_permissions=True)
|
member.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
def username_exists(username):
|
||||||
|
return frappe.db.exists("Community Member", dict(username=username))
|
||||||
|
|
||||||
|
def create_username_from_email(email):
|
||||||
|
string = email.split("@")[0]
|
||||||
|
return ''.join(e for e in string if e.isalnum())
|
||||||
|
|
||||||
|
def adjust_username(username):
|
||||||
|
return username.ljust(4, str(random.randint(0,9)))
|
||||||
@@ -2,9 +2,91 @@
|
|||||||
# Copyright (c) 2021, Frappe and Contributors
|
# Copyright (c) 2021, Frappe and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
from community.lms.doctype.lms_course.test_lms_course import new_user
|
||||||
# import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestCommunityMember(unittest.TestCase):
|
class TestCommunityMember(unittest.TestCase):
|
||||||
pass
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(self):
|
||||||
|
users = ["test_user@example.com","test_user1@example.com"]
|
||||||
|
|
||||||
|
for user in users:
|
||||||
|
if not frappe.db.exists("User", user):
|
||||||
|
new_user("Test User", user)
|
||||||
|
|
||||||
|
def test_member_created_from_user(self):
|
||||||
|
user = frappe.db.get_value("User","test_user@example.com", ["full_name", "email", "username"], as_dict=True)
|
||||||
|
self.assertTrue(frappe.db.exists("Community Member", {"username":user.username}))
|
||||||
|
|
||||||
|
member = frappe.db.get_value("Community Member",
|
||||||
|
filters={"email": user.email},
|
||||||
|
fieldname=["full_name", "email", "owner", "username", "route"],
|
||||||
|
as_dict=True
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(user.full_name, member.full_name)
|
||||||
|
self.assertEqual(member.owner, user.email)
|
||||||
|
self.assertEqual(user.username, member.username)
|
||||||
|
self.assertEqual(member.username, member.route)
|
||||||
|
|
||||||
|
def test_members_with_same_name(self):
|
||||||
|
user1 = frappe.db.get_value("User","test_user@example.com", ["email"], as_dict=True)
|
||||||
|
user2 = frappe.get_doc("User","test_user1@example.com", ["email"], as_dict=True)
|
||||||
|
|
||||||
|
self.assertTrue(frappe.db.exists("Community Member", {"email": user1.email} ))
|
||||||
|
self.assertTrue(frappe.db.exists("Community Member", {"email": user2.email }))
|
||||||
|
|
||||||
|
member1 = frappe.db.get_value("Community Member",
|
||||||
|
filters={"email": user1.email},
|
||||||
|
fieldname=["full_name", "email", "owner", "username", "route"],
|
||||||
|
as_dict=True
|
||||||
|
)
|
||||||
|
member2 = frappe.db.get_value("Community Member",
|
||||||
|
filters={"email": user2.email},
|
||||||
|
fieldname=["full_name", "email", "owner", "username", "route"],
|
||||||
|
as_dict=True
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(member1.full_name, member2.full_name)
|
||||||
|
self.assertEqual(member1.email, user1.email)
|
||||||
|
self.assertEqual(member2.email, user2.email)
|
||||||
|
self.assertNotEqual(member1.username, member2.username)
|
||||||
|
|
||||||
|
def test_username_validations(self):
|
||||||
|
user = new_user("Tst", "tst@example.com")
|
||||||
|
self.assertTrue(frappe.db.exists("Community Member", {"email":user.email} ))
|
||||||
|
|
||||||
|
member = frappe.db.get_value("Community Member",
|
||||||
|
filters={"email": user.email},
|
||||||
|
fieldname=["username"],
|
||||||
|
as_dict=True
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(len(member.username), 4)
|
||||||
|
frappe.delete_doc("User", user.email)
|
||||||
|
|
||||||
|
def test_user_without_username(self):
|
||||||
|
user = new_user("Test User", "test_user2@example.com")
|
||||||
|
self.assertTrue(frappe.db.exists("Community Member", {"email":user.email} ))
|
||||||
|
|
||||||
|
member = frappe.db.get_value("Community Member",
|
||||||
|
filters={"email": user.email},
|
||||||
|
fieldname=["username"],
|
||||||
|
as_dict=True
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(member.username)
|
||||||
|
frappe.delete_doc("User", user.email)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(self):
|
||||||
|
users = ["test_user@example.com","test_user1@example.com"]
|
||||||
|
|
||||||
|
for user in users:
|
||||||
|
if frappe.db.exists("User", user):
|
||||||
|
frappe.delete_doc("User", user)
|
||||||
|
|
||||||
|
if frappe.db.exists("Community Member", {"email": user}):
|
||||||
|
frappe.delete_doc("Community Member", {"email": user})
|
||||||
@@ -7,7 +7,6 @@ def create_members_from_users():
|
|||||||
doc = frappe.get_doc("User", {"email": user.email})
|
doc = frappe.get_doc("User", {"email": user.email})
|
||||||
username = doc.username if doc.username and len(doc.username) > 3 else ("").join([ s for s in doc.full_name.split() ])
|
username = doc.username if doc.username and len(doc.username) > 3 else ("").join([ s for s in doc.full_name.split() ])
|
||||||
if not frappe.db.exists("Community Member", username):
|
if not frappe.db.exists("Community Member", username):
|
||||||
print(doc.email, username)
|
|
||||||
member = frappe.new_doc("Community Member")
|
member = frappe.new_doc("Community Member")
|
||||||
member.full_name = doc.full_name
|
member.full_name = doc.full_name
|
||||||
member.username = username
|
member.username = username
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ web_include_css = "/assets/css/community.css"
|
|||||||
doc_events = {
|
doc_events = {
|
||||||
"User": {
|
"User": {
|
||||||
"after_insert": "community.community.doctype.community_member.community_member.create_member_from_user"
|
"after_insert": "community.community.doctype.community_member.community_member.create_member_from_user"
|
||||||
|
},
|
||||||
|
"LMS Message": {
|
||||||
|
"after_insert": "community.lms.doctype.lms_message.lms_message.publish_message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +150,7 @@ primary_rules = [
|
|||||||
|
|
||||||
# Any frappe default URL is blocked by profile-rules, add it here to unblock it
|
# Any frappe default URL is blocked by profile-rules, add it here to unblock it
|
||||||
whitelist = [
|
whitelist = [
|
||||||
|
"/home",
|
||||||
"/login",
|
"/login",
|
||||||
"/update-password",
|
"/update-password",
|
||||||
"/update-profile",
|
"/update-profile",
|
||||||
@@ -169,3 +173,5 @@ profile_rules = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
website_route_rules = primary_rules + whitelist_rules + profile_rules
|
website_route_rules = primary_rules + whitelist_rules + profile_rules
|
||||||
|
|
||||||
|
update_website_context = 'community.widgets.update_website_context'
|
||||||
|
|||||||
@@ -37,4 +37,3 @@ def save_message(message, batch):
|
|||||||
"message": message
|
"message": message
|
||||||
})
|
})
|
||||||
doc.save(ignore_permissions=True)
|
doc.save(ignore_permissions=True)
|
||||||
return doc
|
|
||||||
@@ -88,3 +88,15 @@ class LMSCourse(Document):
|
|||||||
member.batch_count = len(frappe.get_all("LMS Batch Membership", {"member": member.name, "member_type": "Mentor"}))
|
member.batch_count = len(frappe.get_all("LMS Batch Membership", {"member": member.name, "member_type": "Mentor"}))
|
||||||
course_mentors.append(member)
|
course_mentors.append(member)
|
||||||
return course_mentors
|
return course_mentors
|
||||||
|
|
||||||
|
def get_instructor(self):
|
||||||
|
return frappe.get_doc("User", self.owner)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def find_all():
|
||||||
|
"""Returns all published courses.
|
||||||
|
"""
|
||||||
|
rows = frappe.db.get_all("LMS Course",
|
||||||
|
filters={"is_published": True},
|
||||||
|
fields='*')
|
||||||
|
return [frappe.get_doc(dict(row, doctype='LMS Course')) for row in rows]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from .lms_course import LMSCourse
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestLMSCourse(unittest.TestCase):
|
class TestLMSCourse(unittest.TestCase):
|
||||||
@@ -11,7 +12,6 @@ class TestLMSCourse(unittest.TestCase):
|
|||||||
frappe.db.sql('delete from `tabLMS Course Mentor Mapping`')
|
frappe.db.sql('delete from `tabLMS Course Mentor Mapping`')
|
||||||
frappe.db.sql('delete from `tabLMS Course`')
|
frappe.db.sql('delete from `tabLMS Course`')
|
||||||
frappe.db.sql('delete from `tabCommunity Member`')
|
frappe.db.sql('delete from `tabCommunity Member`')
|
||||||
frappe.db.sql('delete from `tabUser` where email like "%@example.com"')
|
|
||||||
|
|
||||||
def new_course(self, title):
|
def new_course(self, title):
|
||||||
doc = frappe.get_doc({
|
doc = frappe.get_doc({
|
||||||
@@ -21,28 +21,48 @@ class TestLMSCourse(unittest.TestCase):
|
|||||||
doc.insert()
|
doc.insert()
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
def new_user(self, name, email):
|
|
||||||
doc = frappe.get_doc(dict(
|
|
||||||
doctype='User',
|
|
||||||
email=email,
|
|
||||||
first_name=name))
|
|
||||||
doc.insert()
|
|
||||||
return doc
|
|
||||||
|
|
||||||
def test_new_course(self):
|
def test_new_course(self):
|
||||||
course = self.new_course("Test Course")
|
course = self.new_course("Test Course")
|
||||||
assert course.title == "Test Course"
|
assert course.title == "Test Course"
|
||||||
assert course.slug == "test-course"
|
assert course.slug == "test-course"
|
||||||
assert course.get_mentors() == []
|
assert course.get_mentors() == []
|
||||||
|
|
||||||
|
def test_find_all(self):
|
||||||
|
courses = LMSCourse.find_all()
|
||||||
|
assert courses == []
|
||||||
|
|
||||||
|
# new couse, but not published
|
||||||
|
course = self.new_course("Test Course")
|
||||||
|
assert courses == []
|
||||||
|
|
||||||
|
# publish the course
|
||||||
|
course.is_published = True
|
||||||
|
course.save()
|
||||||
|
|
||||||
|
# now we should find one course
|
||||||
|
courses = LMSCourse.find_all()
|
||||||
|
assert [c.slug for c in courses] == [course.slug]
|
||||||
|
|
||||||
# disabled this test as it is failing
|
# disabled this test as it is failing
|
||||||
def _test_add_mentors(self):
|
def _test_add_mentors(self):
|
||||||
course = self.new_course("Test Course")
|
course = self.new_course("Test Course")
|
||||||
assert course.get_mentors() == []
|
assert course.get_mentors() == []
|
||||||
|
|
||||||
user = self.new_user("Tester", "tester@example.com")
|
user = new_user("Tester", "tester@example.com")
|
||||||
course.add_mentor("tester@example.com")
|
course.add_mentor("tester@example.com")
|
||||||
|
|
||||||
mentors = course.get_mentors()
|
mentors = course.get_mentors()
|
||||||
mentors_data = [dict(email=mentor.email, batch_count=mentor.batch_count) for mentor in mentors]
|
mentors_data = [dict(email=mentor.email, batch_count=mentor.batch_count) for mentor in mentors]
|
||||||
assert mentors_data == [{"email": "tester@example.com", "batch_count": 0}]
|
assert mentors_data == [{"email": "tester@example.com", "batch_count": 0}]
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
if frappe.db.exists("User", "tester@example.com"):
|
||||||
|
frappe.delete_doc("User", "tester@example.com")
|
||||||
|
|
||||||
|
def new_user(name, email):
|
||||||
|
doc = frappe.get_doc(dict(
|
||||||
|
doctype='User',
|
||||||
|
email=email,
|
||||||
|
first_name=name))
|
||||||
|
doc.insert()
|
||||||
|
return doc
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-04-26 16:11:20.142164",
|
"modified": "2021-04-28 10:17:57.618127",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Message",
|
"name": "LMS Message",
|
||||||
@@ -80,5 +80,6 @@
|
|||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
|
"title_field": "author",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
@@ -7,10 +7,11 @@ import frappe
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import add_days, nowdate
|
from frappe.utils import add_days, nowdate
|
||||||
|
from community.www.courses.utils import get_batch_members
|
||||||
|
|
||||||
class LMSMessage(Document):
|
class LMSMessage(Document):
|
||||||
def after_insert(self):
|
""" def after_insert(self):
|
||||||
frappe.publish_realtime("new_lms_message", {"message":"JJannat"}, user="Administrator")
|
self.send_email() """
|
||||||
self.send_email()
|
|
||||||
|
|
||||||
def send_email(self):
|
def send_email(self):
|
||||||
membership = frappe.get_all("LMS Batch Membership", {"batch": self.batch}, ["member"])
|
membership = frappe.get_all("LMS Batch Membership", {"batch": self.batch}, ["member"])
|
||||||
@@ -61,3 +62,43 @@ def send_daily_digest():
|
|||||||
},
|
},
|
||||||
delayed = False
|
delayed = False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def publish_message(doc, method):
|
||||||
|
email = frappe.db.get_value("Community Member", doc.author, "email")
|
||||||
|
template = get_message_template()
|
||||||
|
message = frappe._dict()
|
||||||
|
message.author_name = doc.author_name
|
||||||
|
message.message_time = frappe.utils.pretty_date(doc.creation)
|
||||||
|
message.message = frappe.utils.md_to_html(doc.message)
|
||||||
|
|
||||||
|
js = """
|
||||||
|
$(".msger-input").val("");
|
||||||
|
var template = `{0}`;
|
||||||
|
var message = {1};
|
||||||
|
var session_user = ("{2}" == frappe.session.user) ? true : false;
|
||||||
|
message.author_name = session_user ? "You" : message.author_name
|
||||||
|
message.is_author = session_user;
|
||||||
|
template = frappe.render_template(template, {{
|
||||||
|
"message": message
|
||||||
|
}})
|
||||||
|
$(".message-section").append(template);
|
||||||
|
""".format(template, message, email)
|
||||||
|
|
||||||
|
frappe.publish_realtime(event="eval_js", message=js, after_commit=True)
|
||||||
|
|
||||||
|
def get_message_template():
|
||||||
|
return """
|
||||||
|
<div class="discussion {% if message.is_author %} is-author {% endif %}">
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="font-weight-bold">
|
||||||
|
{{ message.author_name }}
|
||||||
|
</div>
|
||||||
|
<div class="text-muted">
|
||||||
|
{{ message.message_time }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-5">
|
||||||
|
{{ message.message }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
@@ -10,9 +10,6 @@ from frappe.model.document import Document
|
|||||||
from . import livecode
|
from . import livecode
|
||||||
|
|
||||||
class LMSSketch(Document):
|
class LMSSketch(Document):
|
||||||
def get_owner_name(self):
|
|
||||||
return get_userinfo(self.owner)['full_name']
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sketch_id(self):
|
def sketch_id(self):
|
||||||
"""Returns the numeric part of the name.
|
"""Returns the numeric part of the name.
|
||||||
@@ -21,6 +18,14 @@ class LMSSketch(Document):
|
|||||||
"""
|
"""
|
||||||
return self.name.replace("SKETCH-", "")
|
return self.name.replace("SKETCH-", "")
|
||||||
|
|
||||||
|
def get_owner(self):
|
||||||
|
"""Returns the owner of this sketch as a document.
|
||||||
|
"""
|
||||||
|
return frappe.get_doc("User", self.owner)
|
||||||
|
|
||||||
|
def get_owner_name(self):
|
||||||
|
return self.get_owner().full_name
|
||||||
|
|
||||||
def get_livecode_url(self):
|
def get_livecode_url(self):
|
||||||
doc = frappe.get_cached_doc("LMS Settings")
|
doc = frappe.get_cached_doc("LMS Settings")
|
||||||
return doc.livecode_url
|
return doc.livecode_url
|
||||||
@@ -46,6 +51,18 @@ class LMSSketch(Document):
|
|||||||
cache.set(key, value)
|
cache.set(key, value)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_recent_sketches(limit=100):
|
||||||
|
"""Returns the recent sketches.
|
||||||
|
"""
|
||||||
|
sketches = frappe.get_all(
|
||||||
|
"LMS Sketch",
|
||||||
|
fields='*',
|
||||||
|
order_by='modified desc',
|
||||||
|
page_length=limit
|
||||||
|
)
|
||||||
|
return [frappe.get_doc(doctype='LMS Sketch', **doc) for doc in sketches]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<LMSSketch {self.name}>"
|
return f"<LMSSketch {self.name}>"
|
||||||
|
|
||||||
@@ -76,36 +93,3 @@ def save_sketch(name, title, code):
|
|||||||
"status": status,
|
"status": status,
|
||||||
"name": doc.name,
|
"name": doc.name,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_recent_sketches():
|
|
||||||
"""Returns the recent sketches.
|
|
||||||
|
|
||||||
The return value will be a list of dicts with each entry containing
|
|
||||||
the following fields:
|
|
||||||
- name
|
|
||||||
- title
|
|
||||||
- owner
|
|
||||||
- owner_name
|
|
||||||
- modified
|
|
||||||
"""
|
|
||||||
sketches = frappe.get_all(
|
|
||||||
"LMS Sketch",
|
|
||||||
fields='*',
|
|
||||||
order_by='modified desc',
|
|
||||||
page_length=100
|
|
||||||
)
|
|
||||||
for s in sketches:
|
|
||||||
s['owner_name'] = get_userinfo(s['owner'])['full_name']
|
|
||||||
return [frappe.get_doc(doctype='LMS Sketch', **doc) for doc in sketches]
|
|
||||||
|
|
||||||
def get_userinfo(email):
|
|
||||||
"""Returns the username and fullname of a user.
|
|
||||||
|
|
||||||
Please note that the email could be "Administrator" or "Guest"
|
|
||||||
as a special case to denote the system admin and guest user respectively.
|
|
||||||
"""
|
|
||||||
user = frappe.get_doc("User", email)
|
|
||||||
return {
|
|
||||||
"full_name": user.full_name,
|
|
||||||
"username": user.username
|
|
||||||
}
|
|
||||||
|
|||||||
5
community/lms/models.py
Normal file
5
community/lms/models.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
"""Handy module to make access to all doctypes from a single place.
|
||||||
|
"""
|
||||||
|
from .doctype.lms_course.lms_course import LMSCourse as Course
|
||||||
|
from .doctype.lms_sketch.lms_sketch import LMSSketch as Sketch
|
||||||
|
|
||||||
13
community/lms/widgets/CourseTeaser.html
Normal file
13
community/lms/widgets/CourseTeaser.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="course-teaser">
|
||||||
|
<div class="course-body">
|
||||||
|
<h3 class="course-title"><a href="/courses/{{ course.slug }}">{{ 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 }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
14
community/lms/widgets/HelloWorld.html
Normal file
14
community/lms/widgets/HelloWorld.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{#
|
||||||
|
Widget to demonostrate how to write a widget.
|
||||||
|
|
||||||
|
A wiget is a reusable template, that can be used in
|
||||||
|
other templates.
|
||||||
|
|
||||||
|
To this widget can be called as:
|
||||||
|
|
||||||
|
{{ widgets.HelloWorld(name="World") }}
|
||||||
|
#}
|
||||||
|
|
||||||
|
<div class="hello">
|
||||||
|
Hello, <em>{{ name }}</em>!
|
||||||
|
</div>
|
||||||
15
community/lms/widgets/SketchTeaser.html
Normal file
15
community/lms/widgets/SketchTeaser.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<div class="sketch-teaser">
|
||||||
|
<div class="sketch-image">
|
||||||
|
<a href="/sketches/{{sketch.sketch_id}}">
|
||||||
|
{{ sketch.to_svg() }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="sketch-footer">
|
||||||
|
<div class="sketch-title">
|
||||||
|
<a href="sketches/{{sketch.sketch_id}}">{{sketch.title}}</a>
|
||||||
|
</div>
|
||||||
|
<div class="sketch-author">
|
||||||
|
by {{sketch.get_owner().full_name}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
"public/css/lms.css"
|
"public/css/lms.css"
|
||||||
],
|
],
|
||||||
"css/community.css": [
|
"css/community.css": [
|
||||||
"public/css/style.css"
|
"public/css/vars.css",
|
||||||
|
"public/css/style.css",
|
||||||
|
"public/css/style.less"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,12 +25,14 @@
|
|||||||
--cta-color: var(--c4);
|
--cta-color: var(--c4);
|
||||||
--send-message: var(--c7);
|
--send-message: var(--c7);
|
||||||
--received-message: var(--c8);
|
--received-message: var(--c8);
|
||||||
|
|
||||||
|
--primary-color: #08B74F;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
background: var(--bg);
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.course-header {
|
.course-header {
|
||||||
@@ -200,10 +202,6 @@ img.profile-photo {
|
|||||||
|
|
||||||
/* override style of base */
|
/* override style of base */
|
||||||
|
|
||||||
nav.navbar {
|
|
||||||
background: var(--c1) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message {
|
.message {
|
||||||
border: 1px dashed var(--text-color);
|
border: 1px dashed var(--text-color);
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
@@ -290,4 +288,5 @@ nav.navbar {
|
|||||||
|
|
||||||
.message-section {
|
.message-section {
|
||||||
margin-left: 5%;
|
margin-left: 5%;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
68
community/public/css/style.less
Normal file
68
community/public/css/style.less
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
@primary-color: #08B74F;
|
||||||
|
|
||||||
|
.teaser {
|
||||||
|
background: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sketch-teaser {
|
||||||
|
.teaser();
|
||||||
|
width: 220px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
.sketch-image {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.sketch-footer {
|
||||||
|
padding: 10px;
|
||||||
|
background: #eee;
|
||||||
|
border-radius: 0px 0px 10px 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-teaser {
|
||||||
|
.teaser();
|
||||||
|
color: #444;
|
||||||
|
|
||||||
|
h3, h4 {
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-body, .course-footer {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-body {
|
||||||
|
min-height: 8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-footer {
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
a, a:hover {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
padding: 60px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section h2 {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section.lightgray {
|
||||||
|
background: #f8f8f8;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hero .jumbotron {
|
||||||
|
background: inherit;
|
||||||
|
}
|
||||||
4
community/public/css/vars.css
Normal file
4
community/public/css/vars.css
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/* Define all your css variables here. */
|
||||||
|
:root {
|
||||||
|
--primary-color: #08B74F;
|
||||||
|
}
|
||||||
16
community/test_widgets.py
Normal file
16
community/test_widgets.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2021, FOSS United and Contributors
|
||||||
|
# See license.txt
|
||||||
|
import frappe
|
||||||
|
import unittest
|
||||||
|
from .widgets import Widget, Widgets
|
||||||
|
|
||||||
|
class TestWidgets(unittest.TestCase):
|
||||||
|
def test_Widgets(self):
|
||||||
|
widgets = Widgets()
|
||||||
|
assert widgets.Foo.name == "Foo"
|
||||||
|
assert widgets.Bar.name == "Bar"
|
||||||
|
|
||||||
|
def _test_Widget(self):
|
||||||
|
hello = Widget("HelloWorld")
|
||||||
|
assert hello(name="Test") == "Hello, Test"
|
||||||
60
community/widgets.py
Normal file
60
community/widgets.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
"""The widgets provides access to HTML widgets
|
||||||
|
provided in each frappe module.
|
||||||
|
|
||||||
|
Widgets are simple moduler templates that can reused
|
||||||
|
in multiple places. These are like macros, but accessing
|
||||||
|
them will be a lot easier.
|
||||||
|
|
||||||
|
The widgets will be provided
|
||||||
|
"""
|
||||||
|
import frappe
|
||||||
|
from frappe.utils.jinja import get_jenv
|
||||||
|
|
||||||
|
# search path for widgets.
|
||||||
|
# When {{widgets.SomeWidget()}} is called, it looks for
|
||||||
|
# widgets/SomeWidgets.html in each of these modules.
|
||||||
|
MODULES = [
|
||||||
|
"lms"
|
||||||
|
]
|
||||||
|
|
||||||
|
def update_website_context(context):
|
||||||
|
"""Adds widgets to the context.
|
||||||
|
|
||||||
|
Called from hooks.
|
||||||
|
"""
|
||||||
|
context.widgets = Widgets()
|
||||||
|
|
||||||
|
class Widgets:
|
||||||
|
"""The widget collection.
|
||||||
|
|
||||||
|
This is just a placeholder object and returns the appropriate
|
||||||
|
widget when accessed using attribute.
|
||||||
|
|
||||||
|
>>> widgets = Widgets()
|
||||||
|
>>> widgets.HelloWorld(name="World!")
|
||||||
|
'<div>Hello, World!</div>'
|
||||||
|
"""
|
||||||
|
def __getattr__(self, name):
|
||||||
|
if not name.startswith("__"):
|
||||||
|
return Widget(name)
|
||||||
|
else:
|
||||||
|
raise AttributeError(name)
|
||||||
|
|
||||||
|
class Widget:
|
||||||
|
"""The Widget class renders a widget.
|
||||||
|
|
||||||
|
Widget is a reusable template defined in widgets/ directory in
|
||||||
|
each frappe module.
|
||||||
|
|
||||||
|
>>> w = Widget("HelloWorld")
|
||||||
|
>>> w(name="World!")
|
||||||
|
'<div>Hello, World!</div>'
|
||||||
|
"""
|
||||||
|
def __init__(self, name):
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
def __call__(self, **kwargs):
|
||||||
|
# the widget could be in any of the modules
|
||||||
|
paths = [f"{module}/widgets/{self.name}.html" for module in MODULES]
|
||||||
|
env = get_jenv()
|
||||||
|
return env.get_or_select_template(paths).render(kwargs)
|
||||||
@@ -1,15 +1,4 @@
|
|||||||
frappe.ready(() => {
|
frappe.ready(() => {
|
||||||
frappe.require("/assets/frappe/js/lib/socket.io.min.js");
|
|
||||||
frappe.require("/assets/frappe/js/frappe/socketio_client.js");
|
|
||||||
if (window.dev_server) {
|
|
||||||
frappe.boot.socketio_port = "9000" //use socketio port shown when bench starts
|
|
||||||
}
|
|
||||||
frappe.socketio.init();
|
|
||||||
console.log(frappe.socketio)
|
|
||||||
//frappe.socketio.emittedDemo("mydata");
|
|
||||||
frappe.realtime.on("new_lms_message", (data) => {
|
|
||||||
console.log(data)
|
|
||||||
})
|
|
||||||
if (frappe.session.user != "Guest") {
|
if (frappe.session.user != "Guest") {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
'method': 'community.lms.doctype.lms_mentor_request.lms_mentor_request.has_requested',
|
'method': 'community.lms.doctype.lms_mentor_request.lms_mentor_request.has_requested',
|
||||||
@@ -25,21 +14,6 @@ frappe.ready(() => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".list-batch").click((e) => {
|
|
||||||
var batch = decodeURIComponent($(e.currentTarget).attr("data-label"))
|
|
||||||
$(".current-batch").text(batch)
|
|
||||||
$(".send-message").attr("data-batch", batch)
|
|
||||||
frappe.call("community.www.courses.course.get_messages", { batch: batch }, (data) => {
|
|
||||||
if (data.message) {
|
|
||||||
$(".discussions").children().remove();
|
|
||||||
for (var i = 0; i < data.message.length; i++) {
|
|
||||||
var element = add_message(data.message[i])
|
|
||||||
$(".discussions").append(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
$(".apply-now").click((e) => {
|
$(".apply-now").click((e) => {
|
||||||
if (frappe.session.user == "Guest") {
|
if (frappe.session.user == "Guest") {
|
||||||
window.location.href = "/login";
|
window.location.href = "/login";
|
||||||
@@ -94,19 +68,4 @@ frappe.ready(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
/*
|
|
||||||
var show_enrollment_badge = () => {
|
|
||||||
$(".btn-enroll").addClass("hide");
|
|
||||||
$(".enrollment-badge").removeClass("hide");
|
|
||||||
}
|
|
||||||
|
|
||||||
var get_search_params = () => {
|
|
||||||
return new URLSearchParams(window.location.search)
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.btn-enroll').on('click', (e) => {
|
|
||||||
frappe.call('community.www.courses.course.enroll', { course: get_search_params().get("course") }, (data) => {
|
|
||||||
show_enrollment_badge()
|
|
||||||
});
|
|
||||||
}); */
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
{{ message.message }}
|
{{ message.message }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
frappe.ready(() => {
|
frappe.ready(() => {
|
||||||
const assets = [
|
const assets = [
|
||||||
"/assets/frappe/js/lib/socket.io.min.js",
|
"/assets/frappe/js/lib/socket.io.min.js",
|
||||||
"/assets/frappe/js/frappe/socketio_client.js"
|
"/assets/frappe/js/frappe/socketio_client.js",
|
||||||
]
|
]
|
||||||
frappe.require(assets, () => {
|
frappe.require(assets, () => {
|
||||||
if (window.dev_server) {
|
if (window.dev_server) {
|
||||||
frappe.boot.socketio_port = "9000" //use socketio port shown when bench starts
|
frappe.boot.socketio_port = "9000" //use socketio port shown when bench starts
|
||||||
}
|
}
|
||||||
frappe.socketio.init(9000);
|
frappe.socketio.init(9000);
|
||||||
console.log(frappe.socketio)
|
|
||||||
})
|
|
||||||
frappe.realtime.on("new_lms_message", (data) => {
|
|
||||||
console.log(data)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
}, 0);
|
}, 300);
|
||||||
|
|
||||||
$(".msger-send-btn").click((e) => {
|
$(".msger-send-btn").click((e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -27,10 +23,6 @@ frappe.ready(() => {
|
|||||||
"args": {
|
"args": {
|
||||||
"batch": decodeURIComponent($(e.target).attr("data-batch")),
|
"batch": decodeURIComponent($(e.target).attr("data-batch")),
|
||||||
"message": message
|
"message": message
|
||||||
},
|
|
||||||
"callback": (data) => {
|
|
||||||
$(".msger-input").val("");
|
|
||||||
frappe.realtime.publish("new_lms_message", {"message":"JJK"})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
51
community/www/home/index.html
Normal file
51
community/www/home/index.html
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{% extends "templates/base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ HeroSection() }}
|
||||||
|
{{ ExploreCourses(courses) }}
|
||||||
|
{{ RecentSketches(recent_sketches) }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% macro HeroSection() %}
|
||||||
|
<section id="hero">
|
||||||
|
<div class="container">
|
||||||
|
<div class="jumbotron">
|
||||||
|
<h1 class="display-4">Guided online courses, with a mentor at your back.</h1>
|
||||||
|
<p class="lead">Hands-on online courses designed by experts, delivered by passionate mentors.</p>
|
||||||
|
<p class="lead">
|
||||||
|
<a class="btn btn-primary btn-lg" href="#" role="button">Request Invite</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro ExploreCourses(courses) %}
|
||||||
|
<section id="explore-courses" class="lightgray">
|
||||||
|
<div class="container lightgray">
|
||||||
|
<h2>Explore Courses</h2>
|
||||||
|
<div class="row">
|
||||||
|
{% for course in courses %}
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ widgets.CourseTeaser(course=course) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro RecentSketches(sketches) %}
|
||||||
|
<section id="recet-sketches">
|
||||||
|
<div class="container">
|
||||||
|
<h2>Recent Sketches</h2>
|
||||||
|
<div class="row">
|
||||||
|
{% for sketch in sketches %}
|
||||||
|
<div class="col-md-3">
|
||||||
|
{{ widgets.SketchTeaser(sketch=sketch) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endmacro %}
|
||||||
7
community/www/home/index.py
Normal file
7
community/www/home/index.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import frappe
|
||||||
|
from community.lms.models import Course, Sketch
|
||||||
|
|
||||||
|
def get_context(context):
|
||||||
|
context.no_cache = 1
|
||||||
|
context.courses = Course.find_all()
|
||||||
|
context.recent_sketches = Sketch.get_recent_sketches(limit=8)
|
||||||
@@ -12,6 +12,6 @@ def get_context(context):
|
|||||||
|
|
||||||
def get_member(username):
|
def get_member(username):
|
||||||
try:
|
try:
|
||||||
frappe.get_doc("Community Member", {"username":username})
|
return frappe.get_doc("Community Member", {"username":username})
|
||||||
except frappe.DoesNotExistError:
|
except frappe.DoesNotExistError:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -16,37 +16,13 @@
|
|||||||
<a href="/sketches/new">Create a New Sketch</a>
|
<a href="/sketches/new">Create a New Sketch</a>
|
||||||
</div>
|
</div>
|
||||||
<div class='container'>
|
<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 ">
|
<div class="row">
|
||||||
{% for sketch in sketches %}
|
{% for sketch in sketches %}
|
||||||
<div class="col mb-4">
|
<div class="col-md-3">
|
||||||
<div class="card sketch-card" style="width: 200px;">
|
{{ widgets.SketchTeaser(sketch=sketch) }}
|
||||||
<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>
|
|
||||||
<div class="sketch-author">
|
|
||||||
by {{sketch.get_owner_name()}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block style %}
|
|
||||||
{{super()}}
|
|
||||||
<style type="text/css">
|
|
||||||
svg {
|
|
||||||
width: 200px;
|
|
||||||
height: 200px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from ...lms.doctype.lms_sketch.lms_sketch import get_recent_sketches
|
from community.lms.models import Sketch
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
context.sketches = get_recent_sketches()
|
context.sketches = Sketch.get_recent_sketches()
|
||||||
|
|
||||||
|
|||||||
34
docker-compose.yml
Normal file
34
docker-compose.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis-cache:
|
||||||
|
image: redis:alpine
|
||||||
|
redis-queue:
|
||||||
|
image: redis:alpine
|
||||||
|
redis-socketio:
|
||||||
|
image: redis:alpine
|
||||||
|
mariadb:
|
||||||
|
image: mariadb
|
||||||
|
volumes:
|
||||||
|
- mariadb-storage:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=root
|
||||||
|
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||||
|
bench:
|
||||||
|
image: anandology/frappe-bench
|
||||||
|
volumes:
|
||||||
|
- .:/home/bench/frappe-bench/apps/community
|
||||||
|
environment:
|
||||||
|
- FRAPPE_APPS=community
|
||||||
|
- FRAPPE_ALLOW_TESTS=true
|
||||||
|
- FRAPPE_SITE_NAME=frappe.localhost
|
||||||
|
depends_on:
|
||||||
|
- mariadb
|
||||||
|
- redis-cache
|
||||||
|
- redis-queue
|
||||||
|
- redis-socketio
|
||||||
|
ports:
|
||||||
|
- 8000:8000
|
||||||
|
- 9000:9000
|
||||||
|
volumes:
|
||||||
|
mariadb-storage: {}
|
||||||
Reference in New Issue
Block a user