-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae4bc3b
commit eee8398
Showing
6 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[flake8] | ||
max-line-length = 270 | ||
exclude=.venv | ||
exclude=.venv | ||
ignore = F841 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 5.0.3 on 2024-06-06 22:32 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0002_alter_speaker_options_alter_speaker_description_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Contact", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"kind", | ||
models.CharField( | ||
choices=[("E", "Email"), ("P", "Phone")], max_length=1 | ||
), | ||
), | ||
("value", models.CharField(max_length=255)), | ||
( | ||
"speaker", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="core.speaker" | ||
), | ||
), | ||
], | ||
), | ||
] |
41 changes: 41 additions & 0 deletions
41
eventex/core/migrations/0004_alter_contact_options_alter_contact_kind_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 5.0.3 on 2024-06-06 23:15 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0003_contact"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="contact", | ||
options={"verbose_name": "contato", "verbose_name_plural": "contatos"}, | ||
), | ||
migrations.AlterField( | ||
model_name="contact", | ||
name="kind", | ||
field=models.CharField( | ||
choices=[("E", "Email"), ("P", "Phone")], | ||
max_length=1, | ||
verbose_name="tipo", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="contact", | ||
name="speaker", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="core.speaker", | ||
verbose_name="palestrante", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="contact", | ||
name="value", | ||
field=models.CharField(max_length=255, verbose_name="valor"), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from django.test import TestCase | ||
from eventex.core.models import Speaker, Contact | ||
from django.core.exceptions import ValidationError | ||
|
||
|
||
class ContactModelTest(TestCase): | ||
def setUp(self): | ||
self.speaker = Speaker.objects.create( | ||
name='Henrique Bastos', | ||
slug='henrique-bastos', | ||
photo='https://cdn.hashnode.com/res/hashnode/image/upload/v1679856878830/hVpMcHC' | ||
'Cz.jpeg?w=500&h=500&fit=crop&crop=faces&auto=compress,format&format=webp' | ||
) | ||
|
||
def test_email(self): | ||
contact = Contact.objects.create( | ||
speaker=self.speaker, | ||
kind=Contact.EMAIL, | ||
value='[email protected]' | ||
) | ||
|
||
self.assertTrue(Contact.objects.exists()) | ||
|
||
def test_phone(self): | ||
contact = Contact.objects.create( | ||
speaker=self.speaker, | ||
kind=Contact.PHONE, | ||
value='21-996186180' | ||
) | ||
|
||
self.assertTrue(Contact.objects.exists()) | ||
|
||
def test_choices(self): | ||
"""Contact kind should be limited to E or P""" | ||
contact = Contact(speaker=self.speaker, kind='A', value='B') | ||
self.assertRaises(ValidationError, contact.full_clean) | ||
|
||
def test_str(self): | ||
contact = Contact( | ||
speaker=self.speaker, | ||
kind=Contact.EMAIL, | ||
value='[email protected]' | ||
) | ||
self.assertEqual('[email protected]', str(contact)) |