Merge pull request #375 from pateljannat/fixes

This commit is contained in:
Jannat Patel
2022-09-14 20:42:54 +05:30
committed by GitHub
8 changed files with 180 additions and 195 deletions

View File

@@ -114,7 +114,8 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-07-28 13:41:29.224332",
"make_attachments_public": 1,
"modified": "2022-09-14 12:47:20.840223",
"modified_by": "Administrator",
"module": "Job",
"name": "Job Opportunity",
@@ -152,4 +153,4 @@
"sort_order": "DESC",
"states": [],
"title_field": "job_title"
}
}

View File

@@ -260,7 +260,8 @@
"link_fieldname": "course"
}
],
"modified": "2022-05-19 16:59:21.933367",
"make_attachments_public": 1,
"modified": "2022-09-14 13:26:53.153822",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course",

View File

@@ -9,12 +9,14 @@ from ...utils import generate_slug
from frappe.utils import flt, cint
from lms.lms.utils import get_chapters
class LMSCourse(Document):
def validate(self):
self.validate_instructors()
self.validate_status()
def validate_instructors(self):
if self.is_new() and not self.instructors:
frappe.get_doc({
@@ -25,14 +27,17 @@ class LMSCourse(Document):
"parenttype": "LMS Course"
}).save(ignore_permissions=True)
def validate_status(self):
if self.published:
self.status = "Approved"
def on_update(self):
if not self.upcoming and self.has_value_changed("upcoming"):
self.send_email_to_interested_users()
def send_email_to_interested_users(self):
interested_users = frappe.get_all("LMS Course Interest", {
"course": self.name
@@ -67,6 +72,7 @@ class LMSCourse(Document):
def __repr__(self):
return f"<Course#{self.name}>"
def has_mentor(self, email):
"""Checks if this course has a mentor with given email.
"""
@@ -76,6 +82,7 @@ class LMSCourse(Document):
mapping = frappe.get_all("LMS Course Mentor Mapping", {"course": self.name, "mentor": email})
return mapping != []
def add_mentor(self, email):
"""Adds a new mentor to the course.
"""
@@ -96,7 +103,6 @@ class LMSCourse(Document):
doc.insert()
def get_student_batch(self, email):
"""Returns the batch the given student is part of.
@@ -115,6 +121,7 @@ class LMSCourse(Document):
fieldname="batch")
return batch_name and frappe.get_doc("LMS Batch", batch_name)
def get_batches(self, mentor=None):
batches = frappe.get_all("LMS Batch", {"course": self.name})
if mentor:
@@ -126,17 +133,21 @@ class LMSCourse(Document):
batch_names = {m.batch for m in memberships}
return [b for b in batches if b.name in batch_names]
def get_cohorts(self):
return frappe.get_all("Cohort", {"course": self.name}, order_by="creation")
def get_cohort(self, cohort_slug):
name = frappe.get_value("Cohort", {"course": self.name, "slug": cohort_slug})
return name and frappe.get_doc("Cohort", name)
def reindex_exercises(self):
for i, c in enumerate(get_chapters(self.name), start=1):
self._reindex_exercises_in_chapter(c, i)
def _reindex_exercises_in_chapter(self, c, index):
i = 1
for lesson in self.get_lessons(c):
@@ -146,12 +157,14 @@ class LMSCourse(Document):
exercise.save()
i += 1
def get_all_memberships(self, member):
all_memberships = frappe.get_all("LMS Batch Membership", {"member": member, "course": self.name}, ["batch"])
for membership in all_memberships:
membership.batch_title = frappe.db.get_value("LMS Batch", membership.batch, "title")
return all_memberships
@frappe.whitelist()
def reindex_exercises(doc):
course_data = json.loads(doc)
@@ -159,6 +172,7 @@ def reindex_exercises(doc):
course.reindex_exercises()
frappe.msgprint("All exercises in this course have been re-indexed.")
@frappe.whitelist(allow_guest=True)
def search_course(text):
search_courses = []
@@ -184,6 +198,7 @@ def search_course(text):
return courses
@frappe.whitelist()
def submit_for_review(course):
chapters = frappe.get_all("Chapter Reference", {"parent": course})
@@ -209,8 +224,8 @@ def save_course(tags, title, short_introduction, video_link, description, course
"image": image,
"description": description,
"tags": tags,
"published": published,
"upcoming": upcoming
"published": cint(published),
"upcoming": cint(upcoming)
})
doc.save(ignore_permissions=True)
return doc.name

View File

@@ -9,7 +9,7 @@
</span>
{% elif not is_instructor(course.name) and frappe.session.user == "Guest" %}
<a class="btn btn-secondary btn-s pull-rightm" href="/login?redirect-to=/courses/{{ course.name }}"> {{ _("Login") }} </a>
{% elif not is_instructor(course.name) and not membership %}
{% elif not is_instructor(course.name) and not membership and course.status == "Approved" %}
<div class="btn btn-secondary btn-sm join-batch pull-right" data-course="{{ course.name | urlencode }}"> {{ _("Start Learning") }} </div>
{% endif %}
</div>

View File

@@ -1545,7 +1545,7 @@ li {
}
}
[contenteditable] {
[contenteditable="true"] {
outline: none;
background-color: var(--bg-light-gray);
border-radius: var(--border-radius);
@@ -1554,7 +1554,7 @@ li {
color: var(--gray-900);
}
[contenteditable]:empty:before {
[contenteditable="true"]:empty:before {
content: attr(data-placeholder);
color: var(--gray-600);
}
@@ -1592,7 +1592,7 @@ li {
padding: 0.5rem 0;
}
.course-card-pills[contenteditable] {
.course-card-pills[contenteditable="true"] {
box-shadow: none;
}

View File

@@ -26,7 +26,7 @@
{{ instructors }}
</div>
<hr style="margin: 0.5rem 0;">
<div> {{ _("Course Instructor") }} </div>
<div class="text-center"> {{ _("Course Instructor") }} </div>
</div>
{% endif %}
@@ -36,7 +36,7 @@
{{ frappe.utils.format_date(certificate.expiry_date, "medium") }}
</div>
<hr style="margin: 0.5rem 0;">
<div> {{ _("Expiry date") }} </div>
<div class="text-center"> {{ _("Expiry date") }} </div>
</div>
{% endif %}
</div>

View File

@@ -73,4 +73,4 @@ def get_user_interest(course):
def show_start_learing_cta(course, membership, restriction):
return not course.disable_self_learning and not membership and not course.upcoming and not restriction.get("restrict") and not is_instructor(course.name)
return not course.disable_self_learning and not membership and not course.upcoming and not restriction.get("restrict") and not is_instructor(course.name) and course.status == "Approved"

View File

@@ -53,14 +53,16 @@
<div class="tab-content">
<div class="tab-pane active" id="profile" role="tabpanel" aria-labelledby="profile">
{{ About(member) }}
{{ EducationDetails(member) }}
{{ WorkDetails(member) }}
{{ ExternalCertification(member) }}
{{ Contact(member) }}
{{ Skills(member) }}
{{ CareerPreference(member) }}
{{ ProfileTabs(profile_tabs) }}
<div class="common-card-style column-card mt-5">
{{ About(member) }}
{{ EducationDetails(member) }}
{{ WorkDetails(member) }}
{{ ExternalCertification(member) }}
{{ Contact(member) }}
{{ Skills(member) }}
{{ CareerPreference(member) }}
{{ ProfileTabs(profile_tabs) }}
</div>
</div>
{% if courses_created | length %}
@@ -91,7 +93,7 @@
<!-- Banner -->
{% macro ProfileBanner(member) %}
{% set cover_image = member.cover_image if member.cover_image else "/assets/lms/images/profile-banner.png" %}
{% set enrollment = get_course_membership(None, member_type="Student") | length %}
{% set enrollment = get_course_membership(member.name, member_type="Student") | length %}
{% set enrollment_suffix = _("Courses") if enrollment > 1 else _("Course") %}
<div class="container">
@@ -194,236 +196,202 @@
<!-- About Section -->
{% macro About(member) %}
<div class="education-details">
<div class="common-card-style column-card">
<div class="course-home-headings"> {{ _("About") }} </div>
<div class="description">
{% if member.bio %}
{{ member.bio }}
{% else %}
{{ _("Hey, my name is ") }} {{ member.full_name }}
{% endif %}
</div>
</div>
<div class="course-home-headings"> {{ _("About") }} </div>
<div class="description">
{% if member.bio %}
{{ member.bio }}
{% else %}
{{ _("Hey, my name is ") }} {{ member.full_name }}
{% endif %}
</div>
{% endmacro %}
<!-- Work Preference -->
{% macro WorkPreference(member) %}
<div class="education-details">
<div class="common-card-style column-card">
<div class="course-home-headings"> {{ _("Work Preference") }} </div>
<div> {{ member.attire }} </div>
<div> {{ member.collaboration }} </div>
<div> {{ member.role }} </div>
<div> {{ member.location_preference }} </div>
<div> {{ member.time }} </div>
<div> {{ member.company_type }} </div>
</div>
</div>
<div class="course-home-headings mt-10"> {{ _("Work Preference") }} </div>
<div> {{ member.attire }} </div>
<div> {{ member.collaboration }} </div>
<div> {{ member.role }} </div>
<div> {{ member.location_preference }} </div>
<div> {{ member.time }} </div>
<div> {{ member.company_type }} </div>
{% endmacro %}
<!-- Career Preference -->
{% macro CareerPreference(member) %}
{% if member.preferred_functions or member.preferred_industries or member.preferred_location or member.dream_companies %}
<div class="education-details">
<div class="common-card-style column-card">
<div class="course-home-headings"> {{ _("Career Preference") }} </div>
<div class="profile-column-grid">
{% if member.preferred_functions | length %}
<div>
<b>{{ _("Preferred Functions:") }}</b>
{% for function in member.preferred_functions %}
<div class="description">{{ function.function }}</div>
{% endfor %}
</div>
{% endif %}
{% if member.preferred_industries | length %}
<div>
<b>{{ _("Preferred Industries:") }}</b>
{% for industry in member.preferred_industries %}
<div class="description">{{ industry.industry }}</div>
{% endfor %}
</div>
{% endif %}
{% if member.preferred_location %}
<div>
<b> {{ _("Preferred Locations:") }} </b>
<div class="description"> {{ member.preferred_location }} </div>
</div>
{% endif %}
{% if member.dream_companies %}
<div>
<b> {{ _("Dream Companies:") }} </b>
<div class="description"> {{ member.dream_companies }} </div>
</div>
{% endif %}
{% if member.preferred_functions or member.preferred_industries or member.preferred_location or member.dream_companies %}
<div class="course-home-headings mt-10"> {{ _("Career Preference") }} </div>
<div class="profile-column-grid">
{% if member.preferred_functions | length %}
<div>
<b>{{ _("Preferred Functions:") }}</b>
{% for function in member.preferred_functions %}
<div class="description">{{ function.function }}</div>
{% endfor %}
</div>
{% endif %}
{% if member.preferred_industries | length %}
<div>
<b>{{ _("Preferred Industries:") }}</b>
{% for industry in member.preferred_industries %}
<div class="description">{{ industry.industry }}</div>
{% endfor %}
</div>
{% endif %}
{% if member.preferred_location %}
<div>
<b> {{ _("Preferred Locations:") }} </b>
<div class="description"> {{ member.preferred_location }} </div>
</div>
{% endif %}
{% if member.dream_companies %}
<div>
<b> {{ _("Dream Companies:") }} </b>
<div class="description"> {{ member.dream_companies }} </div>
</div>
{% endif %}
</div>
</div>
{% endif %}
{% endif %}
{% endmacro %}
<!-- Contact Section -->
{% macro Contact(member) %}
{% if member.linkedin or member.medium or member.github %}
<div class="education-details">
<div class="common-card-style column-card">
<div class="course-home-headings"> {{ _("Contact") }} </div>
<div class="profile-column-grid">
{% if member.linkedin %}
{% set linkedin = member.linkedin[:-1] if member.linkedin[-1] == "/" else member.linkedin %}
<a class="button-links description" href="{{ member.linkedin }}">
<img src="/assets/lms/icons/linkedin.svg"> {{ linkedin.split("/")[-1] }}
</a>
{% endif %}
{% if member.linkedin or member.medium or member.github %}
<div class="course-home-headings mt-10"> {{ _("Contact") }} </div>
<div class="profile-column-grid">
{% if member.linkedin %}
{% set linkedin = member.linkedin[:-1] if member.linkedin[-1] == "/" else member.linkedin %}
<a class="button-links description" href="{{ member.linkedin }}">
<img src="/assets/lms/icons/linkedin.svg"> {{ linkedin.split("/")[-1] }}
</a>
{% endif %}
{% if member.medium %}
<a class="button-links description" href="{{ member.medium}}">
<img src="/assets/lms/icons/medium.svg"> {{ member.medium.split("/")[-1] }}
</a>
{% endif %}
{% if member.medium %}
<a class="button-links description" href="{{ member.medium}}">
<img src="/assets/lms/icons/medium.svg"> {{ member.medium.split("/")[-1] }}
</a>
{% endif %}
{% if member.github %}
<a class="button-links description" href="{{ member.github }}">
<img src="/assets/lms/icons/github.svg"> {{ member.github.split("/")[-1] }}
</a>
{% endif %}
{% if member.github %}
<a class="button-links description" href="{{ member.github }}">
<img src="/assets/lms/icons/github.svg"> {{ member.github.split("/")[-1] }}
</a>
{% endif %}
</div>
</div>
</div>
{% endif %}
{% endif %}
{% endmacro %}
<!-- Skills -->
{% macro Skills(member) %}
{% if member.skill | length %}
<div class="education-details">
<div class="common-card-style column-card">
<div class="course-home-headings"> {{ _("Skills")}} </div>
<div class="profile-column-grid">
{% for skill in member.skill %}
<div class="description"> {{ skill.skill_name }} </div>
{% endfor %}
</div>
{% if member.skill | length %}
<div class="course-home-headings mt-10"> {{ _("Skills")}} </div>
<div class="profile-column-grid">
{% for skill in member.skill %}
<div class="description"> {{ skill.skill_name }} </div>
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
{% endmacro %}
<!-- Education Details -->
{% macro EducationDetails(member) %}
{% if member.education %}
<div class="education-details">
<div class="common-card-style column-card">
<div class="course-home-headings"> {{ _("Education") }} </div>
<div class="profile-grid-card">
{% for edu in member.education %}
<div class="column-card-row">
<div class="bold-title"> {{ edu.institution_name }} </div>
<div class="profile-item"> {{ edu.degree_type }} <span></span> {{ edu.major }}
{% if not member.hide_private %}
<!-- {% if edu.grade_type %} {{ edu.grade_type }} {% endif %} -->
{% if edu.grade %} <span></span> {{ edu.grade }} {% endif %}
{% endif %}
</div>
<div class="description">
{% if edu.start_date %}
{{ frappe.utils.format_date(edu.start_date, "MMM YYYY") }} -
{% endif %}
{{ frappe.utils.format_date(edu.end_date, "MMM YYYY") }}
</div>
<div class="description"> {{ edu.location }} </div>
{% if member.education %}
<div class="course-home-headings mt-10"> {{ _("Education") }} </div>
<div class="profile-grid-card">
{% for edu in member.education %}
<div class="column-card-row">
<div class="bold-title"> {{ edu.institution_name }} </div>
<div class="profile-item"> {{ edu.degree_type }} <span></span> {{ edu.major }}
{% if not member.hide_private %}
<!-- {% if edu.grade_type %} {{ edu.grade_type }} {% endif %} -->
{% if edu.grade %} <span></span> {{ edu.grade }} {% endif %}
{% endif %}
</div>
{% endfor %}
<div class="description">
{% if edu.start_date %}
{{ frappe.utils.format_date(edu.start_date, "MMM YYYY") }} -
{% endif %}
{{ frappe.utils.format_date(edu.end_date, "MMM YYYY") }}
</div>
<div class="description"> {{ edu.location }} </div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
{% endmacro %}
<!-- Work Details -->
{% macro WorkDetails(member) %}
{% set work_details = member.work_experience + member.internship %}
{% set work_details = member.work_experience + member.internship %}
{% if work_details | length %}
<div class="education-details">
<div class="common-card-style column-card">
<div class="course-home-headings"> {{ _("Work Experience") }} </div>
<div class="profile-grid-card">
{% if work_details | length %}
<div class="course-home-headings mt-10"> {{ _("Work Experience") }} </div>
<div class="profile-grid-card">
{% for work in work_details %}
<div class="">
<div class="bold-title"> {{ work.title }} </div>
<div class="profile-item"> {{ work.company }} </div>
<div class="description">
{{ frappe.utils.format_date(work.from_date, "MMM YYYY") }} -
{% if work.to_date %} {{ frappe.utils.format_date(work.to_date, "MMM YYYY") }}
{% else %} Present {% endif %}
</div>
<div class="description"> {{ work.location }} </div>
{% if work.description %}
<div class="profile-item">
{{ work.description }}
</div>
{% endif %}
{% for work in work_details %}
<div class="">
<div class="bold-title"> {{ work.title }} </div>
<div class="profile-item"> {{ work.company }} </div>
<div class="description">
{{ frappe.utils.format_date(work.from_date, "MMM YYYY") }} -
{% if work.to_date %} {{ frappe.utils.format_date(work.to_date, "MMM YYYY") }}
{% else %} Present {% endif %}
</div>
{% endfor %}
<div class="description"> {{ work.location }} </div>
{% if work.description %}
<div class="profile-item">
{{ work.description }}
</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
{% endmacro %}
<!-- Certifications -->
{% macro ExternalCertification(member) %}
{% if member.certification %}
<div class="education-details">
<div class="common-card-style column-card">
<div class="course-home-headings"> {{ _("External Certification") }} </div>
<div class="profile-grid-card">
{% for cert in member.certification %}
<div class="">
{% if member.certification %}
<div class="course-home-headings mt-10"> {{ _("External Certification") }} </div>
<div class="profile-grid-card">
{% for cert in member.certification %}
<div class="">
<div class="bold-title"> {{ cert.certification_name }} </div>
<div class="profile-item"> {{ cert.organization }} </div>
<div class="bold-title"> {{ cert.certification_name }} </div>
<div class="profile-item"> {{ cert.organization }} </div>
<div class="description">
{{ frappe.utils.format_date(cert.issue_date, "MMM YYYY") }}
{% if cert.expiration_date %}
- {{ frappe.utils.format_date(cert.expiration_date, "MMM YYYY") }}
{% endif %}
</div>
{% if cert.description %}
<div class="profile-item">
{{ cert.description }}
</div>
<div class="description">
{{ frappe.utils.format_date(cert.issue_date, "MMM YYYY") }}
{% if cert.expiration_date %}
- {{ frappe.utils.format_date(cert.expiration_date, "MMM YYYY") }}
{% endif %}
</div>
{% endfor %}
{% if cert.description %}
<div class="profile-item">
{{ cert.description }}
</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
{% endmacro %}