Skip to content

Commit b6e514f

Browse files
committed
fix: skip biodata redirect for administrators
1 parent c46cd3b commit b6e514f

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

common/djangoapps/student/helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ def get_biodata_profile_redirect_url(user):
296296
if not getattr(user, 'username', None):
297297
return None
298298

299+
if getattr(user, 'is_staff', False) or getattr(user, 'is_superuser', False):
300+
return None
301+
299302
if _has_submitted_biodata_declaration(user):
300303
return None
301304

common/djangoapps/student/tests/test_helpers.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,23 @@ def test_keeps_login_redirect_when_biodata_declaration_is_complete(self, mock_ge
236236

237237
assert next_page == '/dashboard'
238238

239+
@skip_unless_lms
240+
@override_settings(PROFILE_MICROFRONTEND_URL='http://profile-mfe')
241+
@patch('common.djangoapps.student.helpers.apps.get_model')
242+
def test_keeps_login_redirect_for_administrator_when_biodata_declaration_is_missing(self, mock_get_model):
243+
"""
244+
Test administrators are not redirected to biodata even when their declaration is missing.
245+
"""
246+
user = SimpleNamespace(username='test-user', is_staff=True, is_superuser=False)
247+
248+
req = self.request.get(settings.LOGIN_URL)
249+
req.META["HTTP_ACCEPT"] = "text/html"
250+
251+
next_page = get_next_url_for_login_page(req, user=user)
252+
253+
mock_get_model.assert_not_called()
254+
assert next_page == '/dashboard'
255+
239256
@skip_unless_lms
240257
@override_settings(PROFILE_MICROFRONTEND_URL='http://profile-mfe')
241258
@patch('common.djangoapps.student.helpers.apps.get_model')

0 commit comments

Comments
 (0)