11# -*- coding: utf-8 -*-
2- import pytz
2+ import zoneinfo
33
44from django .urls import reverse
55from django .db import models
66from django .db .models .signals import pre_save , post_save
77from django .contrib .auth .models import User , Group
88from django_countries .fields import CountryField
9+ from django .core .validators import MinValueValidator , MaxValueValidator
910
1011from .fields import PGPKeyField
1112from main .utils import make_choice , set_created_field
@@ -22,7 +23,7 @@ class UserProfile(models.Model):
2223 help_text = "When enabled, send user 'flag out-of-date' notifications" )
2324 time_zone = models .CharField (
2425 max_length = 100 ,
25- choices = make_choice (pytz . common_timezones ),
26+ choices = make_choice (sorted ( zoneinfo . available_timezones ())), # sort as available_timezones output varies
2627 default = "UTC" ,
2728 help_text = "Used for developer clock page" )
2829 alias = models .CharField (
@@ -39,7 +40,8 @@ class UserProfile(models.Model):
3940 website = models .CharField (max_length = 200 , null = True , blank = True )
4041 website_rss = models .CharField (max_length = 200 , null = True , blank = True ,
4142 help_text = 'RSS Feed of your website for planet.archlinux.org' )
42- yob = models .IntegerField ("Year of birth" , null = True , blank = True )
43+ yob = models .IntegerField ("Year of birth" , null = True , blank = True ,
44+ validators = [MinValueValidator (1950 ), MaxValueValidator (2500 )])
4345 country = CountryField (blank = True )
4446 location = models .CharField (max_length = 50 , null = True , blank = True )
4547 languages = models .CharField (max_length = 50 , null = True , blank = True )
0 commit comments