From 2b66628c7846642ed57db38ba8faad8f2e1d648c Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sat, 9 Dec 2023 13:32:27 +0100 Subject: [PATCH] Remove gdpr field --- base/management/commands/load_db.py | 10 +++++----- personal/models.py | 8 +++----- personal/serializers.py | 8 +++----- user/serializers.py | 15 ++------------- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/base/management/commands/load_db.py b/base/management/commands/load_db.py index d832f08d..1a9a38b8 100644 --- a/base/management/commands/load_db.py +++ b/base/management/commands/load_db.py @@ -7,13 +7,14 @@ import pytz import unidecode from allauth.account.models import EmailAddress -from competition.models import (Competition, EventRegistration, Grade, Problem, - Semester, Series, Solution) -from competition.utils import get_school_year_by_date from django.core.management import BaseCommand from django.db.models import Q from django.forms.models import model_to_dict from django.utils.dateparse import parse_datetime + +from competition.models import (Competition, EventRegistration, Grade, Problem, + Semester, Series, Solution) +from competition.utils import get_school_year_by_date from personal.models import Profile, School from user.models import User @@ -244,8 +245,7 @@ def _load_users(self, conn, school_id_map): user['school_id'], School.objects.get_unspecified_value()), year_of_graduation=grade, phone=user['phone_number'] or '', - parent_phone=user['parent_phone_number'] or '', - gdpr=True + parent_phone=user['parent_phone_number'] or '' ) user_id_mapping[user['id']] = profile return user_id_mapping diff --git a/personal/models.py b/personal/models.py index f335ec8d..15488fd0 100644 --- a/personal/models.py +++ b/personal/models.py @@ -1,9 +1,10 @@ -from base.managers import UnspecifiedValueManager -from base.validators import phone_number_validator from django.apps import apps from django.conf import settings from django.db import models +from base.managers import UnspecifiedValueManager +from base.validators import phone_number_validator + class County(models.Model): class Meta: @@ -107,9 +108,6 @@ class Meta: validators=[phone_number_validator], help_text='Telefonné číslo v medzinárodnom formáte (napr. +421 123 456 789).') - gdpr = models.BooleanField( - verbose_name='súhlas so spracovaním osobných údajov', default=False) - @property def grade(self): return apps.get_model('competition', 'Grade').get_grade_by_year_of_graduation( diff --git a/personal/serializers.py b/personal/serializers.py index 6be0d6d2..e566f455 100644 --- a/personal/serializers.py +++ b/personal/serializers.py @@ -59,7 +59,7 @@ class ProfileSerializer(serializers.ModelSerializer): class Meta: model = Profile fields = ['grade_name', 'id', 'email', 'first_name', 'last_name', 'school', - 'phone', 'parent_phone', 'gdpr', 'grade', 'is_student', 'has_school', 'school_id'] + 'phone', 'parent_phone', 'grade', 'is_student', 'has_school', 'school_id'] read_only_fields = ['grade_name', 'id', 'first_name', 'last_name', 'email', 'is_student', 'has_school', 'school'] # 'year_of_graduation', @@ -102,8 +102,7 @@ def create(self, validated_data): school=validated_data['school'], year_of_graduation=grade.get_year_of_graduation_by_date(), phone=validated_data['phone'], - parent_phone=validated_data['parent_phone'], - gdpr=validated_data['gdpr'] + parent_phone=validated_data['parent_phone'] ) @@ -114,7 +113,7 @@ class ProfileCreateSerializer(serializers.ModelSerializer): class Meta: model = Profile fields = ['first_name', 'last_name', 'school', - 'phone', 'parent_phone', 'gdpr', 'grade'] + 'phone', 'parent_phone', 'grade'] read_only_fields = ['grade'] extra_kwargs = { 'grade': { @@ -143,7 +142,6 @@ def create(self, validated_data): year_of_graduation=grade.get_year_of_graduation_by_date(), phone=validated_data['phone'], parent_phone=validated_data['parent_phone'], - gdpr=validated_data['gdpr'] ) diff --git a/user/serializers.py b/user/serializers.py index a6f9d5be..f6f65fb7 100644 --- a/user/serializers.py +++ b/user/serializers.py @@ -116,8 +116,6 @@ def update(self, instance, validated_data): 'last_name', instance.profile.last_name) instance.profile.parent_phone = profile_data.get( 'parent_phone', instance.profile.parent_phone) - instance.profile.gdpr = profile_data.get( - 'gdpr', instance.profile.gdpr) instance.profile.school = profile_data.get( 'school', instance.profile.school) instance.profile.year_of_graduation = profile_data.get( @@ -183,15 +181,6 @@ def validate_email(self, email): def validate_password1(self, password): return get_adapter().clean_password(password) - def validate_profile(self, profile): - ''' - check ci je gdpr zaskrtnute - ''' - if not profile['gdpr']: - raise serializers.ValidationError( - 'Musíš podvrdiť, že si si vedomý spracovania osobných údajov.') - return profile - def validate(self, attrs): if attrs['password1'] != attrs['password2']: raise serializers.ValidationError("Zadané heslá sa nezhodujú.") @@ -224,8 +213,8 @@ def save(self, request): school=profile_data['school'], year_of_graduation=grade.get_year_of_graduation_by_date(), phone=profile_data['phone'], - parent_phone=profile_data['parent_phone'], - gdpr=profile_data['gdpr']) + parent_phone=profile_data['parent_phone'] + ) self.handle_other_school(profile_data['school']) setup_user_email(request, user, [])