fix: removed global discussions page

This commit is contained in:
pateljannat
2021-08-30 12:47:15 +05:30
parent 7a9039090d
commit b3403b78ee
7 changed files with 0 additions and 117 deletions

View File

@@ -141,7 +141,6 @@ website_route_rules = [
{"from_route": "/courses/<course>/learn/<int:chapter>.<int:lesson>", "to_route": "batch/learn"},
{"from_route": "/courses/<course>/progress", "to_route": "batch/progress"},
{"from_route": "/courses/<course>/join", "to_route": "batch/join"},
{"from_route": "/discussions/<discussion>", "to_route": "discussions/discussion"},
{"from_route": "/user/<string(minlength=4):username>", "to_route": "profiles/profile"},
]

View File

@@ -1,16 +0,0 @@
{% extends "templates/base.html" %}
{% block title %}{{ thread.title }}{% endblock %}
{% block head_include %}
<style>
</style>
{% endblock %}
{% block content %}
<div class="common-page-style">
<div class="container">
{{ widgets.BreadCrumb(thread=thread) }}
<div class="course-home-headings">{{ thread.title }}</div>
{{ widgets.DiscussionMessage(thread=thread.name) }}
</div>
</div>
{% endblock %}

View File

@@ -1,18 +0,0 @@
import frappe
def get_context(context):
context.no_cache = 1
try:
thread_name = frappe.form_dict["discussion"]
except KeyError:
redirect_to_discussions()
context.thread = frappe.db.get_value("Discussion Thread", thread_name, ["name", "title"], as_dict=True)
if not len(context.thread):
redirect_to_discussions
def redirect_to_discussions():
frappe.local.flags.redirect_location = "/discussions"
raise frappe.Redirect

View File

@@ -1,51 +0,0 @@
{% extends "templates/base.html" %}
{% block title %}{{ 'Discussions' }}{% endblock %}
{% block head_include %}
<style>
</style>
{% endblock %}
{% block content %}
<div class="common-page-style">
<div class="container">
<div class="courses-header">
<span>{{_('Discussions')}}</span>
<div id="new-topic" class="button is-primary pull-right">
<img src="/assets/community/icons/small-add.svg">
Start a Discussion</div>
</div>
<div class="card-divider-dark"></div>
{% if threads | length %}
<div class="cards-parent">
{% for thread in threads %}
<div class="common-card-style thread-card">
<div class="course-card-title">{{ thread.title }}</div>
<div class="card-divider"></div>
<div>
<span class="course-student-count">
<span class="mr-4">
<img class="icon-background" src="/assets/community/icons/message.svg" />
{{ thread.message_count }}
</span>
<span class="mr-4">
<img class="icon-background" src="/assets/community/icons/user.svg" />
{{ thread.member_count }}
</span>
</span>
</div>
<a class="stretched-link" href="/discussions/{{ thread.name }}"></a>
</div>
{% endfor %}
</div>
{% else %}
<div class="text-center font-weight-bold mt-5">
No discussions yet.
</div>
{% endif %}
</div>
</div>
<!-- New Topic Modal -->
{% endblock %}

View File

@@ -1,14 +0,0 @@
frappe.ready(() => {
$("#new-topic").click((e) => {
show_new_topic_modal(e);
})
})
var show_new_topic_modal = (e) => {
e.preventDefault();
if (frappe.session.user == "Guest") {
window.location.href = `/login?redirect-to=/discussions/`;
return;
}
$("#discussion-modal").modal("show");
}

View File

@@ -1,17 +0,0 @@
import frappe
def get_context(context):
context.threads = get_threads()
def get_threads():
threads = frappe.get_all("Discussion Thread", fields=["name", "title"])
for thread in threads:
messages = frappe.get_all("Discussion Message",
{
"thread": thread.name
},
["owner"],
as_list=True)
thread.message_count = len(messages)
thread.member_count = len(set(messages))
return threads