diff --git a/core/migrations/0035_auto_20200216_1743.py b/core/migrations/0035_auto_20200216_1743.py new file mode 100644 index 00000000..07545832 --- /dev/null +++ b/core/migrations/0035_auto_20200216_1743.py @@ -0,0 +1,24 @@ +# Generated by Django 2.2.10 on 2020-02-16 16:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0034_operationlog"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="sex", + field=models.CharField( + blank=True, + choices=[("MAN", "Man"), ("WOMAN", "Woman")], + max_length=10, + null=True, + verbose_name="sex", + ), + ), + ] diff --git a/core/models.py b/core/models.py index c51c9aab..afa24b9a 100644 --- a/core/models.py +++ b/core/models.py @@ -225,8 +225,9 @@ class User(AbstractBaseUser): sex = models.CharField( _("sex"), max_length=10, + null=True, + blank=True, choices=[("MAN", _("Man")), ("WOMAN", _("Woman"))], - default="MAN", ) tshirt_size = models.CharField( _("tshirt size"), diff --git a/matmat/templates/matmat/search_form.jinja b/matmat/templates/matmat/search_form.jinja index 34d1c1a3..9a2eb149 100644 --- a/matmat/templates/matmat/search_form.jinja +++ b/matmat/templates/matmat/search_form.jinja @@ -43,7 +43,6 @@ {{ form.phone.errors }} {{ form.phone }} - {{ form.sex.as_hidden() }}

@@ -53,7 +52,6 @@

{{ form.quick.errors }} - {{ form.sex.as_hidden() }} {{ form.quick }}

diff --git a/matmat/views.py b/matmat/views.py index 112c1d54..a2d8fff9 100644 --- a/matmat/views.py +++ b/matmat/views.py @@ -69,17 +69,6 @@ class SearchForm(forms.ModelForm): "phone": PhoneNumberInternationalFallbackWidget, } - sex = forms.ChoiceField( - choices=[ - ("MAN", _("Man")), - ("WOMAN", _("Woman")), - ("INDIFFERENT", _("Indifferent")), - ], - widget=forms.RadioSelect, - initial="INDIFFERENT", - label=_("Sex"), - ) - quick = forms.CharField(label=_("Last/First name or nickname"), max_length=255) def __init__(self, *args, **kwargs): @@ -150,7 +139,7 @@ class SearchFormListView(FormerSubscriberMixin, SingleObjectMixin, ListView): search_dict = {} for key, value in self.valid_form.items(): if key not in ("phone", "quick") and not ( - value == "" or value is None or value == "INDIFFERENT" + value == "" or value is None ): search_dict[key + "__icontains"] = value q = q.filter(**search_dict).all()