feat: course enrollment and my courses page

This commit is contained in:
pateljannat
2021-03-03 17:44:46 +05:30
parent b4eb9580af
commit acea59767d
17 changed files with 259 additions and 79 deletions

View File

@@ -0,0 +1,8 @@
// Copyright (c) 2021, Frappe and contributors
// For license information, please see license.txt
frappe.ui.form.on('Community Course Enrollment', {
// refresh: function(frm) {
// }
});

View File

@@ -0,0 +1,54 @@
{
"actions": [],
"creation": "2021-03-03 11:24:08.220185",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"course"
],
"fields": [
{
"fieldname": "course",
"fieldtype": "Link",
"label": "Course",
"options": "Community Course"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-03-03 11:44:32.011805",
"modified_by": "Administrator",
"module": "Community",
"name": "Community 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

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document
class CommunityCourseEnrollment(Document):
pass

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and Contributors
# See license.txt
from __future__ import unicode_literals
# import frappe
import unittest
class TestCommunityCourseEnrollment(unittest.TestCase):
pass

View File

@@ -41,7 +41,8 @@
"fieldname": "email",
"fieldtype": "Data",
"label": "Email",
"options": "Email"
"options": "Email",
"reqd": 1
},
{
"fieldname": "short_intro",
@@ -68,7 +69,7 @@
"index_web_pages_for_search": 1,
"is_published_field": "enabled",
"links": [],
"modified": "2021-03-02 17:53:40.252130",
"modified": "2021-03-03 15:00:46.298535",
"modified_by": "Administrator",
"module": "Community",
"name": "Community Course Member",
@@ -88,7 +89,7 @@
}
],
"quick_entry": 1,
"route": "username",
"route": "me",
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1

View File

@@ -9,10 +9,15 @@ from frappe.website.website_generator import WebsiteGenerator
from frappe import _
class CommunityCourseMember(WebsiteGenerator):
def get_context(self, context):
context.abbr = ("").join([ s[0] for s in self.full_name.split() ])
return context
def validate(self):
self.validate_user_name()
if not self.route:
self.route = "username/" + self.user_name
self.route = "me/" + self.user_name
def validate_user_name(self):
if len(self.user_name) < 4:
@@ -55,7 +60,7 @@ class CommunityCourseMember(WebsiteGenerator):
"username": self.user_name,
"send_welcome_email": 0,
"user_type": 'Website User',
"redirect_url": "username/" + self.name
"redirect_url": "me/" + self.name
})
user.save(ignore_permissions=True)
update_password_link = user.reset_password()

View File

@@ -1,14 +1,23 @@
{% extends "templates/web.html" %}
{% block page_content %}
<div class="py-20 row">
{% if photo %}
<div class="col-sm-2 border border-dark">
<img src="{{ photo }}" alt="{{ full_name }}">
</div>
{% else %}
<div class="col-sm-2">
<div class="standard-image" style="font-size: 30px;">{{ abbr }}</div>
</div>
{% endif %}
<div class="col">
<h1>{{ full_name }}</h1>
{% if short_intro %}
<p class="lead"> {{ short_intro }} </p>
{% endif %}
{% if bio %}
<p class="markdown-style"> {{ frappe.utils.md_to_html(bio) }} </p>
{% endif %}
</div>
</div>
{% endblock %}

View File

@@ -18,7 +18,7 @@
"is_standard": 1,
"login_required": 0,
"max_attachment_size": 0,
"modified": "2021-03-02 11:31:39.072501",
"modified": "2021-03-03 11:02:33.907687",
"modified_by": "Administrator",
"module": "Community",
"name": "community-course-membership",
@@ -70,42 +70,6 @@
"read_only": 0,
"reqd": 0,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "short_intro",
"fieldtype": "Data",
"hidden": 0,
"label": "Short Intro",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "bio",
"fieldtype": "Data",
"hidden": 0,
"label": "Bio",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "photo",
"fieldtype": "Attach Image",
"hidden": 0,
"label": "Photo",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0,
"show_in_filter": 0
}
]
}