From 7c12d094c59d041505445666474c1623b2fcd251 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 3 Jan 2022 09:40:30 +0530 Subject: [PATCH 1/2] fix: logo dimensions --- school/overrides/user.py | 4 ++-- school/www/profiles/profile.html | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/school/overrides/user.py b/school/overrides/user.py index c4e0bb4a..5b452e06 100644 --- a/school/overrides/user.py +++ b/school/overrides/user.py @@ -71,8 +71,8 @@ class CustomUser(User): frappe.throw(_("Skills must be unique")) def validate_completion(self): - all_fields_have_value = True if frappe.db.get_single_value("LMS Settings", "force_profile_completion"): + all_fields_have_value = True profile_mandatory_fields = frappe.get_hooks("profile_mandatory_fields") docfields = frappe.get_meta(self.doctype).fields @@ -81,7 +81,7 @@ class CustomUser(User): all_fields_have_value = False break - self.profile_complete = all_fields_have_value + self.profile_complete = all_fields_have_value def get_authored_courses(self) -> int: """Returns the number of courses authored by this user. diff --git a/school/www/profiles/profile.html b/school/www/profiles/profile.html index 9124e2f5..2dc8c904 100644 --- a/school/www/profiles/profile.html +++ b/school/www/profiles/profile.html @@ -81,20 +81,20 @@
{% if enrollment %}
- - {{ enrollment }} {% if enrollment > 1 %} Courses {% else %} Course {% endif %} Taken + + {{ enrollment }} {% if enrollment > 1 %} Courses {% else %} Course {% endif %} Taken
{% endif %} {% if reviews %}
- - {{ reviews }} {% if reviews > 1 %} Courses {% else %} Course {% endif %} Reviewed + + {{ reviews }} {% if reviews > 1 %} Courses {% else %} Course {% endif %} Reviewed
{% endif %} {% if mentorship %}
- - {{ mentorship }} {% if mentorship > 1 %} Courses {% else %} Course {% endif %} Mentored + + {{ mentorship }} {% if mentorship > 1 %} Courses {% else %} Course {% endif %} Mentored
{% endif %}
@@ -238,6 +238,7 @@ {% endmacro %} {% macro Contact(member) %} +{% if not hide_primary_contact and member.email and member.mobile_no and member.linkedin and member.github and member.medium %}
{{ _("Contact") }}
@@ -269,6 +270,7 @@ {% endif %}
+{% endif %} {% endmacro %} {% macro Skills(member) %} From 730f1a6c47329a2986401c060fcb4118e7b69854 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 3 Jan 2022 09:55:34 +0530 Subject: [PATCH 2/2] fix: conditions to hide contacts section --- school/www/profiles/profile.html | 2 +- school/www/profiles/profile.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/school/www/profiles/profile.html b/school/www/profiles/profile.html index 2dc8c904..e7bbaeea 100644 --- a/school/www/profiles/profile.html +++ b/school/www/profiles/profile.html @@ -238,7 +238,7 @@ {% endmacro %} {% macro Contact(member) %} -{% if not hide_primary_contact and member.email and member.mobile_no and member.linkedin and member.github and member.medium %} +{% if show_contacts_section %}
{{ _("Contact") }}
diff --git a/school/www/profiles/profile.py b/school/www/profiles/profile.py index 60b74143..211d790f 100644 --- a/school/www/profiles/profile.py +++ b/school/www/profiles/profile.py @@ -18,8 +18,16 @@ def get_context(context): context.template = "www/404.html" return context.hide_primary_contact = frappe.db.get_single_value("LMS Settings", "hide_primary_contact") + context.show_contacts_section = show_contacts_section(context.member, context.hide_primary_contact) context.profile_tabs = get_profile_tabs(context.member) +def show_contacts_section(member, hide_primary_contact): + if member.github or member.linkedin or member.medium: + return True + if hide_primary_contact or member.hide_private: + return False + return True + def get_profile_tabs(user): """Returns the enabled ProfileTab objects.