Merge pull request #402 from pateljannat/dashboard-profile-merge
This commit is contained in:
@@ -156,6 +156,7 @@ website_route_rules = [
|
||||
|
||||
website_redirects = [
|
||||
{"source": "/update-profile", "target": "/edit-profile"},
|
||||
{"source": "/dashboard", "target": "/users"},
|
||||
]
|
||||
|
||||
update_website_context = [
|
||||
|
||||
@@ -12,11 +12,13 @@ from lms.lms.utils import get_chapters
|
||||
|
||||
class LMSCourse(Document):
|
||||
|
||||
|
||||
def validate(self):
|
||||
self.validate_instructors()
|
||||
self.validate_status()
|
||||
self.image = validate_image(self.image)
|
||||
|
||||
|
||||
def validate_instructors(self):
|
||||
if self.is_new() and not self.instructors:
|
||||
frappe.get_doc({
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"show_search",
|
||||
"force_profile_completion",
|
||||
"portal_course_creation",
|
||||
"column_break_2",
|
||||
"search_placeholder",
|
||||
"portal_course_creation",
|
||||
"force_profile_completion",
|
||||
"column_break_2",
|
||||
"custom_certificate_template",
|
||||
"livecode_url",
|
||||
"signup_settings_section",
|
||||
@@ -55,13 +54,6 @@
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "show_search",
|
||||
"fieldtype": "Check",
|
||||
"label": "Show Search on Website"
|
||||
},
|
||||
{
|
||||
"depends_on": "show_search",
|
||||
"fieldname": "search_placeholder",
|
||||
"fieldtype": "Data",
|
||||
"label": "Course List Search Bar Placeholder"
|
||||
@@ -150,7 +142,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2022-08-22 10:02:59.988499",
|
||||
"modified": "2022-10-11 16:26:15.898514",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
@@ -32,3 +32,4 @@ lms.patches.v0_0.delete_old_module_docs #08-07-2022
|
||||
lms.patches.v0_0.delete_course_web_forms #21-08-2022
|
||||
lms.patches.v0_0.create_course_instructor_role #29-08-2022
|
||||
lms.patches.v0_0.create_course_moderator_role
|
||||
lms.patches.v0_0.set_dashboard #11-10-2022
|
||||
|
||||
4
lms/patches/v0_0/set_dashboard.py
Normal file
4
lms/patches/v0_0/set_dashboard.py
Normal file
@@ -0,0 +1,4 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.db.set_value("Portal Settings", None, "default_portal_home", "/users")
|
||||
@@ -50,7 +50,7 @@ input[type=checkbox] {
|
||||
.course-card-pills {
|
||||
background: #ffffff;
|
||||
margin-left: 0;
|
||||
margin-right: 1rem;
|
||||
margin-right: 0.5rem;
|
||||
border-radius: var(--border-radius);
|
||||
padding: 3.5px 8px;
|
||||
font-size: 11px;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{% for certificate in certificates %}
|
||||
{% set course = frappe.db.get_value("LMS Course", certificate.course, ["title", "name", "image"], as_dict=True) %}
|
||||
|
||||
<div class="common-card-style column-card">
|
||||
<div class="common-card-style column-card medium">
|
||||
<div class="font-weight-bold">
|
||||
{{ course.title }}
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
<div class="{{ classes }}">
|
||||
{% if courses | length %}
|
||||
<div class="course-home-headings">
|
||||
{{ title }}
|
||||
</div>
|
||||
<div class="cards-parent">
|
||||
{% for course in courses %}
|
||||
{{ widgets.CourseCard(course=course, read_only=False) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<img class="icon icon-xl" src="/assets/lms/icons/comment.svg">
|
||||
<div class="empty-state-text">
|
||||
<div class="empty-state-heading">{{ _("No {0}").format(title) }}</div>
|
||||
<div class="course-meta">{{ _("There are no {0} on this site.").format(title.lower()) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
{% set search_placeholder = frappe.db.get_single_value("LMS Settings", "search_placeholder") %}
|
||||
{% set portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") %}
|
||||
|
||||
<div class="course-search-header">
|
||||
<input class="search" id="search-course" placeholder="{{ _(search_placeholder) or 'Search' }}">
|
||||
{% if portal_course_creation == "Anyone" or has_course_instructor_role() %}
|
||||
<a class="btn btn-secondary btn-md ml-2" href="/courses/new-course"> {{ _("Create a Course") }} </a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<input class="search" id="search-course" placeholder="{{ _(search_placeholder) or 'Search' }}">
|
||||
<div class="empty-state alert alert-dismissible search-empty-state hide">
|
||||
<a href="#" class="close-search-empty-state" aria-label="close">×</a>
|
||||
<div>
|
||||
|
||||
@@ -26,19 +26,95 @@
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
{% include "lms/templates/search_course/search_course.html" %}
|
||||
|
||||
<div class="course-list">
|
||||
{% set courses = live_courses %}
|
||||
{% set title = _("Live Courses ({0})").format(courses | length) %}
|
||||
{% set classes = "live-courses" %}
|
||||
{% include "lms/templates/course_list.html" %}
|
||||
<!-- {% include "lms/templates/search_course/search_course.html" %} -->
|
||||
|
||||
<div class="course-home-headings">
|
||||
{{ _("All Courses") }}
|
||||
</div>
|
||||
|
||||
{% if show_creators_section %}
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-secondary btn-sm" href="/users"> {{ _("Visit Dashboard") }} </a>
|
||||
<a class="btn btn-secondary btn-sm ml-2" href="/courses/new-course"> {{ _("Create a Course") }} </a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<ul class="nav lms-nav" id="courses-tab">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#live">
|
||||
{{ _("Live") }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#upcoming">
|
||||
{{ _("Upcoming") }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if frappe.session.user != "Guest" %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-enrolled">
|
||||
{{ _("Enrolled") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if show_creators_section %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-created">
|
||||
{{ _("Created") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if show_review_section %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-under-review">
|
||||
{{ _("Under Review") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
<div class="border-bottom mb-4"></div>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="live" role="tabpanel" aria-labelledby="live">
|
||||
{% set courses = live_courses %}
|
||||
{% set title = _("Live Courses") %}
|
||||
{% set classes = "live-courses" %}
|
||||
{% include "lms/templates/course_list.html" %}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="upcoming" role="tabpanel" aria-labelledby="upcoming">
|
||||
{% set courses = upcoming_courses %}
|
||||
{% set title = _("Upcoming Courses") %}
|
||||
{% set classes = "upcoming-courses" %}
|
||||
{% include "lms/templates/course_list.html" %}
|
||||
</div>
|
||||
|
||||
{% if frappe.session.user != "Guest" %}
|
||||
<div class="tab-pane fade" id="courses-enrolled" role="tabpanel" aria-labelledby="courses-enrolled">
|
||||
{% include "lms/lms/web_template/courses_enrolled/courses_enrolled.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_creators_section %}
|
||||
<div class="tab-pane fade" id="courses-created" role="tabpanel" aria-labelledby="courses-created">
|
||||
{% include "lms/templates/courses_created.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_review_section %}
|
||||
<div class="tab-pane fade" id="courses-under-review" role="tabpanel" aria-labelledby="courses-under-review">
|
||||
{% include "lms/templates/courses_under_review.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
{% set courses = upcoming_courses %}
|
||||
{% set title = _("Upcoming Courses ({0})").format(courses | length) %}
|
||||
{% set classes = "upcoming-courses mt-10" %}
|
||||
{% include "lms/templates/course_list.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
from lms.lms.utils import check_profile_restriction, get_restriction_details
|
||||
from lms.lms.utils import has_course_instructor_role, has_course_moderator_role, check_profile_restriction, get_restriction_details
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
context.live_courses, context.upcoming_courses = get_courses()
|
||||
context.restriction = check_profile_restriction()
|
||||
portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation")
|
||||
context.show_creators_section = frappe.session.user != "Guest" and \
|
||||
(portal_course_creation == "Anyone" or has_course_instructor_role())
|
||||
context.show_review_section = has_course_moderator_role() and frappe.session.user != "Gurst"
|
||||
|
||||
if context.restriction:
|
||||
context.restriction_details = get_restriction_details()
|
||||
|
||||
context.metatags = {
|
||||
"title": _("All Live Courses"),
|
||||
"title": _("Courses List"),
|
||||
"image": frappe.db.get_single_value("Website Settings", "banner_image"),
|
||||
"description": "This page lists all the courses published on our website",
|
||||
"keywords": "All Courses, Courses, Learn"
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}
|
||||
{{ _("Dashboard")}}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="common-page-style dashboard">
|
||||
<div class="container">
|
||||
|
||||
{% if show_creators_section %}
|
||||
<a class="btn btn-secondary btn-sm course-creation-link" id="create-course-link" href="/courses/new-course">
|
||||
{{ _("Create a Course") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<ul class="nav lms-nav" id="courses-tab">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#courses-enrolled">
|
||||
{{ _("Enrolled") }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if show_creators_section %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-created">
|
||||
{{ _("Created") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if show_review_section %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-under-review">
|
||||
{{ _("Under Review") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#notifications">{{ _("Notifications") }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="border-bottom mb-4"></div>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="courses-enrolled" role="tabpanel" aria-labelledby="courses-enrolled">
|
||||
{% include "lms/lms/web_template/courses_enrolled/courses_enrolled.html" %}
|
||||
</div>
|
||||
|
||||
{% if show_creators_section %}
|
||||
<div class="tab-pane fade" id="courses-created" role="tabpanel" aria-labelledby="courses-created">
|
||||
{% include "lms/templates/courses_created.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_review_section %}
|
||||
<div class="tab-pane fade" id="courses-under-review" role="tabpanel" aria-labelledby="courses-under-review">
|
||||
{% include "lms/templates/courses_under_review.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="tab-pane" id="notifications" role="tabpanel" aria-labelledby="notifications">
|
||||
{% include "lms/templates/notifications.html" %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||
{% endblock %}
|
||||
@@ -1,24 +0,0 @@
|
||||
import frappe
|
||||
from datetime import datetime
|
||||
from lms.lms.utils import has_course_instructor_role, has_course_moderator_role, get_lesson_index
|
||||
|
||||
|
||||
def get_context(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()
|
||||
context.show_review_section = has_course_moderator_role()
|
||||
context.notifications = get_notifications()
|
||||
|
||||
|
||||
def get_notifications():
|
||||
notifications = frappe.get_all("Notification Log", {
|
||||
"document_type": "Course Lesson",
|
||||
"for_user": frappe.session.user
|
||||
}, ["subject", "creation", "from_user", "document_name"])
|
||||
|
||||
for notification in notifications:
|
||||
course = frappe.db.get_value("Course Lesson", notification.document_name, "course")
|
||||
notification.url = "/courses/{0}/learn/{1}".format(course, get_lesson_index(notification.document_name))
|
||||
|
||||
return notifications
|
||||
@@ -23,6 +23,14 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if not read_only %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-enrolled">
|
||||
{{ _("Courses Enrolled") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if courses_created | length %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-created">
|
||||
@@ -39,6 +47,13 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if not read_only %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#notifications">{{ _("Notifications") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if has_course_moderator_role() %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#settings">
|
||||
@@ -65,6 +80,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not read_only %}
|
||||
<div class="tab-pane fade" id="courses-enrolled" role="tabpanel" aria-labelledby="courses-enrolled">
|
||||
{% include "lms/lms/web_template/courses_enrolled/courses_enrolled.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if courses_created | length %}
|
||||
{% set only_published = True %}
|
||||
<div class="tab-pane fade" id="courses-created" role="tabpanel" aria-labelledby="courses-created">
|
||||
@@ -78,6 +99,12 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not read_only %}
|
||||
<div class="tab-pane" id="notifications" role="tabpanel" aria-labelledby="notifications">
|
||||
{% include "lms/templates/notifications.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings">
|
||||
{{ RoleSettings(member) }}
|
||||
</div>
|
||||
@@ -117,7 +144,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" href="/courses"> {{ _("Course List") }} </a>
|
||||
<a class="btn btn-secondary btn-sm ml-2" href="/edit-profile/{{ member.email }}/edit"> {{ _("Edit Profile") }} </a>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -176,7 +203,7 @@
|
||||
<div class="">
|
||||
<div class="common-card-style column-card">
|
||||
<div class="course-home-headings"> {{ _("Role Settings") }} </div>
|
||||
<div>
|
||||
<div class="medium">
|
||||
<label class="role">
|
||||
<input type="checkbox" id="instructor" data-role="Course Instructor"
|
||||
{% if has_course_instructor_role(member.name) %} checked {% endif %}>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
from lms.page_renderers import get_profile_url_prefix
|
||||
from lms.lms.utils import get_lesson_index
|
||||
|
||||
|
||||
def get_context(context):
|
||||
@@ -20,6 +21,7 @@ def get_context(context):
|
||||
return
|
||||
|
||||
context.profile_tabs = get_profile_tabs(context.member)
|
||||
context.notifications = get_notifications()
|
||||
|
||||
|
||||
def get_profile_tabs(user):
|
||||
@@ -30,3 +32,16 @@ def get_profile_tabs(user):
|
||||
"""
|
||||
tabs = frappe.get_hooks("profile_tabs") or []
|
||||
return [frappe.get_attr(tab)(user) for tab in tabs]
|
||||
|
||||
|
||||
def get_notifications():
|
||||
notifications = frappe.get_all("Notification Log", {
|
||||
"document_type": "Course Lesson",
|
||||
"for_user": frappe.session.user
|
||||
}, ["subject", "creation", "from_user", "document_name"])
|
||||
|
||||
for notification in notifications:
|
||||
course = frappe.db.get_value("Course Lesson", notification.document_name, "course")
|
||||
notification.url = "/courses/{0}/learn/{1}".format(course, get_lesson_index(notification.document_name))
|
||||
|
||||
return notifications
|
||||
|
||||
Reference in New Issue
Block a user