fix: scope users API to end-users and tag new registrations as customers

- UserListView and UserMetricsView now filter is_superuser=False so only
  end-user accounts appear in the admin Users page (not admin/staff)
- _serialize_user now returns avatarUrl from profile_picture field so the
  grid view renders profile images instead of broken img tags
- RegisterForm and WebRegisterForm now set is_customer=True and
  role='customer' on save so future registrants are correctly classified
This commit is contained in:
2026-03-25 11:10:29 +05:30
parent 54315408eb
commit a3d1bbad30
2 changed files with 21 additions and 8 deletions

View File

@@ -31,6 +31,9 @@ class RegisterForm(forms.ModelForm):
# Set username equal to email to avoid separate username errors
user.username = self.cleaned_data['email']
user.set_password(self.cleaned_data['password'])
# Mark as a customer / end-user
user.is_customer = True
user.role = 'customer'
if commit:
user.save()
return user
@@ -70,9 +73,9 @@ class WebRegisterForm(forms.ModelForm):
# Set username equal to email to avoid separate username errors
user.username = self.cleaned_data['email']
user.set_password(self.cleaned_data['password'])
print('*' * 100)
print(user.username)
print('*' * 100)
# Mark as a customer / end-user
user.is_customer = True
user.role = 'customer'
if commit:
user.save()
return user