From 687f7f7f7b7716572d5277110794d1c374e659c2 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Thu, 27 May 2021 11:25:05 +0530 Subject: [PATCH 1/3] fix: minor home page issues --- community/lms/widgets/RenderBatch.html | 29 ++++++++++++++++++++++ community/www/batch/home.html | 27 +++----------------- community/www/courses/course.html | 34 ++------------------------ 3 files changed, 35 insertions(+), 55 deletions(-) create mode 100644 community/lms/widgets/RenderBatch.html diff --git a/community/lms/widgets/RenderBatch.html b/community/lms/widgets/RenderBatch.html new file mode 100644 index 00000000..60e77784 --- /dev/null +++ b/community/lms/widgets/RenderBatch.html @@ -0,0 +1,29 @@ +
+
+
Session every {{batch.sessions_on}}
+
{{frappe.utils.format_time(batch.start_time, "short")}} - + {{frappe.utils.format_time(batch.end_time, "short")}} +
+
Starting {{frappe.utils.format_date(batch.start_date, "medium")}}
+
mentors
+ + {% for m in batch.get_mentors() %} +
+ {{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }} + {{m.full_name}} +
+ {% endfor %} +
+ {% if can_manage or can_join %} +
+
+ {% if can_manage %} + Manage + {% elif can_join %} + + {% endif %} +
+
+ {% endif %} +
diff --git a/community/www/batch/home.html b/community/www/batch/home.html index 3b98e3fb..4198f691 100644 --- a/community/www/batch/home.html +++ b/community/www/batch/home.html @@ -14,33 +14,14 @@
{{ widgets.CourseOutline(course=course, batch=batch, show_link=True) }}
-
+

Batch Schedule

- {{ BatchDetails(batch) }} + {{ widgets.RenderBatch(batch=batch) }}
+ {% if batch.description %}

Batch Details

{{ frappe.utils.md_to_html(batch.description) }} - + {% endif %}
{% endblock %} - -{% macro BatchDetails(batch) %} -
-
-
Session every {{batch.sessions_on}}
-
{{frappe.utils.format_time(batch.start_time, "short")}} - - {{frappe.utils.format_time(batch.end_time, "short")}} -
-
Starting {{frappe.utils.format_date(batch.start_date, "medium")}}
-
mentors
- - {% for m in batch.get_mentors() %} -
- {{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }} - {{m.full_name}} -
- {% endfor %} -
-
-{% endmacro %} diff --git a/community/www/courses/course.html b/community/www/courses/course.html index 21c12831..ce8d3c90 100644 --- a/community/www/courses/course.html +++ b/community/www/courses/course.html @@ -64,36 +64,6 @@ {% endif %} {% endmacro %} -{% macro RenderBatch(batch, can_manage=False) %} -
-
-
Session every {{batch.sessions_on}}
-
{{frappe.utils.format_time(batch.start_time, "short")}} - - {{frappe.utils.format_time(batch.end_time, "short")}} -
-
Starting {{frappe.utils.format_date(batch.start_date, "medium")}}
-
mentors
- - {% for m in batch.get_mentors() %} -
- {{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }} - {{m.full_name}} -
- {% endfor %} -
-
-
- {% if can_manage %} - Manage - {% else %} - - {% endif %} -
-
-
-{% endmacro %} - {% macro BatchSectionForMentors(course, mentor_batches) %}

Your Batches

