From 7cd57cadb2c641678c8fd3809d136f908c0ef0a8 Mon Sep 17 00:00:00 2001
From: Anand Chitipothu You don't have permission to manage this course. {{link}}
+
+ Course: {{course.title}}
+
+ Cohort: {{cohort.title}}
+
+ Subgroup: {{subgroup.title}}
+
+ Please login to be able to join the course.
+ If you don't already have an account, you can sign up for a new account.
+ You are already a student of this course. We have received your request to join the course. You'll hear back from us soon.
+ {% set stats = cohort.get_stats() %}
+
+ {{ stats.subgroups }} Subgroups
+ | {{ stats.mentors }} Mentors
+ | {{ stats.students }} students
+ | {{ stats.join_requests }} join requests
+ You don't have permission to manage this course. You don't have permission to manage this course.
+ {% set stats = cohort.get_stats() %}
+
+ {{ stats.subgroups }} Subgroups
+ | {{ stats.mentors }} Mentors
+ | {{ stats.students }} students
+ | {{ stats.join_requests }} join requests
+ Cohorts
+ Permission Denied
+
{% endif %}
+
+ {% if course.is_cohort_staff(frappe.session.user) %}
+
+ Manage the course
+
+ {% endif %}
From 1277cfed64f113311b6a919253d3abbdbaf73075 Mon Sep 17 00:00:00 2001
From: Anand Chitipothu {{cohort.title}} Cohort
+
+Subgroups
+
+ {% for sg in cohort.get_subgroups(include_counts=True) %}
+
+{% endblock %}
+
diff --git a/school/www/cohorts/cohort.py b/school/www/cohorts/cohort.py
new file mode 100644
index 00000000..da120492
--- /dev/null
+++ b/school/www/cohorts/cohort.py
@@ -0,0 +1,34 @@
+import frappe
+from . import utils
+
+def get_context(context):
+ context.no_cache = 1
+ if frappe.session.user == "Guest":
+ frappe.local.flags.redirect_location = "/login?redirect-to=" + frappe.request.path
+ raise frappe.Redirect()
+
+ course = utils.get_course()
+ cohort = course and get_cohort(course, frappe.form_dict["cohort"])
+
+ if not cohort:
+ context.template = "www/404.html"
+ return
+
+ 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")
+
+ context.course = course
+ context.cohort = cohort
+
+def get_cohort(course, cohort_slug):
+ cohort = utils.get_cohort(course, cohort_slug)
+
+ if cohort.is_mentor(frappe.session.user):
+ mentor = cohort.get_mentor(frappe.session.user)
+ sg = frappe.get_doc("Cohort Subgroup", mentor.subgroup)
+ frappe.local.flags.redirect_location = f"/courses/{course.name}/subgroups/{cohort.slug}/{sg.slug}"
+ raise frappe.Redirect
+ elif cohort.is_admin(frappe.session.user) or "System Manager" in frappe.get_roles():
+ return cohort
+
diff --git a/school/www/cohorts/subgroup.html b/school/www/cohorts/subgroup.html
new file mode 100644
index 00000000..c1b6f164
--- /dev/null
+++ b/school/www/cohorts/subgroup.html
@@ -0,0 +1,136 @@
+{% extends "www/cohorts/base.html" %}
+{% block title %} Subgroup {{subgroup.title}} - {{ course.title }} {% endblock %}
+
+{% block page_content %}
+ {{subgroup.title}} Subgroup
+
+
+ Invite Link
+ {% set link = subgroup.get_invite_link() %}
+
+ Copy to Clipboard
+ Mentors
+ {% set mentors = subgroup.get_mentors() %}
+ {% if mentors %}
+ {% for m in mentors %}
+
+
+{% endmacro %}
+
+{% macro render_navitem(title, link, count, active) %}
+
+
+ {% for r in subgroup.get_join_requests() %}
+ #
+ When
+ Email
+ Actions
+
+
+ {% endfor %}
+ {{loop.index}}
+ {{r.creation}}
+ {{r.email}}
+
+ Approve | Reject
+ Join Course
+
+
+ {% else %}
+ There are no pending join requests.
+ {% endif %}
{% endmacro %}
{% macro render_navitem(title, link, count, active) %}
@@ -118,7 +123,7 @@ $(function() {
frappe.confirm(
`Are you sure to accept ${email} to this subgroup?`,
function() {
- console.log("approve", name);
+ run_action("school.lms.api.approve_cohort_join_request", name);
}
);
});
@@ -127,10 +132,23 @@ $(function() {
var name = $(this).parent().data("name");
var email = $(this).parent().data("email");
frappe.confirm(`Are you sure to reject ${email} from joining this subgroup?`, function() {
- console.log("reject", name);
+ run_action("school.lms.api.reject_cohort_join_request", name);
});
});
+ function run_action(method, join_request) {
+ frappe.call(method, {
+ join_request: join_request,
+ })
+ .then(r => {
+ if (r.message.ok) {
+ window.location.reload();
+ }
+ else {
+ frappe.msgprint(r.message.error);
+ }
+ });
+ }
});
{% endblock %}
From 6c747ff8b4875e03f3b9a9c9cd538b162b83c552 Mon Sep 17 00:00:00 2001
From: Anand Chitipothu
{% endfor %}
#
@@ -78,6 +80,9 @@
{{cohort.title}} Cohort
+Subgroups
{% for sg in cohort.get_subgroups(include_counts=True) %}
diff --git a/school/www/cohorts/cohort.py b/school/www/cohorts/cohort.py
index da120492..54fb17af 100644
--- a/school/www/cohorts/cohort.py
+++ b/school/www/cohorts/cohort.py
@@ -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
diff --git a/school/www/cohorts/index.html b/school/www/cohorts/index.html
index dcb4c5d8..68009df8 100644
--- a/school/www/cohorts/index.html
+++ b/school/www/cohorts/index.html
@@ -2,23 +2,19 @@
{% block title %}Manage {{ course.title }}{% endblock %}
{% block page_content %}
-
Cohorts
- Permission Denied
- Cohorts
+ Permission Denied
+ {{cohort.title}}
{{cohort.begin_date}} - {{cohort.end_date}}
+
You are a mentor of {{sg.title}} subgroup.
+ +| Actions | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{loop.index}} | -{{r.creation}} | +{{r.creation}} | {{r.email}} |
{% else %}
- There are no pending join requests.
+ There are no pending join requests. + {% endif %} + {% set rejected_requests = subgroup.get_join_requests(status="Rejected") %} + +Rejected Requests+ {% if rejected_requests %} +
There are no rejected requests. {% endif %} {% endmacro %} @@ -116,6 +143,12 @@ $(function() { }); }); + $(".timestamp"). each(function() { + var t = moment($(this).text()); + var dt = t.from(moment.now()); + $(this).text(dt); + }); + $(".action-approve").click(function() { var name = $(this).parent().data("name"); var email = $(this).parent().data("email"); @@ -136,6 +169,14 @@ $(function() { }); }); + $(".action-undo").click(function() { + var name = $(this).parent().data("name"); + var email = $(this).parent().data("email"); + frappe.confirm(`Are you sure to undo the rejection of ${email}?`, function() { + run_action("school.lms.api.undo_reject_cohort_join_request", name); + }); + }); + function run_action(method, join_request) { frappe.call(method, { join_request: join_request, From 52fd8913702c53eee2e98d89a70b157f94834714 Mon Sep 17 00:00:00 2001 From: Anand ChitipothuMentors{% set mentors = subgroup.get_mentors() %} {% if mentors %} +
{% for m in mentors %}
-
{% else %}
None found.
{% endif %}
@@ -46,12 +45,11 @@
{% macro render_students() %}
{% set students = subgroup.get_students() %}
{% if students %}
+
- {{ widgets.Avatar(member=m, avatar_class="avatar-small") }}
- {{ m.full_name }}
-
+ {{ widgets.MemberCard(member=m, show_course_count=False, dimension_class="") }}
{% endfor %}
+
{% for student in students %}
-
{% else %}
None found.
{% endif %}
From a1d0f3948a001d6981ceccaeadcd4808e9141490 Mon Sep 17 00:00:00 2001
From: Anand Chitipothu
- {{ widgets.Avatar(member=student, avatar_class="avatar-small") }}
- {{ student.full_name }}
-
+ {{ widgets.MemberCard(member=student, show_course_count=False, dimension_class="") }}
{% endfor %}
+ You are a mentor of {{sg.title}} subgroup. - {% endif %} -All Subgroups+ + +
+{% if not page %}
+ {{ render_subgroups() }}
+{% else %}
+ {{ cohort.get_page_template(page) }}
+{% endif %}
+
+
+{% endblock %}
+
+{% macro render_subgroups() %}
{% if is_admin %}
- {{sg.title}}
+ {{sg.title}}
{% else %}
{{sg.title}}
{% endif %}
From 7001ddc96f85379e927dee2810cdef2811238ea8 Mon Sep 17 00:00:00 2001
From: Anand Chitipothu |