fix: add new batch form enhancements (#43) invite request doctype and flow (#42)

This commit is contained in:
pateljannat
2021-05-01 14:37:57 +05:30
parent 4bc05bfda8
commit 52f16131af
17 changed files with 323 additions and 40 deletions

View File

@@ -111,11 +111,11 @@
{% endfor %}
</div>
<a class="btn btn-primary add-batch margin-bottom" href="/add-a-new-batch?new=1&course={{course.name}}">Add a new batch</a>
<a class="btn btn-primary add-batch margin-bottom" href="/add-a-new-batch?new=1&course={{course.title}}">Add a new batch</a>
{% else %}
<div class="mentor_message">
<p> You are a mentor for this course. </p>
<a class="btn btn-primary" href="/add-a-new-batch?new=1&course={{course.name}}" >Create your first batch</a>
<a class="btn btn-primary" href="/add-a-new-batch?new=1&course={{course.title}}" >Create your first batch</a>
</div>
{% endif %}
{% endmacro %}

View File

@@ -0,0 +1,65 @@
{% extends "templates/web.html" %}
{% block title %} {{_("New Sign Up")}} {% endblock %}
{% block page_content %}
<form id="reset-password">
<div class="form-group">
<input id="full_name" type="text" class="form-control" placeholder="{{ _('Full Name') }}" required>
</div>
<div class="form-group">
<input id="signup_email" type="email" class="form-control" placeholder="{{ _('Email') }}" required>
</div>
<div class="form-group">
<input id="username" type="text" class="form-control" placeholder="{{ _('Username') }}" required>
</div>
<div class="form-group">
<input id="password" type="password" class="form-control" placeholder="{{ _('Password') }}" required>
<span class="password-strength-indicator indicator"></span>
</div>
<p class='password-strength-message text-muted small hidden'></p>
<div class="form-group">
<input id="invite_code" type="text" class="form-control" placeholder="{{ _('Invite Code') }}" readonly required
value="{{ frappe.form_dict['invite_code'] }}">
</div>
<button type="submit" id="submit" class="btn btn-primary">{{_("Submit")}}</button>
</form>
<script>
frappe.ready(() => {
$("#submit").click(function () {
var data = {
full_name: $("#full_name").val(),
signup_email: $("#signup_email").val(),
username: $("#username").val(),
password: $("#password").val(),
invite_code: $("#invite_code").val(),
};
frappe.call({
type: "POST",
method: "community.lms.doctype.invite_request.invite_request.update_invite",
args: {
"data": data
},
callback: (data) => {
$("input").val("");
if (data.message == "OK") {
frappe.msgprint({
message: __("Your Account has been successfully created!"),
clear: true
});
setTimeout(function() {
window.location.href = "/login";
}, 2000);
}
}
});
return false;
});
})
</script>
{% endblock %}

View File

@@ -1,14 +1,16 @@
import frappe
from ...lms.doctype.lms_sketch.lms_sketch import get_recent_sketches
from community.lms.models import Sketch
def get_context(context):
context.no_cache = 1
context.username = frappe.form_dict["username"]
print(frappe.form_dict["username"])
context.member = get_member(context.username)
print(context.member)
if not context.member:
context.template = "www/404.html"
else:
context.sketches = list(filter(lambda x: x.owner == context.member.email, get_recent_sketches()))
context.sketches = list(filter(lambda x: x.owner == context.member.email, Sketch.get_recent_sketches()))
def get_member(username):
try: