diff --git a/.github/workflows/django_ci.yml b/.github/workflows/django_ci.yml index d099ff8..57e753a 100644 --- a/.github/workflows/django_ci.yml +++ b/.github/workflows/django_ci.yml @@ -34,13 +34,3 @@ jobs: run: | pipenv run python manage.py test - deploy: - name: Deploy - runs-on: ubuntu-latest - needs: build - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - steps: - - uses: actions/checkout@v3 - - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only \ No newline at end of file diff --git a/.wttd/bin/python b/.wttd/bin/python deleted file mode 120000 index 3e6593e..0000000 --- a/.wttd/bin/python +++ /dev/null @@ -1 +0,0 @@ -/home/matheuspdf/Documentos/GitHub/wttd/.venv/bin/python \ No newline at end of file diff --git a/.wttd/bin/python3 b/.wttd/bin/python3 deleted file mode 120000 index d8654aa..0000000 --- a/.wttd/bin/python3 +++ /dev/null @@ -1 +0,0 @@ -python \ No newline at end of file diff --git a/.wttd/bin/python3.10 b/.wttd/bin/python3.10 deleted file mode 120000 index d8654aa..0000000 --- a/.wttd/bin/python3.10 +++ /dev/null @@ -1 +0,0 @@ -python \ No newline at end of file diff --git a/.wttd/lib64 b/.wttd/lib64 deleted file mode 120000 index 7951405..0000000 --- a/.wttd/lib64 +++ /dev/null @@ -1 +0,0 @@ -lib \ No newline at end of file diff --git a/.wttd/pyvenv.cfg b/.wttd/pyvenv.cfg deleted file mode 100644 index d18a462..0000000 --- a/.wttd/pyvenv.cfg +++ /dev/null @@ -1,3 +0,0 @@ -home = /home/matheuspdf/Documentos/GitHub/wttd/.venv/bin -include-system-site-packages = false -version = 3.10.12 diff --git a/Pipfile b/Pipfile index 0efd3d2..e570dbe 100644 --- a/Pipfile +++ b/Pipfile @@ -15,6 +15,8 @@ notebook = "==6.5.5" django-extensions = "*" traitlets = "==5.9.0" django-test-without-migrations = "*" +sqlformatter = "*" +jupyterlab-pygments = "*" [dev-packages] flake8 = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 8dea0e6..429896f 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -2317,4 +2317,4 @@ "version": "==4.0.10" } } -} +} \ No newline at end of file diff --git a/eventex/core/admin.py b/eventex/core/admin.py index ff71472..e1e024d 100644 --- a/eventex/core/admin.py +++ b/eventex/core/admin.py @@ -35,6 +35,13 @@ def phone(self, obj): email.short_description = 'telefone' +class TalkModelAdmin(admin.ModelAdmin): + def get_queryset(self, request): + qs = super().get_queryset(request) + return qs.filter(course=None) + + + admin.site.register(Speaker, SpeakerModelAdmin) -admin.site.register(Talk) +admin.site.register(Talk, TalkModelAdmin) admin.site.register(Course) diff --git a/eventex/core/migrations/0008_rename_course_courseold_alter_courseold_options.py b/eventex/core/migrations/0008_rename_course_courseold_alter_courseold_options.py new file mode 100644 index 0000000..fd39000 --- /dev/null +++ b/eventex/core/migrations/0008_rename_course_courseold_alter_courseold_options.py @@ -0,0 +1,22 @@ +# Generated by Django 5.0.3 on 2024-10-08 00:26 + +from django.db import migrations + + +class Migration(migrations.Migration): + + atomic = False + dependencies = [ + ('core', '0007_alter_talk_title_course'), + ] + + operations = [ + migrations.RenameModel( + old_name='Course', + new_name='CourseOld', + ), + migrations.AlterModelOptions( + name='courseold', + options={'verbose_name': 'curso', 'verbose_name_plural': 'cursos'}, + ), + ] diff --git a/eventex/core/migrations/0009_course.py b/eventex/core/migrations/0009_course.py new file mode 100644 index 0000000..e5bb27b --- /dev/null +++ b/eventex/core/migrations/0009_course.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.2 on 2020-11-03 19:27 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0008_rename_course_courseold_alter_courseold_options'), + ] + + operations = [ + migrations.CreateModel( + name='Course', + fields=[ + ('talk_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.talk')), + ('slots', models.IntegerField()), + ], + options={ + 'verbose_name': 'curso', + 'verbose_name_plural': 'cursos', + }, + bases=('core.talk',), + ), + ] \ No newline at end of file diff --git a/eventex/core/migrations/0010_course_abc_to_mti.py b/eventex/core/migrations/0010_course_abc_to_mti.py new file mode 100644 index 0000000..5e69ff3 --- /dev/null +++ b/eventex/core/migrations/0010_course_abc_to_mti.py @@ -0,0 +1,41 @@ +# Generated by Django 3.1.2 on 2020-11-03 19:29 + +from django.db import migrations + + +def copy_src_to_dst(Source, Destination): + for src in Source.objects.all(): + dst = Destination( + title=src.title, + start=src.start, + description=src.description, + slots=src.slots + ) + dst.save() + dst.speakers.set(src.speakers.all()) + src.delete() + + +def forward_course_abc_to_mti(apps, schema_editor): + copy_src_to_dst( + apps.get_model('core', 'CourseOld'), + apps.get_model('core', 'Course'), + ) + + +def backward_course_abc_to_mti(apps, schema_editor): + copy_src_to_dst( + apps.get_model('core', 'CourseOld'), + apps.get_model('core', 'Course'), + ) + + +class Migration(migrations.Migration): + dependencies = [ + ('core', '0009_course'), + ] + + operations = [ + migrations.RunPython(forward_course_abc_to_mti, + backward_course_abc_to_mti) + ] \ No newline at end of file diff --git a/eventex/core/migrations/0011_delete_courseold.py b/eventex/core/migrations/0011_delete_courseold.py new file mode 100644 index 0000000..ea699e6 --- /dev/null +++ b/eventex/core/migrations/0011_delete_courseold.py @@ -0,0 +1,16 @@ +# Generated by Django 5.0.3 on 2024-10-08 03:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0010_course_abc_to_mti"), + ] + + operations = [ + migrations.DeleteModel( + name="CourseOld", + ), + ] diff --git a/eventex/core/models.py b/eventex/core/models.py index 675b79f..f4f333a 100644 --- a/eventex/core/models.py +++ b/eventex/core/models.py @@ -44,7 +44,7 @@ def __str__(self): return self.value -class Activity(models.Model): +class Talk(models.Model): title = models.CharField('título', max_length=200) start = models.TimeField('início', blank=True, null=True) description = models.TextField('descrição', blank=True) @@ -53,7 +53,7 @@ class Activity(models.Model): objects = PeriodManager() class Meta: - abstract = True + ordering = ['start'] verbose_name_plural = 'palestras' verbose_name = 'palestra' @@ -61,13 +61,11 @@ def __str__(self): return self.title -class Talk(Activity): - pass - - -class Course(Activity): +class Course(Talk): slots = models.IntegerField() + objects = PeriodManager() + class Meta: verbose_name_plural = 'cursos' - verbose_name = 'curso' + verbose_name = 'curso' \ No newline at end of file diff --git a/eventex/core/templates/core/talk_list.html b/eventex/core/templates/core/talk_list.html index 441592b..7272869 100644 --- a/eventex/core/templates/core/talk_list.html +++ b/eventex/core/templates/core/talk_list.html @@ -16,12 +16,6 @@

