diff --git a/corehq/apps/users/views/__init__.py b/corehq/apps/users/views/__init__.py index 06e451937615..06e9de50ea0f 100644 --- a/corehq/apps/users/views/__init__.py +++ b/corehq/apps/users/views/__init__.py @@ -12,7 +12,7 @@ from corehq.apps.cloudcare.dbaccessors import get_cloudcare_apps, get_application_access_for_domain from corehq.apps.custom_data_fields.edit_entity import CustomDataEditor -from corehq.apps.custom_data_fields.models import CustomDataFieldsProfile, CustomDataFieldsDefinition +from corehq.apps.custom_data_fields.models import CustomDataFieldsProfile, CustomDataFieldsDefinition, PROFILE_SLUG from corehq.apps.registry.utils import get_data_registry_dropdown_options from corehq.apps.reports.models import TableauVisualization, TableauUser from corehq.apps.sso.models import IdentityProvider @@ -1204,10 +1204,17 @@ def request_id(self): @property def page_context(self): + initial_values = {} + if self.invitation: + initial_values = {f.slug: self.invitation.custom_user_data.get(f.slug) + for f in self.custom_data.fields} + if self.invitation.profile: + initial_values[PROFILE_SLUG] = self.invitation.profile.id ctx = { 'registration_form': self.invite_web_user_form, + 'user_data': initial_values, **self.custom_data.field_view.get_field_page_context( - self.domain, self.request.couch_user, self.custom_data, None, self.invitation + self.domain, self.request.couch_user, self.custom_data, None ) } return ctx diff --git a/corehq/apps/users/views/mobile/custom_data_fields.py b/corehq/apps/users/views/mobile/custom_data_fields.py index 395b57b441f0..e4a3a57bdc35 100644 --- a/corehq/apps/users/views/mobile/custom_data_fields.py +++ b/corehq/apps/users/views/mobile/custom_data_fields.py @@ -102,7 +102,7 @@ def get_displayable_profiles_and_edit_permission(cls, original_profile_id, domai @classmethod def get_field_page_context(cls, domain, couch_user, custom_data_editor: CustomDataEditor, - original_profile_id=None, invitation=None): + original_profile_id=None): profiles, can_edit_original_profile = ( cls.get_displayable_profiles_and_edit_permission( original_profile_id, domain, couch_user @@ -110,11 +110,6 @@ def get_field_page_context(cls, domain, couch_user, custom_data_editor: CustomDa ) serialized_profiles = [p.to_json() for p in profiles] - initial_values = {} - if invitation: - initial_values = {f.slug: invitation.custom_user_data.get(f.slug) for f in custom_data_editor.fields} - if invitation.profile: - initial_values[PROFILE_SLUG] = invitation.profile.id return { 'can_edit_original_profile': can_edit_original_profile, 'custom_fields_slugs': [f.slug for f in custom_data_editor.fields], @@ -123,7 +118,6 @@ def get_field_page_context(cls, domain, couch_user, custom_data_editor: CustomDa ], 'custom_fields_profiles': sorted(serialized_profiles, key=lambda x: x['name'].lower()), 'custom_fields_profile_slug': PROFILE_SLUG, - 'user_data': initial_values, } @classmethod