-
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
aa68cec
commit addc504
Showing
15 changed files
with
248 additions
and
11 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
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,31 @@ | ||
# Generated by Django 5.0.3 on 2024-06-13 22:18 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0004_alter_contact_options_alter_contact_kind_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Talk", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("title", models.CharField(max_length=200)), | ||
("start", models.TimeField()), | ||
("description", models.TextField()), | ||
("speakers", models.ManyToManyField(to="core.speaker")), | ||
], | ||
), | ||
] |
39 changes: 39 additions & 0 deletions
39
eventex/core/migrations/0006_alter_talk_options_alter_talk_description_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,39 @@ | ||
# Generated by Django 5.0.3 on 2024-06-13 22:37 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0005_talk"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="talk", | ||
options={"verbose_name": "palestra", "verbose_name_plural": "palestras"}, | ||
), | ||
migrations.AlterField( | ||
model_name="talk", | ||
name="description", | ||
field=models.TextField(blank=True, verbose_name="descrição"), | ||
), | ||
migrations.AlterField( | ||
model_name="talk", | ||
name="speakers", | ||
field=models.ManyToManyField( | ||
blank=True, to="core.speaker", verbose_name="palestrantes" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="talk", | ||
name="start", | ||
field=models.TimeField(blank=True, null=True, verbose_name="início"), | ||
), | ||
migrations.AlterField( | ||
model_name="talk", | ||
name="title", | ||
field=models.CharField(max_length=200, verbose_name="Título"), | ||
), | ||
] |
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
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,21 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<section> | ||
<div class="talks content row padding-bottom-3 desktop-12 container"> | ||
<h2>Manhã</h2> | ||
{% for talk in morning_talks %} | ||
{% include 'core/talk_list_snippet.html' with talk=talk only %} | ||
{% empty %} | ||
<p>Ainda não existem palestras de manhã.</p> | ||
{% endfor %} | ||
|
||
<h2>Tarde</h2> | ||
{% for talk in afternoon_talks %} | ||
{% include 'core/talk_list_snippet.html' with talk=talk only %} | ||
{% empty %} | ||
<p>Ainda não existem palestras de tarde.</p> | ||
{% endfor %} | ||
</div> | ||
</section> | ||
{% endblock content %} |
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,7 @@ | ||
<h3>{{ talk.start }} - {{ talk.title}}</h3> | ||
<h4>Por | ||
{% for speaker in talk.speakers.all %} | ||
<a href="{{ speaker.get_absolute_url }}">{{ speaker.name }}</a> | ||
{% endfor %} | ||
</h4> | ||
<p>{{ talk.description }}</p> |
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,40 @@ | ||
from django.test import TestCase | ||
from eventex.core.models import Talk | ||
|
||
|
||
class TalkModelTest(TestCase): | ||
def setUp(self): | ||
self.talk = Talk.objects.create( | ||
title='Título da Palestra' | ||
) | ||
|
||
def test_create(self): | ||
self.assertTrue(Talk.objects.exists()) | ||
|
||
def test_has_speakers(self): | ||
"""Talk has many Speakers and vice-versa""" | ||
self.talk.speakers.create( | ||
name='Henrique Bastos', | ||
slug='henrique-bastos', | ||
website='http://henriquebastos.net' | ||
) | ||
self.assertEqual(1, self.talk.speakers.count()) | ||
|
||
def test_description_blank(self): | ||
field = Talk._meta.get_field('description') | ||
self.assertTrue(field.blank) | ||
|
||
def test_speakers_blank(self): | ||
field = Talk._meta.get_field('speakers') | ||
self.assertTrue(field.blank) | ||
|
||
def test_start_blank(self): | ||
field = Talk._meta.get_field('start') | ||
self.assertTrue(field.blank) | ||
|
||
def test_start_null(self): | ||
field = Talk._meta.get_field('start') | ||
self.assertTrue(field.null) | ||
|
||
def test_str(self): | ||
self.assertEqual('Título da Palestra', str(self.talk)) |
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,59 @@ | ||
from django.test import TestCase | ||
from django.shortcuts import resolve_url as r | ||
|
||
from eventex.core.models import Talk, Speaker | ||
|
||
|
||
class TalkListGet(TestCase): | ||
def setUp(self): | ||
t1 = Talk.objects.create(title='Título da Palestra', start='10:00', description='Descrição da palestra') | ||
t2 = Talk.objects.create(title='Título da Palestra', start='13:00', description='Descrição da palestra') | ||
|
||
speaker = Speaker.objects.create( | ||
name='Henrique Bastos', | ||
slug='henrique-bastos', | ||
website='http://henriquebastos.net' | ||
) | ||
|
||
t1.speakers.add(speaker) | ||
t2.speakers.add(speaker) | ||
|
||
self.resp = self.client.get(r('talk_list')) | ||
|
||
def test_get(self): | ||
self.assertEqual(200, self.resp.status_code) | ||
|
||
def test_template(self): | ||
self.assertTemplateUsed(self.resp, 'core/talk_list.html') | ||
|
||
def test_html(self): | ||
contents = [ | ||
(2, 'Título da Palestra'), | ||
(1, '10:00'), | ||
(1, '13:00'), | ||
(2, '/palestrantes/henrique-bastos/'), | ||
(2, 'Henrique Bastos'), | ||
(2, 'Descrição da palestra'), | ||
] | ||
|
||
for count, expected in contents: | ||
with self.subTest(): | ||
self.assertContains(self.resp, expected, count) | ||
|
||
def test_context(self): | ||
variables = [ | ||
'morning_talks', | ||
'afternoon_talks' | ||
] | ||
|
||
for key in variables: | ||
with self.subTest(): | ||
self.assertIn(key, self.resp.context) | ||
|
||
|
||
class TalkListGetEmpty(TestCase): | ||
def test_get_empty(self): | ||
response = self.client.get(r('talk_list')) | ||
|
||
self.assertContains(response, 'Ainda não existem palestras de manhã.') | ||
self.assertContains(response, 'Ainda não existem palestras de tarde.') |
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
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