diff --git a/community/community/doctype/community_member/community_member.py b/community/community/doctype/community_member/community_member.py index dd7bed8b..0c1ecdb3 100644 --- a/community/community/doctype/community_member/community_member.py +++ b/community/community/doctype/community_member/community_member.py @@ -47,6 +47,9 @@ class CommunityMember(Document): 'member_type': 'Mentor' }) + def get_photo_url(self): + return frappe.db.get_value("User", self.email, ["user_image"]) + def get_palette(self): palette = [ ['--orange-avatar-bg', '--orange-avatar-color'], @@ -74,7 +77,7 @@ def create_member_from_user(doc, method): if ( doc.username and username_exists(doc.username)) or not doc.username: username = create_username_from_email(doc.email) - elif len(doc.username) < 4: + elif len(doc.username) < 4 and doc.send_welcome_email == 1: username = adjust_username(doc.username) if username_exists(username): diff --git a/community/community/widgets/Avatar.html b/community/community/widgets/Avatar.html index e0c88cf5..fac236df 100644 --- a/community/community/widgets/Avatar.html +++ b/community/community/widgets/Avatar.html @@ -1,8 +1,8 @@ {% set color = member.get_palette() %} - {% if member.photo %} - + {% if member.get_photo_url() %} + {% else %}
- Request Invite + Request + Invite
@@ -18,27 +19,44 @@ invite_email: invite_email }, callback: (data) => { - $("#invite-request-form").hide(); + if (data.message == "invalid email") { + $(".email-validation") && $(".email-validation").remove(); + if (invite_email) { + var message = `
+ ${invite_email} is not a valid email address. +
`; + } + else { + var message = `
+ Please enter an email address. +
`; + } - if (data.message == "OK") { - var message = `
+ $("#invite-request-form").append(message); + } + else { + $("#invite-request-form").hide(); + + if (data.message == "OK") { + var message = `

Thanks for your interest in Mon School. We have recorded your interest and we will get back to you shortly.

`; - } + } - else if (data.message == "invite") { - var message = `
+ else if (data.message == "invite") { + var message = `

Email ${invite_email} has already been used to request an invitation.

`; - } + } - else if (data.message == "user") { - var message = `
+ else if (data.message == "user") { + var message = `

Looks like there is already an account with email ${invite_email}. Would you like to login?

`; - } + } - $(".jumbotron").append(message); + $(".jumbotron").append(message); + } } }) }) diff --git a/community/www/courses/about/index.html b/community/www/courses/about/index.html index 1ea0ab1f..99eb138f 100644 --- a/community/www/courses/about/index.html +++ b/community/www/courses/about/index.html @@ -46,9 +46,7 @@ {% for m in batch.get_mentors() %}
- {% if m.photo_url %} - - {% endif %} + {{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }} {{m.full_name}}
{% endfor %} diff --git a/community/www/courses/course.html b/community/www/courses/course.html index ff51a3fc..7e118055 100644 --- a/community/www/courses/course.html +++ b/community/www/courses/course.html @@ -88,7 +88,8 @@ {% if can_manage %} Manage {% else %} - + {% endif %}
diff --git a/community/www/courses/course.js b/community/www/courses/course.js index 3ac859b8..ae77bdb0 100644 --- a/community/www/courses/course.js +++ b/community/www/courses/course.js @@ -17,7 +17,7 @@ frappe.ready(() => { $("#apply-now").click((e) => { e.preventDefault(); if (frappe.session.user == "Guest") { - window.location.href = "/login"; + window.location.href = `/login?redirect-to=/courses/${$(e.currentTarget).attr("data-course")}`; return; } frappe.call({ @@ -53,7 +53,7 @@ frappe.ready(() => { $(".join-batch").click((e) => { e.preventDefault() if (frappe.session.user == "Guest") { - window.location.href = "/login"; + window.location.href = `/login?redirect-to=/courses/${$(e.currentTarget).attr("data-course")}`; return; } batch = decodeURIComponent($(e.currentTarget).attr("data-batch")) @@ -70,4 +70,3 @@ frappe.ready(() => { }) }) }) -