feat: show counts on cohort listing and view pages

Issue #271
This commit is contained in:
Anand Chitipothu
2021-12-02 10:36:17 +05:30
parent e014c94446
commit c96e3ee2f9
5 changed files with 51 additions and 28 deletions

View File

@@ -4,6 +4,15 @@
{% block page_content %}
<h2>{{cohort.title}} <span class="badge badge-secondary">Cohort</span></h2>
<p>
{% set stats = cohort.get_stats() %}
{{ stats.subgroups }} Subgroups
| {{ stats.mentors }} Mentors
| {{ stats.students }} students
| {{ stats.join_requests }} join requests
</p>
<h5>Subgroups</h5>
<ul class="list-group">
{% for sg in cohort.get_subgroups(include_counts=True) %}

View File

@@ -16,7 +16,7 @@ def get_context(context):
utils.add_nav(context, "All Courses", "/courses")
utils.add_nav(context, course.title, "/courses/" + course.name)
utils.add_nav(context, "Cohorts", "/courses/" + course.name + "/cohorts")
utils.add_nav(context, "Cohorts", "/courses/" + course.name + "/manage")
context.course = course
context.cohort = cohort

View File

@@ -2,23 +2,19 @@
{% block title %}Manage {{ course.title }}{% endblock %}
{% block page_content %}
<div class="common-page-style">
<div class="container">
{% if cohorts %}
<h2>Cohorts</h2>
<div class="row">
{% for cohort in cohorts %}
<div class="col-md-4">
{{ render_cohort(course, cohort) }}
</div>
{% endfor %}
{% else %}
<h2>Permission Denied</h2>
<p>You don't have permission to manage this course.</p>
{% endif %}
</div>
</div>
</div>
{% if cohorts %}
<h2>Cohorts</h2>
<div class="row">
{% for cohort in cohorts %}
<div class="col-md-6">
{{ render_cohort(course, cohort) }}
</div>
{% endfor %}
</div>
{% else %}
<h2>Permission Denied</h2>
<p>You don't have permission to manage this course.</p>
{% endif %}
{% endblock %}
{% macro render_cohort(course, cohort) %}
@@ -26,6 +22,14 @@
<div class="card-body">
<h5 class="card-title">{{cohort.title}}</h5>
<h6 class="card-subtitle mb-2 text-muted">{{cohort.begin_date}} - {{cohort.end_date}}</h6>
<p>
{% set stats = cohort.get_stats() %}
{{ stats.subgroups }} Subgroups
| {{ stats.mentors }} Mentors
| {{ stats.students }} students
| {{ stats.join_requests }} join requests
</p>
<a href="/courses/{{course.name}}/cohorts/{{cohort.slug}}" class="card-link">Manage</a>
</div>

View File

@@ -17,7 +17,7 @@ def get_context(context):
utils.add_nav(context, "All Courses", "/courses")
utils.add_nav(context, course.title, f"/courses/{course.name}")
utils.add_nav(context, "Cohorts", f"/courses/{course.name}/cohorts")
utils.add_nav(context, "Cohorts", f"/courses/{course.name}/manage")
utils.add_nav(context, cohort.title, f"/courses/{course.name}/cohorts/{cohort.slug}")
context.course = course