signup-and-onboarding

This commit is contained in:
Jannat Patel
2022-12-16 16:44:55 +05:30
parent 9d373d4091
commit f93d7b0193
14 changed files with 80 additions and 90 deletions

View File

@@ -58,10 +58,13 @@ web_include_js = ["website.bundle.js"]
# ------------
# before_install = "lms.install.before_install"
after_install = "lms.install.after_install"
after_sync = "lms.install.after_sync"
after_uninstall = "lms.install.after_uninstall"
setup_wizard_requires = "assets/lms/js/setup_wizard.js"
# Desk Notifications
# ------------------
# See frappe.core.notifications.get_notification_config
@@ -284,4 +287,6 @@ profile_url_prefix = "/users/"
signup_form_template = "lms.plugins.show_custom_signup"
on_login = "lms.overrides.user.set_country_from_ip"
on_login = "lms.overrides.user.on_login"
on_session_creation = "lms.overrides.user.on_session_creation"

View File

@@ -2,12 +2,48 @@ import frappe
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
def after_install():
add_pages_to_nav()
def after_sync():
create_lms_roles()
set_default_home()
add_all_roles_to("Administrator")
def add_pages_to_nav():
pages = [
{"label": "Explore", "idx": 1},
{"label": "Courses", "url": "/courses", "parent": "Explore", "idx": 2},
{"label": "Classes", "url": "/classes", "parent": "Explore", "idx": 3},
{"label": "Statistics", "url": "/statistics", "parent": "Explore", "idx": 4},
{"label": "Jobs", "url": "/jobs", "parent": "Explore", "idx": 5},
{"label": "People", "url": "/community", "parent": "Explore", "idx": 6},
]
for page in pages:
filters = frappe._dict()
if page.get("url"):
filters["url"] = ["like", "%" + page.get("url") + "%"]
else:
filters["label"] = page.get("label")
if not frappe.db.exists("Top Bar Item", filters):
frappe.get_doc(
{
"doctype": "Top Bar Item",
"label": page.get("label"),
"url": page.get("url"),
"parent_label": page.get("parent"),
"idx": page.get("idx"),
"parent": "Website Settings",
"parenttype": "Website Settings",
"parentfield": "top_bar_items",
}
).save()
def after_uninstall():
delete_custom_fields()

View File

@@ -1,7 +0,0 @@
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on("LMS Course Enrollment", {
// refresh: function(frm) {
// }
});

View File

@@ -1,61 +0,0 @@
{
"actions": [],
"creation": "2021-03-03 11:24:08.220185",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"course",
"user"
],
"fields": [
{
"fieldname": "course",
"fieldtype": "Link",
"label": "Course",
"options": "LMS Course"
},
{
"fieldname": "user",
"fieldtype": "Data",
"label": "User",
"options": "Email"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-03-05 12:59:22.973826",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course Enrollment",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Student",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}

View File

@@ -1,9 +0,0 @@
# Copyright (c) 2021, FOSS United and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class LMSCourseEnrollment(Document):
pass

View File

@@ -1,9 +0,0 @@
# Copyright (c) 2021, FOSS United and Contributors
# See license.txt
# import frappe
import unittest
class TestLMSCourseEnrollment(unittest.TestCase):
pass

View File

View File

@@ -0,0 +1,3 @@
frappe.pages['lms-home'].on_page_load = function(wrapper) {
window.location.href = '/courses'
}

View File

@@ -0,0 +1,19 @@
{
"content": null,
"creation": "2022-12-15 13:45:06.602567",
"docstatus": 0,
"doctype": "Page",
"idx": 0,
"modified": "2022-12-15 13:45:06.602567",
"modified_by": "Administrator",
"module": "LMS",
"name": "lms-home",
"owner": "Administrator",
"page_name": "lms-home",
"roles": [],
"script": null,
"standard": "Yes",
"style": null,
"system_page": 1,
"title": "LMS"
}

View File

@@ -8,7 +8,6 @@ from frappe import _
from frappe.core.doctype.user.user import User
from frappe.utils import cint, escape_html, random_string
from frappe.website.utils import is_signup_disabled
from lms.lms.utils import validate_image
from lms.widgets import Widgets
@@ -295,6 +294,14 @@ def get_country_code():
return
def on_login(login_manager):
set_country_from_ip()
def on_session_creation(login_manager):
frappe.local.response["home_page"] = "/courses"
@frappe.whitelist(allow_guest=True)
def search_users(start=0, text=""):
or_filters = get_or_filters(text)

View File

@@ -36,6 +36,7 @@ lms.patches.v0_0.set_dashboard #11-10-2022
lms.patches.v0_0.set_courses_page_as_home
lms.patches.v0_0.set_member_in_progress #09-11-2022
lms.patches.v0_0.convert_progress_to_float
lms.patches.v0_0.add_pages_to_nav #25-11-2022
lms.patches.v0_0.change_role_names
lms.patches.v0_0.quiz_submission_result
lms.patches.v0_0.skill_to_user_skill

View File

@@ -0,0 +1,5 @@
frappe.provide("lms.setup");
// redirect to desk page 'lms' after setup wizard is complete
// 'lms' desk page redirects to '/courses'
frappe.setup.welcome_page = "/app/lms-home";

View File

@@ -205,9 +205,9 @@
<div class="course-home-headings"> {{ _("Role Settings") }} </div>
<div class="medium">
<label class="role">
<input type="checkbox" id="instructor" data-role="Instructor"
<input type="checkbox" id="course-creator" data-role="Course Creator"
{% if has_course_instructor_role(member.name) %} checked {% endif %}>
{{ _("Instructor") }}
{{ _("Course Creator") }}
</label>
<label class="role">
<input type="checkbox" id="moderator" data-role="Moderator"