fix: clean urls for hackathons and correcting slug parameter for discussions
This commit is contained in:
@@ -137,7 +137,9 @@ primary_rules = [
|
|||||||
{"from_route": "/courses", "to_route": "courses"},
|
{"from_route": "/courses", "to_route": "courses"},
|
||||||
{"from_route": "/courses/<course>", "to_route": "courses/course"},
|
{"from_route": "/courses/<course>", "to_route": "courses/course"},
|
||||||
{"from_route": "/courses/<course>/<topic>", "to_route": "courses/topic"},
|
{"from_route": "/courses/<course>/<topic>", "to_route": "courses/topic"},
|
||||||
{"from_route": "/courses/<course>/<topic>", "to_route": "courses/topic"}
|
{"from_route": "/hackathons", "to_route": "hackathons"},
|
||||||
|
{"from_route": "/hackathons/<hackathon>", "to_route": "hackathons/hackathon"},
|
||||||
|
{"from_route": "/hackathons/<hackathon>/<project>", "to_route": "hackathons/project"}
|
||||||
]
|
]
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ from frappe import _
|
|||||||
from frappe.utils import add_days, nowdate
|
from frappe.utils import add_days, nowdate
|
||||||
class LMSMessage(Document):
|
class LMSMessage(Document):
|
||||||
def after_insert(self):
|
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"])
|
membership = frappe.get_all("LMS Batch Membership", {"batch": self.batch}, ["member"])
|
||||||
for entry in membership:
|
for entry in membership:
|
||||||
member = frappe.get_doc("Community Member", entry.member)
|
member = frappe.get_doc("Community Member", entry.member)
|
||||||
|
|||||||
@@ -29,13 +29,14 @@ def get_course(slug):
|
|||||||
)
|
)
|
||||||
return course
|
return course
|
||||||
|
|
||||||
def get_discussions(course):
|
def get_discussions(slug):
|
||||||
memberships = get_membership(course)
|
memberships = get_membership(slug)
|
||||||
messages = get_messages(memberships[0].batch)
|
messages = get_messages(memberships[0].batch)
|
||||||
return messages, memberships
|
return messages, memberships
|
||||||
|
|
||||||
def get_membership(course):
|
def get_membership(slug):
|
||||||
memberships = []
|
memberships = []
|
||||||
|
course = frappe.db.get_value("LMS Course", {"slug": slug}, "name")
|
||||||
member = frappe.db.get_value("Community Member", {"email": frappe.session.user}, "name")
|
member = frappe.db.get_value("Community Member", {"email": frappe.session.user}, "name")
|
||||||
batches = frappe.get_all("LMS Batch", {"course": course}, ["name"])
|
batches = frappe.get_all("LMS Batch", {"course": course}, ["name"])
|
||||||
for batch in batches:
|
for batch in batches:
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
{% macro card(project) %}
|
{% macro card(project) %}
|
||||||
<div class="col-sm-4 mb-4 text-left">
|
<div class="col-sm-4 mb-4 text-left">
|
||||||
<a href="/hackathons/project?project={{ project.name }}&hackathon={{ hackathon }}" class="no-decoration no-underline">
|
<a href="/hackathons/{{ hackathon }}/{{ project.name }}" class="no-decoration no-underline">
|
||||||
<div class="card h-100">
|
<div class="card h-100">
|
||||||
<div class='card-body'>
|
<div class='card-body'>
|
||||||
<h5 class='card-title'>{{ project.name }}</h5>
|
<h5 class='card-title'>{{ project.name }}</h5>
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
<div class='card-body'>
|
<div class='card-body'>
|
||||||
<p>{{ frappe.utils.md_to_html(update.project_update) }}</p>
|
<p>{{ frappe.utils.md_to_html(update.project_update) }}</p>
|
||||||
<div>
|
<div>
|
||||||
<a href="/hackathons/project?project={{update.project}}&hackathon={{hackathon}}">{{ update.project}}</a>
|
<a href="/hackathons/{{hackathon}}/{{update.project}}">{{ update.project}}</a>
|
||||||
by {{ show_user(update.owner) }}
|
by {{ show_user(update.owner) }}
|
||||||
<div class="text-muted">{{ frappe.utils.format_datetime(update.creation, "medium") }}</div>
|
<div class="text-muted">{{ frappe.utils.format_datetime(update.creation, "medium") }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% macro hackathon_card(hackathon) %}
|
{% macro hackathon_card(hackathon) %}
|
||||||
<div class="col-sm-4 mb-4 text-left">
|
<div class="col-sm-4 mb-4 text-left">
|
||||||
<a href="/hackathons/hackathon?hackathon={{ hackathon.name }}" class="no-decoration no-underline">
|
<a href="/hackathons/{{ hackathon.name }}" class="no-decoration no-underline">
|
||||||
<div class="card h-100">
|
<div class="card h-100">
|
||||||
<div class='card-body'>
|
<div class='card-body'>
|
||||||
<h5 class='card-title'>{{ hackathon.name }}</h5>
|
<h5 class='card-title'>{{ hackathon.name }}</h5>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<section class="section">
|
<section class="section">
|
||||||
{{ hero(project, {'name': hackathon, 'url': '/hackathons/hackathon?hackathon=' + hackathon}) }}
|
{{ hero(project, {'name': hackathon, 'url': '/hackathons/' + hackathon}) }}
|
||||||
<div class='container'>
|
<div class='container'>
|
||||||
{% if project %}
|
{% if project %}
|
||||||
<h1 class="mb-2">{{project.project_name}}</h1>
|
<h1 class="mb-2">{{project.project_name}}</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user