diff --git a/lms/overrides/test_user.py b/lms/overrides/test_user.py index 5d1b9c030..2035f89d7 100644 --- a/lms/overrides/test_user.py +++ b/lms/overrides/test_user.py @@ -20,14 +20,6 @@ def test_without_username(self): user = new_user("Username", "test-without-username@example.com") self.assertTrue(user.username) - def test_with_illegal_characters(self): - user = new_user("Username$$", "test_with_illegal_characters@example.com") - self.assertEqual(user.username[:8], "username") - - def test_with_underscore_at_end(self): - user = new_user("Username___", "test_with_underscore_at_end@example.com") - self.assertNotEqual(user.username[-1], "_") - def test_with_short_first_name(self): user = new_user("USN", "test_with_short_first_name@example.com") self.assertGreaterEqual(len(user.username), 4) @@ -37,8 +29,6 @@ def tearDownClass(cls) -> None: users = [ "test_with_basic_username@example.com", "test-without-username@example.com", - "test_with_illegal_characters@example.com", - "test_with_underscore_at_end@example.com", "test_with_short_first_name@example.com", ] frappe.db.delete("User", {"name": ["in", users]}) diff --git a/lms/overrides/user.py b/lms/overrides/user.py index b92366b4b..b3d9c947c 100644 --- a/lms/overrides/user.py +++ b/lms/overrides/user.py @@ -9,64 +9,29 @@ from frappe.utils import cint, escape_html, random_string from frappe.website.utils import is_signup_disabled from lms.lms.utils import validate_image +from frappe.website.utils import cleanup_page_name +from frappe.model.naming import append_number_if_name_exists from lms.widgets import Widgets class CustomUser(User): def validate(self): super().validate() - self.validate_username_characters() + self.validate_username_duplicates() self.validate_completion() self.user_image = validate_image(self.user_image) self.cover_image = validate_image(self.cover_image) - def validate_username_characters(self): - if self.username and len(self.username): - other_conditions = ( - self.username[0] == "_" or self.username[-1] == "_" or "-" in self.username + def validate_username_duplicates(self): + while not self.username or self.username_exists(): + self.username = append_number_if_name_exists( + self.doctype, cleanup_page_name(self.full_name), fieldname="username" ) - else: - other_conditions = "" - - regex = re.compile(r"[@!#$%^&*()<>?/\|}{~:-]") - - if self.is_new(): - if not self.username: - self.username = self.get_username_from_first_name() - - if self.username.find(" "): - self.username.replace(" ", "") - - if len(self.username) < 4: - self.username = self.email.replace("@", "").replace(".", "") - - if regex.search(self.username) or other_conditions: - self.username = self.remove_illegal_characters() - - while self.username_exists(): - self.username = self.remove_illegal_characters() + str(random.randint(0, 99)) - - else: - if not self.username: - frappe.throw(_("Username already exists.")) - - if regex.search(self.username): - frappe.throw(_("Username can only contain alphabets, numbers and underscore.")) - - if other_conditions: - if "-" in self.username: - frappe.throw(_("Username cannot contain a Hyphen(-)")) - else: - frappe.throw(_("First and Last character of username cannot be Underscore(_).")) - - if len(self.username) < 4: - frappe.throw(_("Username cannot be less than 4 characters")) - - def get_username_from_first_name(self): - return frappe.scrub(self.first_name) + str(random.randint(0, 99)) + if " " in self.username: + self.username = self.username.replace(" ", "") - def remove_illegal_characters(self): - return re.sub(r"[^\w]+", "", self.username).strip("_") + if len(self.username) < 4: + self.username = self.email.replace("@", "").replace(".", "") def validate_skills(self): unique_skills = [] diff --git a/lms/page_renderers.py b/lms/page_renderers.py index 5a067d8a2..55ac47c9d 100644 --- a/lms/page_renderers.py +++ b/lms/page_renderers.py @@ -57,8 +57,8 @@ def __init__(self, path, http_status_code): self.renderer = None def can_render(self): - if "." in self.path: - return False + """if "." in self.path: + return False""" # has prefix and path starts with prefix? prefix = get_profile_url_prefix().lstrip("/") @@ -67,8 +67,8 @@ def can_render(self): # not a userpage? username = self.get_username() - if RE_INVALID_USERNAME.search(username): - return False + """ if RE_INVALID_USERNAME.search(username): + return False """ # if there is prefix then we can allow all usernames if prefix: return True diff --git a/lms/public/css/style.css b/lms/public/css/style.css index c8e35a677..5ac363db0 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -2,7 +2,6 @@ --text-3-5xl: 24px; --text-3-8xl: 34px; --text-4xl: 36px; - --checkbox-gradient: linear-gradient(180deg, #3d4142 -124.51%, var(--primary) 100%); } .nav-link .course-list-count { @@ -651,8 +650,12 @@ input[type=checkbox] { } .avatar-xl { - width: 112px; - height: 112px; + width: 8rem; + height: 8rem; +} + +.avatar-xl .standard-image { + border: 4px solid #ffffff; } @media (max-width: 500px) { @@ -791,9 +794,9 @@ input[type=checkbox] { } .profile-banner { - height: 248px; - background-size: cover; - background-position: center; + height: 248px; + background-size: cover; + background-position: center; } @media (max-width: 500px) { @@ -803,24 +806,24 @@ input[type=checkbox] { } .profile-info { - height: 90px; - background: #ffffff; - border-radius: 0px 0px 8px 8px; - font-size: var(--text-sm); - display: flex; - flex-direction: column; - margin-bottom: 2.5rem; - padding-left: 200px; - padding-right: 1rem; - box-shadow: var(--shadow-sm); + height: 90px; + background: #ffffff; + border-radius: 0px 0px 8px 8px; + font-size: var(--text-sm); + display: flex; + flex-direction: column; + margin-bottom: 2.5rem; + padding-left: 200px; + padding-right: 1rem; + border: 1px solid var(--gray-300); } @media (max-width: 550px) { - .profile-info { - align-items: flex-end; - padding-left: 0; - height: 150px; - } + .profile-info { + align-items: flex-end; + padding-left: 0; + height: 150px; + } } .profile-avatar { @@ -1524,10 +1527,6 @@ pre { margin: 0 1rem; } -.profile-page-body { - background-color: var(--gray-50); -} - .profile-column-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); @@ -1802,6 +1801,8 @@ li { } .role { + display: flex; + align-items: center; margin-bottom: 0; cursor: pointer; } diff --git a/lms/www/profiles/profile.html b/lms/www/profiles/profile.html index fbac97368..44a3f010c 100644 --- a/lms/www/profiles/profile.html +++ b/lms/www/profiles/profile.html @@ -68,7 +68,7 @@
-
+
{{ About(member) }} {{ EducationDetails(member) }} {{ WorkDetails(member) }} @@ -126,7 +126,7 @@
- {{ widgets.Avatar(member=member, avatar_class="avatar-square") }} + {{ widgets.Avatar(member=member, avatar_class="avatar-xl") }}
@@ -201,9 +201,9 @@ {% macro RoleSettings(member) %} {% if has_course_moderator_role() %}
-
+
{{ _("Role Settings") }}
-
+