Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General adjusts on search view #291

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/org_eleicoes/votepeloclima/candidature/forms/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# from django_select2.forms import Select2Widget

from ..layout import NoCrispyField
from ..choices import Gender, Color
from ..choices import Gender, Color, Sexuality
from ..fields import CepField, ButtonCheckboxSelectMultiple, ButtonRadioSelect
from ..locations_utils import get_ufs, get_choices
from ..models import Candidature
Expand Down Expand Up @@ -80,12 +80,15 @@ class FilterFormSidebar(RemoveRequiredMixin, forms.ModelForm):
label="Gênero", choices=Gender.choices[1:], widget=ButtonCheckboxSelectMultiple
)
color = forms.MultipleChoiceField(
label="Raça", choices=Color.choices[1:], widget=ButtonCheckboxSelectMultiple
label="Cor ou raça", choices=Color.choices[1:], widget=ButtonCheckboxSelectMultiple
)
sexuality = forms.MultipleChoiceField(
label="Sexualidade", choices=Sexuality.choices[1:], widget=ButtonCheckboxSelectMultiple
)

class Meta:
model = Candidature
fields = ["proposes", "mandate_type", "gender", "color"]
fields = ["proposes", "mandate_type", "gender", "color", "sexuality"]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -97,6 +100,7 @@ def __init__(self, *args, **kwargs):
NoCrispyField("mandate_type"),
NoCrispyField("gender"),
NoCrispyField("color"),
NoCrispyField("sexuality"),
)

def get_proposes_choices(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated by Django 4.2 on 2024-09-11 18:28

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('candidature', '0021_alter_candidature_political_party'),
]

operations = [
migrations.AlterField(
model_name='candidature',
name='ballot_name',
field=models.CharField(max_length=100, verbose_name='Nome na urna'),
),
migrations.AlterField(
model_name='candidature',
name='birth_date',
field=models.DateField(verbose_name='Data de nascimento'),
),
migrations.AlterField(
model_name='candidature',
name='color',
field=models.CharField(max_length=30, verbose_name='Cor ou raça'),
),
migrations.AlterField(
model_name='candidature',
name='deputy_mayor_political_party',
field=models.CharField(blank=True, max_length=60, null=True, verbose_name='Partido do vice-prefeito'),
),
migrations.AlterField(
model_name='candidature',
name='intended_position',
field=models.CharField(choices=[('', 'Selecione uma opção'), ('prefeitura', 'Prefeito/a'), ('vereacao', 'Vereador/a')], max_length=50, verbose_name='Cargo pretendido'),
),
migrations.AlterField(
model_name='candidature',
name='is_collective_mandate',
field=models.BooleanField(blank=True, default=False, verbose_name='Mandato coletivo'),
),
migrations.AlterField(
model_name='candidature',
name='number_id',
field=models.PositiveIntegerField(verbose_name='Número na urna'),
),
migrations.AlterField(
model_name='candidature',
name='political_party',
field=models.CharField(choices=[('', 'Selecione o partido'), ('agir', 'Agir'), ('avante', 'Avante'), ('cidadania', 'Cidadania'), ('dc', 'DC'), ('mdb', 'MDB'), ('mobiliza', 'Mobiliza'), ('novo', 'Novo'), ('patriota', 'Patriota'), ('pcb', 'PCB'), ('pcdob', 'PCdoB'), ('pco', 'PCO'), ('pdt', 'PDT'), ('pl', 'PL'), ('pmb', 'PMB'), ('pmn', 'PMN'), ('pode', 'PODE'), ('pp', 'PP'), ('prd', 'PRD'), ('pros', 'PROS'), ('prtb', 'PRTB'), ('psb', 'PSB'), ('psc', 'PSC'), ('psd', 'PSD'), ('psdb', 'PSDB'), ('psol', 'PSOL'), ('pstu', 'PSTU'), ('pt', 'PT'), ('ptb', 'PTB'), ('ptc', 'PTC'), ('pv', 'PV'), ('rede', 'Rede'), ('republicanos', 'Republicanos'), ('solidariedade', 'Solidariedade'), ('união', 'União'), ('up', 'UP')], max_length=60, verbose_name='Partido político'),
),
migrations.AlterField(
model_name='candidature',
name='sexuality',
field=models.CharField(blank=True, max_length=30, null=True, verbose_name='Sexualidade'),
),
migrations.AlterField(
model_name='candidature',
name='short_description',
field=models.TextField(verbose_name='Descrição curta'),
),
migrations.AlterField(
model_name='candidature',
name='social_media',
field=models.JSONField(blank=True, default=list, null=True, verbose_name='Redes sociais'),
),
]
26 changes: 15 additions & 11 deletions app/org_eleicoes/votepeloclima/candidature/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@