@@ -105,7 +75,7 @@
{% for batch in mentor_batches %}
- {{ RenderBatch(batch, can_manage=True) }} + {{ widgets.RenderBatch(batch=batch, can_manage=True) }}
{% endfor %}
@@ -127,7 +97,7 @@
{% for batch in upcoming_batches %}
- {{ RenderBatch(batch, can_manage=False) }} + {{ widgets.RenderBatch(batch=batch, can_join=True) }}
{% endfor %}
From a8752afb3b99ce284cbe945de15701a220862394 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Fri, 28 May 2021 13:53:34 +0530 Subject: [PATCH 2/3] feat: invite based membership become a member page --- community/hooks.py | 3 +- community/public/css/style.css | 27 +++++++ .../www/batch/become-a-member/index.html | 73 +++++++++++++++++++ community/www/batch/become-a-member/index.py | 8 ++ community/www/batch/home.html | 33 ++++++++- community/www/courses/course.html | 4 +- community/www/courses/learn/index.js | 3 - 7 files changed, 142 insertions(+), 9 deletions(-) create mode 100644 community/www/batch/become-a-member/index.html create mode 100644 community/www/batch/become-a-member/index.py delete mode 100644 community/www/courses/learn/index.js diff --git a/community/hooks.py b/community/hooks.py index 3ace5ad7..e507aefa 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -143,7 +143,8 @@ primary_rules = [ {"from_route": "/courses///members", "to_route": "batch/members"}, {"from_route": "/courses///discuss", "to_route": "batch/discuss"}, {"from_route": "/courses///about", "to_route": "batch/about"}, - {"from_route": "/courses///progress", "to_route": "batch/progress"} + {"from_route": "/courses///progress", "to_route": "batch/progress"}, + {"from_route": "/become-a-member/", "to_route": "batch/become-a-member"} ] # Any frappe default URL is blocked by profile-rules, add it here to unblock it diff --git a/community/public/css/style.css b/community/public/css/style.css index b97c3996..60eb4ed2 100644 --- a/community/public/css/style.css +++ b/community/public/css/style.css @@ -211,3 +211,30 @@ section { background: #eee; border: 2px solid #ddd; } + + +.page-card { + max-width: 360px; + padding: 15px; + margin: 70px auto; + border: 1px solid #d1d8dd; + border-radius: 4px; + background-color: #fff; + box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.1); +} +.page-card .page-card-head { + padding: 10px 15px; + margin: -15px; + margin-bottom: 15px; + border-bottom: 1px solid #d1d8dd; +} +.page-card .page-card-head .indicator { + color: #36414C; + font-size: 14px; +} +.page-card .page-card-head .indicator::before { + margin: 0 6px 0.5px 0px; +} +.page-card .btn { + margin-top: 30px; +} diff --git a/community/www/batch/become-a-member/index.html b/community/www/batch/become-a-member/index.html new file mode 100644 index 00000000..5f0f418d --- /dev/null +++ b/community/www/batch/become-a-member/index.html @@ -0,0 +1,73 @@ +% extends "templates/base.html" %} +{% block title %}Become a member{% endblock %} +{% block head_include %} + + +{% endblock %} + +{% block content %} +{% if frappe.session.user == "Guest" %} + +
+
+ Login Required +
+
Please log in to confirm your membership.
+ {{_("Login")}} +
+ +{% elif already_a_member %} + +
+
+ Already a member +
+
You are already a member of the batch {{ batch.title }}. +
+ {{_("Go to Batch Home")}} +
+ +{% else %} + +
+
+ Confirm your membership +
+
Please provide your confirmation to be a part of the batch {{ batch.title }} for the course + {{ batch.course_title }}. +
+ {{_("Confirm")}} +
+ +{% endif %} + + +{% endblock %} diff --git a/community/www/batch/become-a-member/index.py b/community/www/batch/become-a-member/index.py new file mode 100644 index 00000000..7a2e885c --- /dev/null +++ b/community/www/batch/become-a-member/index.py @@ -0,0 +1,8 @@ +import frappe + +def get_context(context): + context.no_cache = 1 + batch_name = frappe.form_dict["batch"] + context.batch = frappe.get_doc("LMS Batch", batch_name) + context.already_a_member = context.batch.is_member(frappe.session.user) + context.batch.course_title = frappe.db.get_value("LMS Course", context.batch.course, "title") diff --git a/community/www/batch/home.html b/community/www/batch/home.html index 4198f691..839df68c 100644 --- a/community/www/batch/home.html +++ b/community/www/batch/home.html @@ -8,20 +8,47 @@ {% endblock %} {% block content %} +{% set invite_link = frappe.utils.get_url() + "/become-a-member/" + batch.name %}
{{ widgets.BatchTabs(course=course, batch=batch) }} -

