fix: profile, dashboard and tests
This commit is contained in:
@@ -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`')
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 }}
|
||||
<div class="common-page-style dashboard">
|
||||
<div class="container">
|
||||
|
||||
{% if show_creators_section %}
|
||||
<a class="btn btn-secondary btn-sm pull-right" id="create-course-link" href="/courses/new-course">
|
||||
<a class="btn btn-secondary btn-sm course-creation-link" id="create-course-link" href="/courses/new-course">
|
||||
{{ _("Create a Course") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
8
lms/www/dashboard/index.py
Normal file
8
lms/www/dashboard/index.py
Normal file
@@ -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()
|
||||
@@ -58,7 +58,7 @@
|
||||
{% if frappe.session.user == member.email %}
|
||||
<div class="ml-auto mt-1">
|
||||
<a class="btn btn-secondary btn-sm" href="/dashboard"> {{ _("Visit Dashboard") }} </a>
|
||||
<a class="btn btn-secondary btn-sm ml-2" href="/edit-profile?name={{ member.email }}"> {{ _("Edit Profile") }} </a>
|
||||
<a class="btn btn-secondary btn-sm ml-2" href="/edit-profile/{{ member.email }}"> {{ _("Edit Profile") }} </a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user