feat: allow moderators to edit course

This commit is contained in:
Jannat Patel
2022-09-09 15:37:35 +05:30
parent 316e7be51e
commit 9dc10c3756
9 changed files with 18 additions and 15 deletions

View File

@@ -542,10 +542,6 @@ const build_attachment_table = (file_doc) => {
const make_editor = () => {
let comment = `<!--
{{ YouTubeVideo('Video Id') }}
{{ Quiz('Quiz Id') }}
-->`
this.code_field_group = new frappe.ui.FieldGroup({
fields: [
@@ -556,7 +552,7 @@ const make_editor = () => {
wrap: true,
max_lines: Infinity,
min_lines: 20,
default: $("#body").data("body") || comment,
default: $("#body").data("body"),
depends_on: 'eval:doc.type=="Markdown"',
}
],

View File

@@ -27,7 +27,7 @@ def get_context(context):
context.lesson = frappe._dict()
if frappe.form_dict.get("edit"):
if not is_instructor(context.course.name) or has_course_moderator_role():
if not is_instructor(context.course.name) and not has_course_moderator_role():
redirect_to_courses_list()
context.lesson.edit_mode = True
else:

View File

@@ -270,7 +270,7 @@
membership.current_lesson else "1.1" if first_lesson_exists(course.name) else None %}
{% if show_start_learing_cta %}
<div class="btn btn-primary wide-button join-batch" data-course="{{ course.name | urlencode }}">
<div class="btn btn-primary wide-button join-batch mb-2" data-course="{{ course.name | urlencode }}">
{{ _("Start Learning") }}
<img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
</div>
@@ -323,7 +323,7 @@
{% endif %}
{% endif %}
{% if is_instructor(course.name) %}
{% if is_instructor(course.name) or has_course_moderator_role() %}
<a class="btn btn-secondary wide-button" href="/courses/{{ course.name }}?edit=1"> {{ _("Edit Course") }} </a>
{% endif %}
{% endmacro %}
@@ -341,9 +341,9 @@
frappe.utils.format_time(certificate_request.start_time, "short")) }} </p>
{% endif %}
{% if course.status == "Under Review" %}
{% if course.status == "Under Review" and is_instructor(course.name) %}
<div class="mb-4">
{{ _("Your course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
{{ _("This course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
</div>
{% endif %}

View File

@@ -206,7 +206,7 @@ const submit_for_review = (e) => {
}, 3);
setTimeout(() => {
window.location.reload();
}, 3000);
}, 1000);
}
}
});

View File

@@ -28,7 +28,7 @@ def set_course_context(context, course_name):
as_dict=True)
if frappe.form_dict.get("edit"):
if not is_instructor(course.name) or not has_course_moderator_role():
if not is_instructor(course.name) and not has_course_moderator_role():
redirect_to_courses_list()
course.edit_mode = True