fix: cohort issue

This commit is contained in:
Jannat Patel
2022-10-13 17:12:13 +05:30
parent 437f637be9
commit f9748cb723
7 changed files with 33 additions and 30 deletions

View File

@@ -61,6 +61,7 @@
"fieldtype": "Data",
"in_list_view": 1,
"label": "Slug",
"reqd": 1,
"unique": 1
},
{
@@ -105,7 +106,7 @@
"link_fieldname": "cohort"
}
],
"modified": "2021-12-16 14:44:25.406301",
"modified": "2022-10-13 15:46:32.322926",
"modified_by": "Administrator",
"module": "LMS",
"name": "Cohort",
@@ -127,5 +128,6 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}

View File

@@ -137,7 +137,7 @@ class LMSCourse(Document):
def get_cohorts(self):
return frappe.get_all("Cohort", {"course": self.name}, order_by="creation")
return frappe.get_all("Cohort", {"course": self.name}, ["name", "slug"], order_by="creation")
def get_cohort(self, cohort_slug):

View File

@@ -2,22 +2,24 @@
{% block title %}Manage {{ course.title }}{% endblock %}
{% block page_content %}
<h2>{{cohort.title}} <span class="badge badge-secondary">Cohort</span></h2>
<div class="course-home-headings">
{{ cohort.title }}
</div>
<p>
{% set stats = cohort.get_stats() %}
{{ stats.subgroups }} Subgroups
| {{ stats.mentors }} Mentors
| {{ stats.students }} students
| {{ stats.join_requests }} join requests
{{ stats.subgroups }} {{ _("Subgroups")}}
| {{ stats.mentors }} {{ _("Mentors") }}
| {{ stats.students }} {{ _("Students") }}
| {{ stats.join_requests }} {{ _("Join Requests") }}
</p>
{% if is_mentor %}
<div class="alert alert-info">
{% set sg = mentor.get_subgroup() %}
<p>You are a mentor of <b>{{sg.title}}</b> subgroup.</p>
<p><a href="{{sg.get_url()}}" class="btn btn-primary">Visit Your Subgroup &rarr;</a></p>
{% set sg = mentor.get_subgroup() %}
<div class="alert alert-info medium">
<a href="{{sg.get_url()}}">{{ _("You are a mentor of {0} subgroup.").format(frappe.bold(sg.title)) }}</a>
</div>
{% endif %}

View File

@@ -1,5 +1,6 @@
import frappe
from .utils import get_course, add_nav
from frappe.utils import get_url
def get_context(context):
context.no_cache = 1
@@ -14,7 +15,7 @@ def get_context(context):
context.cohorts = get_cohorts(context.course)
if len(context.cohorts) == 1:
frappe.local.flags.redirect_location = context.cohorts[0].get_url()
frappe.local.flags.redirect_location = f"{get_url()}/courses/{context.course.name}/cohorts/{context.cohorts[0].slug}"
raise frappe.Redirect
add_nav(context, "All Courses", "/courses")

View File

@@ -2,10 +2,9 @@
{% block title %} Subgroup {{subgroup.title}} - {{ course.title }} {% endblock %}
{% block page_content %}
<h2 id="page-title"
data-subgroup="{{subgroup.name}}"
data-title="{{subgroup.title}}"
>{{subgroup.title}} <span class="badge badge-secondary">Subgroup</span></h2>
<div id="page-title" class="course-home-headings" data-subgroup="{{subgroup.name}}" data-title="{{subgroup.title}}">
{{subgroup.title}}
</div>
<ul class="nav nav-tabs">
{{ render_navitem("Mentors", "/mentors", stats.mentors, page=="mentors")}}
@@ -51,31 +50,30 @@
{% endmacro %}
{% macro render_mentors() %}
<h5>Mentors</h5>
{% set mentors = subgroup.get_mentors() %}
{% if mentors %}
<div class="member-parent">
{% for m in mentors %}
{{ widgets.MemberCard(member=m, show_course_count=False) }}
{{ widgets.MemberCard(member=m, avatar_class="avatar-medium", show_course_count=False) }}
{% endfor %}
</div>
{% else %}
<em>None found.</em>
<div>None found.</div>
{% endif %}
{% endmacro %}
{% macro render_students() %}
{% set students = subgroup.get_students() %}
{% if students %}
<div class="member-parent">
{% for student in students %}
{{ widgets.MemberCard(member=student, show_course_count=False) }}
{% endfor %}
</div>
{% else %}
<em>None found.</em>
{% endif %}
{% set students = subgroup.get_students() %}
{% if students %}
<div class="member-parent">
{% for student in students %}
{{ widgets.MemberCard(member=student, avatar_class="avatar-medium", show_course_count=False) }}
{% endfor %}
</div>
{% else %}
<div>None found.</div>
{% endif %}
{% endmacro %}

View File

@@ -315,7 +315,7 @@
{% elif is_cohort_staff(course.name, frappe.session.user) %}
<a class="btn btn-secondary button-links wide-button" href="/courses/{{course.name}}/manage">
{{ _("Manage the course") }}
{{ _("Manage Cohorts") }}
</a>
{% elif membership %}

View File