fix: show first chapter and question form by default

This commit is contained in:
Jannat Patel
2022-09-15 22:52:17 +05:30
parent f3adbfef55
commit 47b9b1dcd6
11 changed files with 69 additions and 21 deletions

View File

@@ -45,6 +45,7 @@
"fieldtype": "Column Break"
},
{
"default": "Full Time",
"fieldname": "type",
"fieldtype": "Select",
"label": "Type",
@@ -115,7 +116,7 @@
"index_web_pages_for_search": 1,
"links": [],
"make_attachments_public": 1,
"modified": "2022-09-14 12:47:20.840223",
"modified": "2022-09-15 17:22:21.662675",
"modified_by": "Administrator",
"module": "Job",
"name": "Job Opportunity",

View File

@@ -9,10 +9,23 @@ from frappe.utils import get_link_to_form
class JobOpportunity(Document):
def validate(self):
self.validate_urls()
self.validate_logo()
def validate_urls(self):
frappe.utils.validate_url(self.company_website, True)
frappe.utils.validate_url(self.application_link, True)
def validate_logo(self):
if "/private" in self.company_logo:
frappe.db.set_value("File", {"file_url": self.company_logo}, "is_private", 0)
frappe.db.set_value("File", {"file_url": self.company_logo}, "file_url", self.company_logo.replace("/private", ""))
self.company_logo = self.company_logo.replace("/private", "")
@frappe.whitelist()
def report(job, reason):
system_managers = get_system_managers(only_name=True)

View File

@@ -16,11 +16,11 @@
"docstatus": 0,
"doctype": "Web Form",
"idx": 0,
"is_multi_step_form": 0,
"is_standard": 1,
"list_columns": [],
"login_required": 1,
"max_attachment_size": 0,
"modified": "2022-02-24 11:31:25.290524",
"modified": "2022-09-15 17:22:43.957184",
"modified_by": "Administrator",
"module": "Job",
"name": "job-opportunity",
@@ -28,11 +28,9 @@
"payment_button_label": "Buy Now",
"published": 1,
"route": "job-opportunity",
"route_to_success_link": 1,
"show_attachments": 0,
"show_in_grid": 0,
"show_list": 1,
"show_sidebar": 0,
"sidebar_items": [],
"success_message": "",
"success_url": "/jobs",
"title": "Job Opportunity",
@@ -63,6 +61,7 @@
},
{
"allow_read_on_all_link_options": 0,
"default": "Full Time",
"fieldname": "type",
"fieldtype": "Select",
"hidden": 0,

View File

@@ -1,18 +1,28 @@
<div class="course-home-outline">
{% set chapters = get_chapters(course.name) %}
{% if course.edit_mode and course.name %}
<button class="btn btn-md btn-secondary btn-chapter pull-right"> {{ _("New Chapter") }} </button>
{% endif %}
{% if course.name and (course.edit_mode or get_chapters(course.name) | length) %}
{% if course.name and (course.edit_mode or chapters | length) %}
<div class="course-home-headings" id="outline-heading">
{{ _("Course Content") }}
</div>
{% endif %}
{% if get_chapters(course.name) | length %}
{% if course.edit_mode and course.name and not chapters | length %}
<div class="chapter-parent chapter-edit new-chapter">
<div contenteditable="true" data-placeholder="{{ _('Chapter Name') }}" class="chapter-title-main"></div>
<div class="chapter-description small my-2" contenteditable="true" data-placeholder="{{ _('Short Description') }}"></div>
<button class="btn btn-sm btn-secondary d-block btn-save-chapter" data-index="1"> {{ _('Save') }} </button>
</div>
{% endif %}
{% for chapter in get_chapters(course.name) %}
{% if chapters | length %}
{% for chapter in chapters %}
<div class="chapter-parent {% if course.edit_mode %} chapter-edit {% endif %} ">
<div class="chapter-title" {% if not course.edit_mode %} data-toggle="collapse" aria-expanded="false"
data-target="#{{ get_slugified_chapter_title(chapter.title) }}" {% endif %} >

View File

@@ -127,7 +127,7 @@ const scroll_to_chapter_container = () => {
scrollTop: $(".new-chapter").offset().top
}, 1000);
$(".new-chapter").find(".chapter-title-main").focus();
}
};
const save_chapter = (e) => {
@@ -150,7 +150,7 @@ const save_chapter = (e) => {
});
setTimeout(() => {
window.location.reload();
}, 1000)
}, 1000);
}
});
};