class Candidature(models.Model):
legal_name = models.CharField(max_length=150, verbose_name="Nome")
ballot_name = models.CharField(max_length=100, verbose_name="Nome na Urna")
birth_date = models.DateField(verbose_name="Data de Nascimento")
ballot_name = models.CharField(max_length=100, verbose_name="Nome na urna")
birth_date = models.DateField(verbose_name="Data de nascimento")
email = models.EmailField(verbose_name="E-mail")
cpf = models.CharField(max_length=30, verbose_name="CPF")
number_id = models.PositiveIntegerField(verbose_name="Número na Urna")
intended_position = models.CharField(max_length=50, choices=IntendedPosition.choices, verbose_name="Cargo Pretendido")
number_id = models.PositiveIntegerField(verbose_name="Número na urna")
intended_position = models.CharField(max_length=50, choices=IntendedPosition.choices, verbose_name="Cargo pretendido")
deputy_mayor = models.CharField(max_length=140, blank=True, null=True, verbose_name="Vice-prefeito")
deputy_mayor_political_party = models.CharField(max_length=60, blank=True, null=True, verbose_name="Partido do Vice-prefeito")
deputy_mayor_political_party = models.CharField(max_length=60, blank=True, null=True, verbose_name="Partido do vice-prefeito")
state = models.CharField(max_length=10, verbose_name="Estado")
city = models.CharField(max_length=60, verbose_name="Cidade")
is_collective_mandate = models.BooleanField(default=False, blank=True, verbose_name="Mandato Coletivo")
political_party = models.CharField(max_length=60, choices=PoliticalParty.choices, verbose_name="Partido Político")
is_collective_mandate = models.BooleanField(default=False, blank=True, verbose_name="Mandato coletivo")
political_party = models.CharField(max_length=60, choices=PoliticalParty.choices, verbose_name="Partido político")
video = models.FileField(upload_to="candidatures/videos/", null=True, blank=True, verbose_name="Vídeo")
photo = models.FileField(upload_to="candidatures/photos/", null=True, blank=True, verbose_name="Foto")
gender = models.CharField(max_length=30, verbose_name="Gênero")
color = models.CharField(max_length=30, verbose_name="Raça")
sexuality = models.CharField(max_length=30, null=True, blank=True, choices=Sexuality.choices, verbose_name="Sexualidade")
social_media = models.JSONField(blank=True, null=True, default=list, verbose_name="Redes Sociais")
color = models.CharField(max_length=30, verbose_name="Cor ou raça")
sexuality = models.CharField(max_length=30, null=True, blank=True, verbose_name="Sexualidade")
social_media = models.JSONField(blank=True, null=True, default=list, verbose_name="Redes sociais")
education = models.CharField(max_length=80, null=True, blank=True, choices=Education.choices, verbose_name="Educação")
employment = models.CharField(max_length=150, null=True, blank=True, verbose_name="Ocupação")
short_description = models.TextField(verbose_name="Descrição Curta")
short_description = models.TextField(verbose_name="Descrição curta")
milestones = models.JSONField(blank=True, null=True, default=list, verbose_name="Marcos")
proposes = models.JSONField(blank=True, verbose_name="Propostas")
appointments = models.JSONField(blank=True, verbose_name="Compromissos")
Expand Down Expand Up @@ -73,6 +73,10 @@ def get_color_display(self):
@property
def get_gender_display(self):
return dict(Gender.choices).get(self.gender)

@property
def get_sexuality_display(self):
return dict(Sexuality.choices).get(self.sexuality)

@property
def get_proposes_display(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3 class="text-uppercase pb-2">Informações</h3>
<div class="d-flex flex-wrap">
<div class="col pe-2">
<p><strong>Data de Nascimento:</strong> {{ candidature.birth_date }}</p>
<p><strong>Raça:</strong> {{ candidature.get_color_display }}</p>
<p><strong>Cor ou raça:</strong> {{ candidature.get_color_display }}</p>
<p><strong>Gênero:</strong> {{ candidature.get_gender_display }}</p>
</div>
<div class="col">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h6 class="text-uppercase fw-bold"><i class="ds-sidebar-bars"></i> Filtrar resul
<div class="card-body px-2 py-1">
<p class="state-city mb-1 text-black-50">{{ candidature.get_city_display }} - {{ candidature.get_state_display }}</p>
<div class="card-title">
<h5 class="fw-bold">{{ candidature.ballot_name|title }}</h5>
<h5 class="text-uppercase fw-bold">{{ candidature.ballot_name|title }}</h5>
</div>
<hr style="width: 24px;" class="my-2" />
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CandidatureSearchView(ListView):
"short_description",
]
unique_filter_fields = ["political_party", "state", "city", "intended_position"]
multiple_filter_fields = ["gender", "color", "proposes"]
multiple_filter_fields = ["gender", "color", "proposes", "sexuality"]

def get_queryset(self):
queryset = super().get_queryset()
Expand Down
Loading