Skip to content

Commit

Permalink
fix(vote): add updated and created fields and ordering suffle queryse…
Browse files Browse the repository at this point in the history
…t to candidature list
  • Loading branch information
igr-santos committed Sep 2, 2024
1 parent 171d7b7 commit 1cd5180
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/org_eleicoes/votepeloclima/candidature/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

class CandidatureAdmin(admin.ModelAdmin):
search_fields = ("legal_name", "ballot_name", "email", "political_party")
list_display = ("legal_name", "email", "political_party", "status")
list_display = ("legal_name", "email", "political_party", "status", "updated_at")
ordering = ("updated_at", )

def has_add_permission(self, request):
return False
Expand Down Expand Up @@ -51,7 +52,8 @@ class Meta:
class CandidatureFlowAdmin(admin.ModelAdmin):
form = CandidatureFlowAdminForm
list_filter = ("status", )
list_display = ("legal_name", "email", "political_party", "status")
list_display = ("legal_name", "email", "political_party", "status", "created_at", "updated_at")
ordering = ("updated_at", )

fieldsets = (
(None, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.2 on 2024-09-02 21:56

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('candidature', '0015_alter_candidature_appointments_and_more'),
]

operations = [
migrations.AlterModelOptions(
name='candidature',
options={'ordering': ['?'], 'verbose_name': 'Candidatura'},
),
migrations.AddField(
model_name='candidature',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='Criado em'),
preserve_default=False,
),
migrations.AddField(
model_name='candidature',
name='updated_at',
field=models.DateTimeField(auto_now=True, verbose_name='Atualizado em'),
),
migrations.AddField(
model_name='candidatureflow',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='Criado em'),
preserve_default=False,
),
migrations.AddField(
model_name='candidatureflow',
name='updated_at',
field=models.DateTimeField(auto_now=True, verbose_name='Atualizado em'),
),
]
9 changes: 9 additions & 0 deletions app/org_eleicoes/votepeloclima/candidature/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ class Candidature(models.Model):
# friendly url by ballot_name
slug = models.SlugField(max_length=100, unique=True, blank=True, null=True)

#
created_at = models.DateTimeField(verbose_name="Criado em", auto_now_add=True)
updated_at = models.DateTimeField(verbose_name="Atualizado em", auto_now=True)

class Meta:
verbose_name = "Candidatura"
ordering = ["-updated_at"]

@property
def status(self):
Expand Down Expand Up @@ -123,6 +128,10 @@ class CandidatureFlow(models.Model):
# - Habilitar usuário `is_active=True`
user = models.OneToOneField(User, null=True, on_delete=models.SET_NULL, verbose_name="Usuário")

#
created_at = models.DateTimeField(verbose_name="Criado em", auto_now_add=True)
updated_at = models.DateTimeField(verbose_name="Atualizado em", auto_now=True)

class Meta:
verbose_name = "Formulário"

Expand Down

0 comments on commit 1cd5180

Please sign in to comment.