diff --git a/lms/lms/doctype/exercise/test_exercise.py b/lms/lms/doctype/exercise/test_exercise.py index 139b6f7a..9deaa690 100644 --- a/lms/lms/doctype/exercise/test_exercise.py +++ b/lms/lms/doctype/exercise/test_exercise.py @@ -6,10 +6,6 @@ import unittest from lms.lms.doctype.lms_course.test_lms_course import new_course class TestExercise(unittest.TestCase): - def setUp(self): - frappe.db.sql('delete from `tabLMS Batch Membership`') - frappe.db.sql('delete from `tabExercise Submission`') - frappe.db.sql('delete from `tabExercise`') def new_exercise(self): course = new_course("Test Course") @@ -47,3 +43,8 @@ class TestExercise(unittest.TestCase): user_submission = e.get_user_submission() assert user_submission is not None assert user_submission.name == submission.name + + def tearDown(self): + frappe.db.sql('delete from `tabLMS Batch Membership`') + frappe.db.sql('delete from `tabExercise Submission`') + frappe.db.sql('delete from `tabExercise`') diff --git a/lms/lms/doctype/lms_course/test_lms_course.py b/lms/lms/doctype/lms_course/test_lms_course.py index 542db568..ef133bda 100644 --- a/lms/lms/doctype/lms_course/test_lms_course.py +++ b/lms/lms/doctype/lms_course/test_lms_course.py @@ -7,13 +7,16 @@ import frappe from .lms_course import LMSCourse import unittest + class TestLMSCourse(unittest.TestCase): + def test_new_course(self): course = new_course("Test Course") assert course.title == "Test Course" assert course.name == "test-course" + # disabled this test as it is failing def _test_add_mentors(self): course = new_course("Test Course") @@ -26,10 +29,23 @@ class TestLMSCourse(unittest.TestCase): mentors_data = [dict(email=mentor.email, batch_count=mentor.batch_count) for mentor in mentors] assert mentors_data == [{"email": "tester@example.com", "batch_count": 0}] + def tearDown(self): if frappe.db.exists("User", "tester@example.com"): frappe.delete_doc("User", "tester@example.com") + if frappe.db.exists("LMS Course", "test-course"): + frappe.db.delete("Exercise Submission", {"course": "test-course"}) + frappe.db.delete("Exercise Latest Submission", {"course": "test-course"}) + frappe.db.delete("Exercise", {"course": "test-course"}) + frappe.db.delete("LMS Batch Membership", {"course": "test-course"}) + frappe.db.delete("LMS Batch", {"course": "test-course"}) + frappe.db.delete("LMS Course Mentor Mapping", {"course": "test-course"}) + frappe.db.delete("Course Instructor", {"parent": "test-course"}) + frappe.db.sql('delete from `tabCourse Instructor`') + frappe.delete_doc("LMS Course", "test-course") + + def new_user(name, email): user = frappe.db.exists("User", email) if user: @@ -46,6 +62,7 @@ def new_user(name, email): doc.insert() return doc + def new_course(title, additional_filters=None): course = frappe.db.exists("LMS Course", { "title": title }) if course: @@ -66,6 +83,7 @@ def new_course(title, additional_filters=None): doc.insert(ignore_permissions=True) return doc + def create_evaluator(): if not frappe.db.exists("Course Evaluator", "evaluator@example.com"): new_user("Evaluator", "evaluator@example.com") diff --git a/lms/lms/web_form/profile/profile.json b/lms/lms/web_form/profile/profile.json index 705b1e0d..f0e5ab81 100644 --- a/lms/lms/web_form/profile/profile.json +++ b/lms/lms/web_form/profile/profile.json @@ -18,11 +18,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-06-24 19:08:29.197279", + "modified": "2022-09-05 13:08:40.071348", "modified_by": "Administrator", "module": "LMS", "name": "profile", @@ -30,11 +30,9 @@ "payment_button_label": "Buy Now", "published": 1, "route": "edit-profile", - "route_to_success_link": 0, "show_attachments": 0, - "show_in_grid": 0, + "show_list": 0, "show_sidebar": 0, - "sidebar_items": [], "success_url": "/profile", "title": "Profile", "web_form_fields": [ @@ -50,18 +48,6 @@ "reqd": 1, "show_in_filter": 0 }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "middle_name", - "fieldtype": "Data", - "hidden": 0, - "label": "Middle Name (Optional)", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - }, { "allow_read_on_all_link_options": 0, "fieldname": "last_name", diff --git a/lms/overrides/user.py b/lms/overrides/user.py index 617f72bd..52db13c7 100644 --- a/lms/overrides/user.py +++ b/lms/overrides/user.py @@ -167,7 +167,8 @@ def get_authored_courses(member=None, only_published=True): for course in courses: detail = frappe.db.get_value("LMS Course", course.parent, ["name", "upcoming", "title", "image", "enable_certification", "status", "published"], as_dict=True) - if only_published and not detail.published: + + if only_published and detail and not detail.published: continue course_details.append(detail) diff --git a/lms/public/css/style.css b/lms/public/css/style.css index 6cdfe14b..5a4c85ed 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -44,32 +44,32 @@ input[type=checkbox] { } .course-image .course-tags { - width: 95%; + width: fit-content; } .course-card-pills { - background: #ffffff; - margin-left: 0; - margin-right: 1rem; - border-radius: var(--border-radius); - padding: 3.5px 8px; - font-size: 11px; - text-align: center; - letter-spacing: 0.011em; - text-transform: uppercase; - font-weight: 600; - color: var(--gray-900); - width: fit-content; - box-shadow: var(--shadow-sm); + background: #ffffff; + margin-left: 0; + margin-right: 1rem; + border-radius: var(--border-radius); + padding: 3.5px 8px; + font-size: 11px; + text-align: center; + letter-spacing: 0.011em; + text-transform: uppercase; + font-weight: 600; + color: var(--gray-900); + width: fit-content; + box-shadow: var(--shadow-sm); } .dark-pills { - background: rgba(25, 39, 52, 0.8); - color: #ffffff; + background: rgba(25, 39, 52, 0.8); + color: #ffffff; } .dark-pills img { - width: 0.75rem; - height: 0.75rem; + width: 0.75rem; + height: 0.75rem; } .common-page-style { @@ -903,7 +903,7 @@ pre { .empty-state { background: var(--gray-200); border-radius: var(--border-radius-lg); - padding: 2rem; + padding: 1.25rem; display: flex; justify-content: space-between; align-items: center; @@ -911,7 +911,6 @@ pre { .empty-state-text { flex: 1; - margin-left: 1.25rem; text-align: center; } @@ -1667,3 +1666,14 @@ li { color: var(--text-color); cursor: pointer; } + +.course-creation-link { + float: right; +} + +@media (max-width: 500px) { + .course-creation-link { + float: inherit; + margin-bottom: 1rem; + } +} diff --git a/lms/www/dashboard/index.html b/lms/www/dashboard/index.html index d4897187..03025f98 100644 --- a/lms/www/dashboard/index.html +++ b/lms/www/dashboard/index.html @@ -5,14 +5,12 @@ {% block content %} -{% set portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") %} -{% set show_creators_section = portal_course_creation == "Anyone" or has_course_instructor_role() %} {{ frappe.session.user }}
{% if show_creators_section %} - + {{ _("Create a Course") }} {% endif %} diff --git a/lms/www/dashboard/index.py b/lms/www/dashboard/index.py new file mode 100644 index 00000000..23616076 --- /dev/null +++ b/lms/www/dashboard/index.py @@ -0,0 +1,8 @@ +import frappe +from lms.lms.utils import has_course_instructor_role + + +def get_content(context): + context.no_cache = 1 + portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") + context.show_creators_section = portal_course_creation == "Anyone" or has_course_instructor_role() diff --git a/lms/www/profiles/profile.html b/lms/www/profiles/profile.html index 0878c6a4..962f4cea 100644 --- a/lms/www/profiles/profile.html +++ b/lms/www/profiles/profile.html @@ -58,7 +58,7 @@ {% if frappe.session.user == member.email %} {% endif %}