View File

@@ -33,7 +33,9 @@
</div>
<div class="lesson-pagination-parent">
{{ LessonContent(lesson) }}
{% if not lesson.edit_mode %} {{ Discussions() }} {% endif %}
{% if not lesson.edit_mode and course.staus == "Approved" and not course.upcoming %}
{{ Discussions() }}
{% endif %}
</div>
</div>
</div>

View File

@@ -498,8 +498,14 @@ const save_lesson = (e) => {
"idx": $("#title").data("index"),
"lesson": lesson ? lesson : ""
},
callback: (data) => {
window.location.href = window.location.href.split("?")[0];
callback: (data) => {;
frappe.show_alert({
message: __("Saved"),
indicator: "green",
});
setTimeout(() => {
window.location.href = window.location.href.split("?")[0];
}, 1000);
}
});
};

View File

@@ -24,7 +24,7 @@ def get_context(context):
context.lesson = get_current_lesson_details(lesson_number, context)
instructor = is_instructor(context.course.name)
context.show_lesson = context.membership or context.lesson.include_in_preview or instructor or has_course_moderator_role()
context.show_lesson = context.membership or (context.lesson and context.lesson.include_in_preview) or instructor or has_course_moderator_role()
if not context.lesson:
context.lesson = frappe._dict()

View File

@@ -40,7 +40,7 @@
{% for question in quiz.questions %}
<div class="quiz-card">
<div contenteditable="true" data-placeholder="{{ _('Question') }}" data-question="{{ question.name }}"
class="question mb-4">{% if question.question %} {{ question.question }} {% endif %}</div>
class="question mb-4 req">{% if question.question %} {{ question.question }} {% endif %}</div>
{% for i in range(1,5) %}
{% set num = frappe.utils.cstr(i) %}

View File

@@ -1,7 +1,11 @@
frappe.ready(() => {
if(!$(".quiz-card").length) {
add_question();
}
$(".btn-question").click((e) => {
add_question(e);
add_question();
});
$(".btn-save-question").click((e) => {
@@ -17,10 +21,15 @@ frappe.ready(() => {
});
const add_question = (e) => {
const add_question = () => {
if ($(".new-quiz-card").length) {
scroll_to_question_container();
return;
}
let add_after = $(".quiz-card").length ? $(".quiz-card:last") : $("#quiz-title");
let question_template = `<div class="quiz-card">
<div contenteditable="true" data-placeholder="${__("Question")}" class="question mb-4"></div>
let question_template = `<div class="quiz-card new-quiz-card">
<div contenteditable="true" data-placeholder="${__("Question")}" class="question req mb-4"></div>
</div>`;
$(question_template).insertAfter(add_after);
get_question_template();
@@ -109,3 +118,11 @@ const get_questions = () => {
return questions;
};
const scroll_to_question_container = () => {
$([document.documentElement, document.body]).animate({
scrollTop: $(".new-quiz-card").offset().top
}, 1000);
$(".new-quiz-card").find(".question").focus();
}

View File

@@ -22,7 +22,7 @@
{{ Description(course) }}
{{ Save(course) }}
{{ widgets.CourseOutline(course=course, membership=membership, is_user_interested=is_user_interested) }}
{% if not course.edit_mode %}
{% if not course.edit_mode and course.staus == "Approved" and not course.upcoming %}
{{ widgets.Reviews(course=course, membership=membership) }}
{% endif %}
</div>