diff --git a/base/management/commands/load_db.py b/base/management/commands/load_db.py index 0fe99e1b..d832f08d 100644 --- a/base/management/commands/load_db.py +++ b/base/management/commands/load_db.py @@ -240,7 +240,6 @@ def _load_users(self, conn, school_id_map): first_name=user['first_name'], last_name=user['last_name'], user=new_user, - nickname=user['username'], school=school_id_map.get( user['school_id'], School.objects.get_unspecified_value()), year_of_graduation=grade, diff --git a/competition/fixtures/sources/generate_users_problems.py b/competition/fixtures/sources/generate_users_problems.py index a4da0d96..fca4b4a1 100644 --- a/competition/fixtures/sources/generate_users_problems.py +++ b/competition/fixtures/sources/generate_users_problems.py @@ -39,7 +39,6 @@ def generate_profile(pk, user, year, school): "user": user, "first_name": "Ucastnik ", "last_name": f'Priezvisko{user}', - "nickname": f'Prezyvka{user}', "school": "000160997", "year_of_graduation": year, "phone": "+421912345678", diff --git a/personal/fixtures/profiles.json b/personal/fixtures/profiles.json index f867d696..1f0ba023 100644 --- a/personal/fixtures/profiles.json +++ b/personal/fixtures/profiles.json @@ -6,7 +6,6 @@ "user": 20, "first_name": "\ud83e\udd89", "last_name": "\ud83e\udd89", - "nickname": "\ud83e\udd89", "school": 0, "year_of_graduation": 8389, "phone": "\ud83e\udd89", @@ -33,7 +32,6 @@ "user": 42, "first_name": "Mat", "last_name": "Krajin\u00e1rsky \u2013 Architekt", - "nickname": "", "school": 598071, "year_of_graduation": 42, "phone": "00420420420420" @@ -46,7 +44,6 @@ "user": 17, "first_name": "\ud83d\ude65\ud83d\udd4f\ud83d\udd45\ud83d\udd79\ud83d\udda8\ud83d\uddf0\ud83d\udde2\ud83d\udddd\ud83d\udddc\ud83d\uddce\ud83d\uddd1\ud83d\udde1\ud83d\uddff\ud83d\uddfa\ud83e\udd49\ud83e\udd36\ud83e\udd00\ud83e\udd68\ud83e\uddc1\ud83d\ude67", "last_name": "\ud83d\ude6c\ud83e\udeb5\ud83e\ude78\ud83e\uded5\ud83e\uded3\ud83e\ude90\ud83e\ude80\ud83e\ude86\ud83e\udea6\ud83e\udec0\ud83e\udec2\ud83d\ude6e", - "nickname": "\ud83d\ude75////////\ud83d\ude75\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude7f\ud83d\ude75", "school": 36080501, "year_of_graduation": 0, "phone": "\ud83d\ude3d" diff --git a/personal/fixtures/profiles_more.json b/personal/fixtures/profiles_more.json index 67ce86b1..15e92026 100644 --- a/personal/fixtures/profiles_more.json +++ b/personal/fixtures/profiles_more.json @@ -6,7 +6,6 @@ "user": 48, "first_name": "Ucastnik", "last_name": "Priezvisko48", - "nickname": "Prezyvka48", "school": "000160997", "year_of_graduation": 2022, "phone": "+421912345678", @@ -20,7 +19,6 @@ "user": 49, "first_name": "Ucastnik", "last_name": "Priezvisko49", - "nickname": "Prezyvka49", "school": "000160997", "year_of_graduation": 2025, "phone": "+421912345678", @@ -34,7 +32,6 @@ "user": 50, "first_name": "Ucastnik", "last_name": "Priezvisko50", - "nickname": "Prezyvka50", "school": "000160997", "year_of_graduation": 2028, "phone": "+421912345678", @@ -48,7 +45,6 @@ "user": 51, "first_name": "Ucastnik", "last_name": "Priezvisko51", - "nickname": "Prezyvka51", "school": "000160997", "year_of_graduation": 2025, "phone": "+421912345678", @@ -62,7 +58,6 @@ "user": 52, "first_name": "Ucastnik", "last_name": "Priezvisko52", - "nickname": "Prezyvka52", "school": "000160997", "year_of_graduation": 2024, "phone": "+421912345678", @@ -76,7 +71,6 @@ "user": 53, "first_name": "Ucastnik", "last_name": "Priezvisko53", - "nickname": "Prezyvka53", "school": "000160997", "year_of_graduation": 2025, "phone": "+421912345678", @@ -90,7 +84,6 @@ "user": 54, "first_name": "Ucastnik", "last_name": "Priezvisko54", - "nickname": "Prezyvka54", "school": "000160997", "year_of_graduation": 2027, "phone": "+421912345678", @@ -104,7 +97,6 @@ "user": 55, "first_name": "Ucastnik", "last_name": "Priezvisko55", - "nickname": "Prezyvka55", "school": "000160997", "year_of_graduation": 2022, "phone": "+421912345678", @@ -118,7 +110,6 @@ "user": 56, "first_name": "Ucastnik", "last_name": "Priezvisko56", - "nickname": "Prezyvka56", "school": "000160997", "year_of_graduation": 2021, "phone": "+421912345678", @@ -132,7 +123,6 @@ "user": 57, "first_name": "Ucastnik", "last_name": "Priezvisko57", - "nickname": "Prezyvka57", "school": "000160997", "year_of_graduation": 2029, "phone": "+421912345678", @@ -146,7 +136,6 @@ "user": 58, "first_name": "Ucastnik", "last_name": "Priezvisko58", - "nickname": "Prezyvka58", "school": "000160997", "year_of_graduation": 2022, "phone": "+421912345678", @@ -160,7 +149,6 @@ "user": 59, "first_name": "Ucastnik", "last_name": "Priezvisko59", - "nickname": "Prezyvka59", "school": "000160997", "year_of_graduation": 2021, "phone": "+421912345678", @@ -174,7 +162,6 @@ "user": 60, "first_name": "Ucastnik", "last_name": "Priezvisko60", - "nickname": "Prezyvka60", "school": "000160997", "year_of_graduation": 2024, "phone": "+421912345678", @@ -188,7 +175,6 @@ "user": 61, "first_name": "Ucastnik", "last_name": "Priezvisko61", - "nickname": "Prezyvka61", "school": "000160997", "year_of_graduation": 2020, "phone": "+421912345678", @@ -202,7 +188,6 @@ "user": 62, "first_name": "Ucastnik", "last_name": "Priezvisko62", - "nickname": "Prezyvka62", "school": "000160997", "year_of_graduation": 2024, "phone": "+421912345678", @@ -216,7 +201,6 @@ "user": 63, "first_name": "Ucastnik", "last_name": "Priezvisko63", - "nickname": "Prezyvka63", "school": "000160997", "year_of_graduation": 2026, "phone": "+421912345678", @@ -230,7 +214,6 @@ "user": 64, "first_name": "Ucastnik", "last_name": "Priezvisko64", - "nickname": "Prezyvka64", "school": "000160997", "year_of_graduation": 2029, "phone": "+421912345678", @@ -244,7 +227,6 @@ "user": 65, "first_name": "Ucastnik", "last_name": "Priezvisko65", - "nickname": "Prezyvka65", "school": "000160997", "year_of_graduation": 2028, "phone": "+421912345678", @@ -258,7 +240,6 @@ "user": 66, "first_name": "Ucastnik", "last_name": "Priezvisko66", - "nickname": "Prezyvka66", "school": "000160997", "year_of_graduation": 2025, "phone": "+421912345678", @@ -272,7 +253,6 @@ "user": 67, "first_name": "Ucastnik", "last_name": "Priezvisko67", - "nickname": "Prezyvka67", "school": "000160997", "year_of_graduation": 2025, "phone": "+421912345678", @@ -286,7 +266,6 @@ "user": 68, "first_name": "Ucastnik", "last_name": "Priezvisko68", - "nickname": "Prezyvka68", "school": "000160997", "year_of_graduation": 2023, "phone": "+421912345678", @@ -300,7 +279,6 @@ "user": 69, "first_name": "Ucastnik", "last_name": "Priezvisko69", - "nickname": "Prezyvka69", "school": "000160997", "year_of_graduation": 2024, "phone": "+421912345678", @@ -314,7 +292,6 @@ "user": 70, "first_name": "Ucastnik", "last_name": "Priezvisko70", - "nickname": "Prezyvka70", "school": "000160997", "year_of_graduation": 2028, "phone": "+421912345678", @@ -328,7 +305,6 @@ "user": 71, "first_name": "Ucastnik", "last_name": "Priezvisko71", - "nickname": "Prezyvka71", "school": "000160997", "year_of_graduation": 2025, "phone": "+421912345678", @@ -342,7 +318,6 @@ "user": 72, "first_name": "Ucastnik", "last_name": "Priezvisko72", - "nickname": "Prezyvka72", "school": "000160997", "year_of_graduation": 2025, "phone": "+421912345678", @@ -356,7 +331,6 @@ "user": 73, "first_name": "Ucastnik", "last_name": "Priezvisko73", - "nickname": "Prezyvka73", "school": "000160997", "year_of_graduation": 2020, "phone": "+421912345678", @@ -370,7 +344,6 @@ "user": 74, "first_name": "Ucastnik", "last_name": "Priezvisko74", - "nickname": "Prezyvka74", "school": "000160997", "year_of_graduation": 2024, "phone": "+421912345678", @@ -384,7 +357,6 @@ "user": 75, "first_name": "Ucastnik", "last_name": "Priezvisko75", - "nickname": "Prezyvka75", "school": "000160997", "year_of_graduation": 2023, "phone": "+421912345678", @@ -398,7 +370,6 @@ "user": 76, "first_name": "Ucastnik", "last_name": "Priezvisko76", - "nickname": "Prezyvka76", "school": "000160997", "year_of_graduation": 2022, "phone": "+421912345678", @@ -412,7 +383,6 @@ "user": 77, "first_name": "Ucastnik", "last_name": "Priezvisko77", - "nickname": "Prezyvka77", "school": "000160997", "year_of_graduation": 2029, "phone": "+421912345678", diff --git a/personal/models.py b/personal/models.py index 2216d6cd..f335ec8d 100644 --- a/personal/models.py +++ b/personal/models.py @@ -90,9 +90,6 @@ class Meta: related_name='profile' ) - nickname = models.CharField( - verbose_name='prezývka', max_length=32, blank=True, ) - school = models.ForeignKey( School, on_delete=models.SET(School.objects.get_unspecified_value), verbose_name='škola') diff --git a/personal/serializers.py b/personal/serializers.py index f0c7b0fd..6be0d6d2 100644 --- a/personal/serializers.py +++ b/personal/serializers.py @@ -58,7 +58,7 @@ class ProfileSerializer(serializers.ModelSerializer): class Meta: model = Profile - fields = ['grade_name', 'id', 'email', 'first_name', 'last_name', 'nickname', 'school', + fields = ['grade_name', 'id', 'email', 'first_name', 'last_name', 'school', 'phone', 'parent_phone', 'gdpr', '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', @@ -99,7 +99,6 @@ def create(self, validated_data): return Profile.objects.create( first_name=validated_data['first_name'], last_name=validated_data['last_name'], - nickname=validated_data['nickname'], school=validated_data['school'], year_of_graduation=grade.get_year_of_graduation_by_date(), phone=validated_data['phone'], @@ -114,7 +113,7 @@ class ProfileCreateSerializer(serializers.ModelSerializer): class Meta: model = Profile - fields = ['first_name', 'last_name', 'nickname', 'school', + fields = ['first_name', 'last_name', 'school', 'phone', 'parent_phone', 'gdpr', 'grade'] read_only_fields = ['grade'] extra_kwargs = { @@ -140,7 +139,6 @@ def create(self, validated_data): return Profile.objects.create( first_name=validated_data['first_name'], last_name=validated_data['last_name'], - nickname=validated_data['nickname'], school=validated_data['school'], year_of_graduation=grade.get_year_of_graduation_by_date(), phone=validated_data['phone'], @@ -153,7 +151,7 @@ def create(self, validated_data): class ProfileShortSerializer(serializers.ModelSerializer): class Meta: model = Profile - fields = ['first_name', 'last_name', 'nickname'] + fields = ['first_name', 'last_name'] @ts_interface(context='personal') @@ -170,4 +168,4 @@ class Meta: model = Profile fields = ['school_name', 'school_abbreviation', 'school_street', 'school_city', 'school_zip_code', - 'first_name', 'last_name', 'nickname', 'email'] + 'first_name', 'last_name', 'email'] diff --git a/personal/views.py b/personal/views.py index bcc96d78..cf030313 100644 --- a/personal/views.py +++ b/personal/views.py @@ -42,7 +42,7 @@ class ProfileViewSet(viewsets.ModelViewSet): filterset_fields = ['school', 'year_of_graduation', ] permission_classes = [IsAdminUser] filter_backends = [DjangoFilterBackend, SearchFilter] - search_fields = ['first_name', 'last_name', 'nickname'] + search_fields = ['first_name', 'last_name'] # pylint: disable=inconsistent-return-statements @action(methods=['get', 'put'], detail=False, permission_classes=[IsAuthenticated]) diff --git a/user/serializers.py b/user/serializers.py index f58169bf..665281da 100644 --- a/user/serializers.py +++ b/user/serializers.py @@ -105,8 +105,6 @@ def update(self, instance, validated_data): # Update Profile # Nie všetky polia v modeloch User a Profile sú editovateľné cez API. - instance.profile.nickname = profile_data.get( - 'nickname', instance.profile.nickname) instance.profile.phone = profile_data.get( 'phone', instance.profile.phone) instance.profile.parent_phone = profile_data.get( @@ -186,7 +184,6 @@ def save(self, request): Profile.objects.create(user=user, first_name=profile_data['first_name'], last_name=profile_data['last_name'], - nickname=profile_data['nickname'], school=profile_data['school'], year_of_graduation=grade.get_year_of_graduation_by_date(), phone=profile_data['phone'],