{{ batch.title }}

+
+

{{ batch.title }}

+
+ + +
+
{{ widgets.CourseOutline(course=course, batch=batch, show_link=True) }}

Batch Schedule

- {{ widgets.RenderBatch(batch=batch) }} + {{ widgets.RenderBatch(course=course, batch=batch) }}
{% if batch.description %}

Batch Details

{{ frappe.utils.md_to_html(batch.description) }} {% endif %} -
+ + {% endblock %} diff --git a/community/www/courses/course.html b/community/www/courses/course.html index ce8d3c90..0d4d7ccc 100644 --- a/community/www/courses/course.html +++ b/community/www/courses/course.html @@ -75,7 +75,7 @@
{% for batch in mentor_batches %}
- {{ widgets.RenderBatch(batch=batch, can_manage=True) }} + {{ widgets.RenderBatch(course=course, batch=batch, can_manage=True) }}
{% endfor %}
@@ -97,7 +97,7 @@
{% for batch in upcoming_batches %}
- {{ widgets.RenderBatch(batch=batch, can_join=True) }} + {{ widgets.RenderBatch(course=course, batch=batch, can_join=True) }}
{% endfor %}
diff --git a/community/www/courses/learn/index.js b/community/www/courses/learn/index.js deleted file mode 100644 index 0a6799eb..00000000 --- a/community/www/courses/learn/index.js +++ /dev/null @@ -1,3 +0,0 @@ -frappe.ready(() => { - -}) \ No newline at end of file From bb0aa09b4e80feb84fa203b251f97b0f391931dd Mon Sep 17 00:00:00 2001 From: pateljannat Date: Mon, 31 May 2021 13:39:31 +0530 Subject: [PATCH 3/3] fix: messages and url --- community/hooks.py | 2 +- community/www/batch/home.html | 22 ++++++++++++------- .../{become-a-member/index.html => join.html} | 11 +++++----- .../{become-a-member/index.py => join.py} | 0 4 files changed, 21 insertions(+), 14 deletions(-) rename community/www/batch/{become-a-member/index.html => join.html} (86%) rename community/www/batch/{become-a-member/index.py => join.py} (100%) diff --git a/community/hooks.py b/community/hooks.py index e507aefa..e6916c0b 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -144,7 +144,7 @@ primary_rules = [ {"from_route": "/courses///discuss", "to_route": "batch/discuss"}, {"from_route": "/courses///about", "to_route": "batch/about"}, {"from_route": "/courses///progress", "to_route": "batch/progress"}, - {"from_route": "/become-a-member/", "to_route": "batch/become-a-member"} + {"from_route": "/courses///join", "to_route": "batch/join"} ] # Any frappe default URL is blocked by profile-rules, add it here to unblock it diff --git a/community/www/batch/home.html b/community/www/batch/home.html index 839df68c..09743e50 100644 --- a/community/www/batch/home.html +++ b/community/www/batch/home.html @@ -1,23 +1,18 @@ {% extends "templates/base.html" %} -{% block title %}Batch{% endblock %} +{% block title %} Batch {% endblock %} + {% block head_include %} - {% endblock %} {% block content %} -{% set invite_link = frappe.utils.get_url() + "/become-a-member/" + batch.name %} +{% set invite_link = frappe.utils.get_url() + "/courses/" + course.name + "/" + batch.name + "/join" %}
{{ widgets.BatchTabs(course=course, batch=batch) }}

{{ batch.title }}

-
- - -
{{ widgets.CourseOutline(course=course, batch=batch, show_link=True) }} @@ -26,10 +21,21 @@

Batch Schedule

{{ widgets.RenderBatch(course=course, batch=batch) }}
+ {% if batch.description %}

Batch Details

{{ frappe.utils.md_to_html(batch.description) }} {% endif %} + + {% if course.is_mentor(frappe.session.user) %} +
+

Invite Members

+ Get Batch Invitation + Link + +
+ {% endif %} +