Tarde

{% empty %}

Ainda não existem palestras de tarde.

{% endfor %} - -

Mini-cursos

- {% for course in courses %} - {% include 'core/talk_list_snippet.html' with talk=course only %} - {% endfor %} - {% endblock content %} \ No newline at end of file diff --git a/eventex/core/tests/test_model_talk.py b/eventex/core/tests/test_model_talk.py index 63c0181..e6bdbe3 100644 --- a/eventex/core/tests/test_model_talk.py +++ b/eventex/core/tests/test_model_talk.py @@ -1,7 +1,7 @@ from django.test import TestCase from eventex.core.managers import PeriodManager -from eventex.core.models import Talk, Course +from eventex.core.models import Talk, Course, Course class TalkModelTest(TestCase): @@ -41,6 +41,9 @@ def test_start_null(self): def test_str(self): self.assertEqual('Título da Palestra', str(self.talk)) + def test_ordering(self): + self.assertListEqual(['start'], Talk._meta.ordering) + class PeriodManagerTest(TestCase): def setUp(self): @@ -87,3 +90,6 @@ def test_str(self): def test_manager(self): self.assertIsInstance(Course.objects, PeriodManager) + + def test_ordering(self): + self.assertListEqual(['start'], Course._meta.ordering) \ No newline at end of file diff --git a/eventex/core/tests/test_view_talk_list.py b/eventex/core/tests/test_view_talk_list.py index e45bdd0..7d25dfa 100644 --- a/eventex/core/tests/test_view_talk_list.py +++ b/eventex/core/tests/test_view_talk_list.py @@ -49,7 +49,6 @@ def test_context(self): variables = [ 'morning_talks', 'afternoon_talks', - 'courses' ] for key in variables: diff --git a/eventex/core/views.py b/eventex/core/views.py index a79ef4e..f199312 100644 --- a/eventex/core/views.py +++ b/eventex/core/views.py @@ -15,9 +15,8 @@ def speaker_detail(request, slug): def talk_list(request): context = { - 'morning_talks': Talk.objects.at_morning(), - 'afternoon_talks': Talk.objects.at_afternoon(), - 'courses': Course.objects.all(), + 'morning_talks': Talk.objects.at_morning(), + 'afternoon_talks': Talk.objects.at_afternoon(), } return render(request, 'core/talk_list.html', context)