diff --git a/borgia/static/static_dirs/COMPILED/less/_bootstrap-light.css b/borgia/static/static_dirs/COMPILED/less/_bootstrap-light.css index 651df87e..c282062b 100644 --- a/borgia/static/static_dirs/COMPILED/less/_bootstrap-light.css +++ b/borgia/static/static_dirs/COMPILED/less/_bootstrap-light.css @@ -255,7 +255,7 @@ th { @font-face { font-family: 'Glyphicons Halflings'; src: url('/static/fonts/glyphicons-halflings-regular.eot'); - src: url('/static/fonts/glyphicons-halflings-regular.eot#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); + src: url('/static/fonts/glyphicons-halflings-regular.eot#iefix') format('embedded-opentype'), url('../../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); } .glyphicon { position: relative; diff --git a/borgia/users/forms.py b/borgia/users/forms.py index 42ac8e34..2cbf3b01 100644 --- a/borgia/users/forms.py +++ b/borgia/users/forms.py @@ -1,10 +1,10 @@ +import datetime from django import forms from django.core.exceptions import ValidationError from django.forms.widgets import PasswordInput from users.models import User, get_list_year - class UserCreationCustomForm(forms.Form): first_name = forms.CharField(label='Prenom', max_length=255) last_name = forms.CharField(label='Nom', max_length=255) @@ -14,7 +14,7 @@ class UserCreationCustomForm(forms.Form): campus = forms.ChoiceField( label='Tabagn\'s', choices=User.CAMPUS_CHOICES, required=False) year = forms.ChoiceField( - label='Prom\'ss', choices=User.YEAR_CHOICES[::-1], required=True) + label='Prom\'ss', choices=tuple((year,year) for year in list(range(1953, datetime.datetime.now().year + 2))[::-1]), required=True) # +2 as last item is omitted username = forms.CharField(label='Username', max_length=255) is_external_member = forms.BooleanField( label='Externe à l\'association', required=False) @@ -42,7 +42,7 @@ class UserUpdateForm(forms.Form): campus = forms.ChoiceField( label='Tabagn\'s', choices=User.CAMPUS_CHOICES, required=False) year = forms.ChoiceField( - label='Prom\'ss', choices=User.YEAR_CHOICES, required=False) + label='Prom\'ss', choices=tuple((year,year) for year in list(range(1953, datetime.datetime.now().year + 2))[::-1]), required=False) # +2 as last item is omitted def __init__(self, **kwargs): self.user = kwargs.pop('user') diff --git a/borgia/users/migrations/0003_auto_20241110_1157.py b/borgia/users/migrations/0003_auto_20241110_1157.py new file mode 100644 index 00000000..bf4370ee --- /dev/null +++ b/borgia/users/migrations/0003_auto_20241110_1157.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.28 on 2024-11-10 11:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0002_auto_20230423_1543'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='year', + field=models.IntegerField(blank=True, choices=[(1953, 1953), (1954, 1954), (1955, 1955), (1956, 1956), (1957, 1957), (1958, 1958), (1959, 1959), (1960, 1960), (1961, 1961), (1962, 1962), (1963, 1963), (1964, 1964), (1965, 1965), (1966, 1966), (1967, 1967), (1968, 1968), (1969, 1969), (1970, 1970), (1971, 1971), (1972, 1972), (1973, 1973), (1974, 1974), (1975, 1975), (1976, 1976), (1977, 1977), (1978, 1978), (1979, 1979), (1980, 1980), (1981, 1981), (1982, 1982), (1983, 1983), (1984, 1984), (1985, 1985), (1986, 1986), (1987, 1987), (1988, 1988), (1989, 1989), (1990, 1990), (1991, 1991), (1992, 1992), (1993, 1993), (1994, 1994), (1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name="Prom'ss"), + ), + ] diff --git a/borgia/users/migrations/0004_auto_20241110_1247.py b/borgia/users/migrations/0004_auto_20241110_1247.py new file mode 100644 index 00000000..6fb55852 --- /dev/null +++ b/borgia/users/migrations/0004_auto_20241110_1247.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.28 on 2024-11-10 12:47 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0003_auto_20241110_1157'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='year', + field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1953)], verbose_name="Prom'ss"), + ), + ] diff --git a/borgia/users/models.py b/borgia/users/models.py index f315eff9..ffdc372a 100644 --- a/borgia/users/models.py +++ b/borgia/users/models.py @@ -1,9 +1,8 @@ -import datetime import decimal import itertools from django.contrib.auth.models import AbstractUser -from django.core.validators import RegexValidator +from django.core.validators import RegexValidator, MinValueValidator from django.db import models from django.utils import timezone @@ -63,9 +62,6 @@ class User(AbstractUser): ('KA', 'Ka'), ('KIN', 'Kin') ) - YEAR_CHOICES = [] - for i in range(1953, datetime.datetime.now().year + 1): - YEAR_CHOICES.append((i, i)) THEME_CHOICES = ( ('light', 'Light'), @@ -79,7 +75,7 @@ class User(AbstractUser): decimal_places=2) virtual_balance = models.DecimalField('Solde prévisionnel', default=0, max_digits=9, decimal_places=2) - year = models.IntegerField('Prom\'ss', choices=YEAR_CHOICES, blank=True, + year = models.IntegerField('Prom\'ss', validators=[MinValueValidator(1953)], blank=True, null=True) campus = models.CharField('Tabagn\'ss', choices=CAMPUS_CHOICES, max_length=3, blank=True, null=True)