Show employee login only to self and portal admins.

Managers and HR keep contact PII but no longer see usernames.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-14 15:25:02 +03:00
parent bf5310e489
commit 598d26c52c
2 changed files with 7 additions and 1 deletions
+4
View File
@@ -124,18 +124,22 @@ class EmployeeDetailTests(TestCase):
self.assertIn('Личный телефон', html)
self.assertIn('Интеграции', html)
self.assertIn(self.employee.personal_phone, html)
self.assertIn(self.employee.username, html)
def test_manager_sees_subordinate_pii(self):
login_2fa(self.client, self.manager)
html = self.client.get(f'/employees/{self.employee.pk}/', HTTP_HX_REQUEST='true').content.decode()
self.assertIn('Личный телефон', html)
self.assertIn(self.employee.personal_phone, html)
# Логин — только себе и администратору портала, не руководителю.
self.assertNotIn(self.employee.username, html)
def test_self_sees_own_pii(self):
login_2fa(self.client, self.employee)
html = self.client.get(f'/employees/{self.employee.pk}/', HTTP_HX_REQUEST='true').content.decode()
self.assertIn('Личный телефон', html)
self.assertIn(self.employee.personal_phone, html)
self.assertIn(self.employee.username, html)
def test_stranger_does_not_see_pii(self):
login_2fa(self.client, self.stranger)
@@ -46,11 +46,13 @@
</div>
<div style="border-top:1px solid var(--color-border); padding-top:0.875rem; margin-bottom:1rem; font-size:0.8125rem;">
{% if can_view_pii or is_own_profile %}
{% if is_own_profile or can_edit %}
<div style="display:flex; justify-content:space-between; gap:0.5rem; margin-bottom:0.375rem;">
<span style="color:var(--color-muted-foreground);">{% trans "Логин" %}</span>
<span style="font-weight:500; text-align:right; word-break:break-all;">{{ employee.username }}</span>
</div>
{% endif %}
{% if can_view_pii or is_own_profile %}
{% if employee.email %}
<div style="display:flex; justify-content:space-between; gap:0.5rem; margin-bottom:0.375rem;">
<span style="color:var(--color-muted-foreground);">Email</span>