fix: exponse class info only to moderators

This commit is contained in:
Jannat Patel
2023-04-11 17:09:38 +05:30
parent 5fb7e88318
commit 7be9eb09e8
3 changed files with 7 additions and 5 deletions

View File

@@ -285,9 +285,8 @@
{%- block script %}
{{ super() }}
{% if is_moderator %}
<script>
{% if is_moderator %}
frappe.boot.user = {
"can_create": [],
"can_select": ["User"],
@@ -299,9 +298,9 @@
return name.toLowerCase().replace(/ /g, "-");
}
}
{% endif %}
let class_info = {{ class_info | json }};
</script>
{% endif %}
{{ include_script('controls.bundle.js') }}
{% endblock %}

View File

@@ -6,7 +6,7 @@
{% block page_content %}
<div class="common-page-style lms-page-style">
<div class="container">
{% if has_course_moderator_role() %}
{% if is_moderator %}
<button class="btn btn-secondary btn-sm pull-right" id="create-class">
{{ _("Create Class") }}
</button>
@@ -30,9 +30,11 @@
{%- block script %}
{{ super() }}
{{ include_script('controls.bundle.js') }}
{% if is_moderator %}
<script>
let class_info = null;
</script>
{% endif %}
{% endblock %}
{% macro ClassCards(classes) %}

View File

@@ -1,10 +1,11 @@
import frappe
from frappe.utils import getdate
from lms.lms.utils import has_course_moderator_role
def get_context(context):
context.no_cache = 1
context.is_moderator = has_course_moderator_role()
context.classes = frappe.get_all(
"LMS Class",
{"end_date": [">=", getdate()]},