From a8752afb3b99ce284cbe945de15701a220862394 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Fri, 28 May 2021 13:53:34 +0530 Subject: [PATCH] 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