diff --git a/README.md b/README.md index 5150a070..7dd33577 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Community App #### License -MIT \ No newline at end of file +AGPL \ No newline at end of file diff --git a/community/hooks.py b/community/hooks.py index 7669e2fe..c7d5210e 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -137,7 +137,9 @@ primary_rules = [ {"from_route": "/courses", "to_route": "courses"}, {"from_route": "/courses/", "to_route": "courses/course"}, {"from_route": "/courses//", "to_route": "courses/topic"}, - {"from_route": "/courses//", "to_route": "courses/topic"} + {"from_route": "/hackathons", "to_route": "hackathons"}, + {"from_route": "/hackathons/", "to_route": "hackathons/hackathon"}, + {"from_route": "/hackathons//", "to_route": "hackathons/project"} ] # Any frappe default URL is blocked by profile-rules, add it here to unblock it diff --git a/community/lms/doctype/lms_message/lms_message.py b/community/lms/doctype/lms_message/lms_message.py index 739f07b6..4e490075 100644 --- a/community/lms/doctype/lms_message/lms_message.py +++ b/community/lms/doctype/lms_message/lms_message.py @@ -9,6 +9,12 @@ from frappe import _ from frappe.utils import add_days, nowdate class LMSMessage(Document): def after_insert(self): + message = self.as_dict() + message['broadcast'] = True + frappe.publish_realtime('new_lms_message', message, after_commit=True) + self.send_email() + + def send_email(self): membership = frappe.get_all("LMS Batch Membership", {"batch": self.batch}, ["member"]) for entry in membership: member = frappe.get_doc("Community Member", entry.member) diff --git a/community/www/courses/course.py b/community/www/courses/course.py index 32396a18..85c953dd 100644 --- a/community/www/courses/course.py +++ b/community/www/courses/course.py @@ -29,13 +29,14 @@ def get_course(slug): ) return course -def get_discussions(course): - memberships = get_membership(course) +def get_discussions(slug): + memberships = get_membership(slug) messages = get_messages(memberships[0].batch) return messages, memberships -def get_membership(course): +def get_membership(slug): memberships = [] + course = frappe.db.get_value("LMS Course", {"slug": slug}, "name") member = frappe.db.get_value("Community Member", {"email": frappe.session.user}, "name") batches = frappe.get_all("LMS Batch", {"course": course}, ["name"]) for batch in batches: diff --git a/community/www/hackathons/hackathon.html b/community/www/hackathons/hackathon.html index 7f15a18d..7dd50542 100644 --- a/community/www/hackathons/hackathon.html +++ b/community/www/hackathons/hackathon.html @@ -41,7 +41,7 @@ {% macro card(project) %}