From 10579af1967301ba1b83ee3ef13c0f2d369dacd7 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Mon, 23 Oct 2023 18:02:31 +0500 Subject: [PATCH] feat: add term and conditions field --- common/djangoapps/student/helpers.py | 2 +- .../0047_userprofile_terms_and_conditions.py | 18 ++++++++++++++++++ common/djangoapps/student/models/user.py | 1 + .../djangoapps/user_authn/views/register.py | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 common/djangoapps/student/migrations/0047_userprofile_terms_and_conditions.py diff --git a/common/djangoapps/student/helpers.py b/common/djangoapps/student/helpers.py index 298922520076..cfb047f1a947 100644 --- a/common/djangoapps/student/helpers.py +++ b/common/djangoapps/student/helpers.py @@ -742,7 +742,7 @@ def do_create_account(form, custom_form=None): profile_fields = [ "name", "level_of_education", "gender", "mailing_address", "city", "country", "goals", "year_of_birth", "national_id", "phone_number", "date_of_birth", "region", "address_line", - "english_language_level", "employment_status", "work_experience_level", "job_title", + "english_language_level", "employment_status", "work_experience_level", "job_title", "terms_and_conditions" ] profile = UserProfile( user=user, diff --git a/common/djangoapps/student/migrations/0047_userprofile_terms_and_conditions.py b/common/djangoapps/student/migrations/0047_userprofile_terms_and_conditions.py new file mode 100644 index 000000000000..b57074c545c1 --- /dev/null +++ b/common/djangoapps/student/migrations/0047_userprofile_terms_and_conditions.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.21 on 2023-10-23 06:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('student', '0046_alter_userprofile_english_language_level'), + ] + + operations = [ + migrations.AddField( + model_name='userprofile', + name='terms_and_conditions', + field=models.BooleanField(default=True), + ), + ] diff --git a/common/djangoapps/student/models/user.py b/common/djangoapps/student/models/user.py index c496c5a96a70..bee8d4ce16b1 100644 --- a/common/djangoapps/student/models/user.py +++ b/common/djangoapps/student/models/user.py @@ -594,6 +594,7 @@ class Meta: employment_status = models.CharField(blank=True, null=True, max_length=3, choices=EMPLOYMENT_STATUS_CHOICES) work_experience_level = models.CharField(blank=True, null=True, max_length=3, choices=WORK_EXPERIENCE_LEVEL_CHOICES) job_title = models.CharField(blank=True, null=True, max_length=63) + terms_and_conditions = models.BooleanField(default=True) @property diff --git a/openedx/core/djangoapps/user_authn/views/register.py b/openedx/core/djangoapps/user_authn/views/register.py index a7ca4a3ba21c..30e850ce57ce 100644 --- a/openedx/core/djangoapps/user_authn/views/register.py +++ b/openedx/core/djangoapps/user_authn/views/register.py @@ -178,6 +178,7 @@ def create_account_with_params(request, params): # pylint: disable=too-many-sta extra_fields["employment_status"] = "required" extra_fields["work_experience_level"] = "required" extra_fields["job_title"] = "required" + extra_fields["terms_and_conditions"] = "required" if is_registration_api_v1(request): if 'confirm_email' in extra_fields: @@ -590,6 +591,7 @@ def post(self, request): ) data = request.POST.copy() + data["terms_and_conditions"] = True if data.get("terms_and_conditions")=="true" else False self._handle_terms_of_service(data) try: