Skip to content

Commit

Permalink
Adiciona campo paid
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuspdf committed Apr 9, 2024
1 parent 27c3c35 commit 87a4d72
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eventex/subscriptions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

class SubscriptionModelAdmin(admin.ModelAdmin):
list_display = ('name', 'email', 'phone', 'cpf', 'created_at',
'subscribe_today')
'subscribe_today', 'paid')
date_hierarchy = 'created_at'
search_fields = ('name', 'email', 'phone', 'cpf', 'created_at')
list_filter = ('created_at',)
list_filter = ('paid', 'created_at')

def subscribe_today(self, obj):
return obj.created_at == now().date()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by Django 5.0.3 on 2024-04-09 21:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("subscriptions", "0001_initial"),
]

operations = [
migrations.AlterModelOptions(
name="subscription",
options={
"ordering": ("-created_at",),
"verbose_name": "inscrição",
"verbose_name_plural": "inscrições",
},
),
migrations.AddField(
model_name="subscription",
name="paid",
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name="subscription",
name="cpf",
field=models.CharField(max_length=11, verbose_name="CPF"),
),
migrations.AlterField(
model_name="subscription",
name="created_at",
field=models.DateTimeField(auto_now_add=True, verbose_name="criado em"),
),
migrations.AlterField(
model_name="subscription",
name="email",
field=models.EmailField(max_length=254, verbose_name="e-mail"),
),
migrations.AlterField(
model_name="subscription",
name="name",
field=models.CharField(max_length=100, verbose_name="nome"),
),
migrations.AlterField(
model_name="subscription",
name="phone",
field=models.CharField(max_length=20, verbose_name="telefone"),
),
]
18 changes: 18 additions & 0 deletions eventex/subscriptions/migrations/0003_alter_subscription_paid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.3 on 2024-04-09 21:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("subscriptions", "0002_alter_subscription_options_subscription_paid_and_more"),
]

operations = [
migrations.AlterField(
model_name="subscription",
name="paid",
field=models.BooleanField(default=False, verbose_name="pago"),
),
]
1 change: 1 addition & 0 deletions eventex/subscriptions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Subscription(models.Model):
email = models.EmailField('e-mail')
phone = models.CharField('telefone', max_length=20)
created_at = models.DateTimeField('criado em', auto_now_add=True)
paid = models.BooleanField('pago', default=False)

class Meta:
verbose_name_plural = 'inscrições'
Expand Down
4 changes: 4 additions & 0 deletions eventex/subscriptions/tests/test_model_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ def test_created_at(self):

def test_str(self):
self.assertEqual('Matheus Lopes', str(self.obj))

def test_paid_default_to_False(self):
"""By default paid must be False."""
self.assertEqual(False, self.obj.paid)

0 comments on commit 87a4d72

Please sign in to comment.