From b3403b78ee3b8e94d32027e22249e3b3fcb6a618 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Mon, 30 Aug 2021 12:47:15 +0530 Subject: [PATCH] fix: removed global discussions page --- community/hooks.py | 1 - community/www/discussions/__init__.py | 0 community/www/discussions/discussion.html | 16 ------- community/www/discussions/discussion.py | 18 -------- community/www/discussions/index.html | 51 ----------------------- community/www/discussions/index.js | 14 ------- community/www/discussions/index.py | 17 -------- 7 files changed, 117 deletions(-) delete mode 100644 community/www/discussions/__init__.py delete mode 100644 community/www/discussions/discussion.html delete mode 100644 community/www/discussions/discussion.py delete mode 100644 community/www/discussions/index.html delete mode 100644 community/www/discussions/index.js delete mode 100644 community/www/discussions/index.py diff --git a/community/hooks.py b/community/hooks.py index 00472b15..488cbe9e 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -141,7 +141,6 @@ website_route_rules = [ {"from_route": "/courses//learn/.", "to_route": "batch/learn"}, {"from_route": "/courses//progress", "to_route": "batch/progress"}, {"from_route": "/courses//join", "to_route": "batch/join"}, - {"from_route": "/discussions/", "to_route": "discussions/discussion"}, {"from_route": "/user/", "to_route": "profiles/profile"}, ] diff --git a/community/www/discussions/__init__.py b/community/www/discussions/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/community/www/discussions/discussion.html b/community/www/discussions/discussion.html deleted file mode 100644 index afa8d8b1..00000000 --- a/community/www/discussions/discussion.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %}{{ thread.title }}{% endblock %} -{% block head_include %} - -{% endblock %} - -{% block content %} -
-
- {{ widgets.BreadCrumb(thread=thread) }} -
{{ thread.title }}
- {{ widgets.DiscussionMessage(thread=thread.name) }} -
-
-{% endblock %} diff --git a/community/www/discussions/discussion.py b/community/www/discussions/discussion.py deleted file mode 100644 index 605e70c8..00000000 --- a/community/www/discussions/discussion.py +++ /dev/null @@ -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 diff --git a/community/www/discussions/index.html b/community/www/discussions/index.html deleted file mode 100644 index 5125a37b..00000000 --- a/community/www/discussions/index.html +++ /dev/null @@ -1,51 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %}{{ 'Discussions' }}{% endblock %} -{% block head_include %} - -{% endblock %} - -{% block content %} -
-
-
- {{_('Discussions')}} -
- - Start a Discussion
-
-
- {% if threads | length %} -
- {% for thread in threads %} -
-
{{ thread.title }}
-
-
- - - - {{ thread.message_count }} - - - - {{ thread.member_count }} - - -
- -
- {% endfor %} -
- {% else %} -
- No discussions yet. -
- {% endif %} -
-
- - - - -{% endblock %} diff --git a/community/www/discussions/index.js b/community/www/discussions/index.js deleted file mode 100644 index 0cac1f1a..00000000 --- a/community/www/discussions/index.js +++ /dev/null @@ -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"); -} diff --git a/community/www/discussions/index.py b/community/www/discussions/index.py deleted file mode 100644 index d474b2a5..00000000 --- a/community/www/discussions/index.py +++ /dev/null @@ -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