Skip to content

Commit

Permalink
Course como MTI
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuspdf committed Oct 8, 2024
1 parent 4e12d38 commit 714545b
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 35 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/django_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion .wttd/bin/python

This file was deleted.

1 change: 0 additions & 1 deletion .wttd/bin/python3

This file was deleted.

1 change: 0 additions & 1 deletion .wttd/bin/python3.10

This file was deleted.

1 change: 0 additions & 1 deletion .wttd/lib64

This file was deleted.

3 changes: 0 additions & 3 deletions .wttd/pyvenv.cfg

This file was deleted.

2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ notebook = "==6.5.5"
django-extensions = "*"
traitlets = "==5.9.0"
django-test-without-migrations = "*"
sqlformatter = "*"
jupyterlab-pygments = "*"

[dev-packages]
flake8 = "*"
Expand Down
2 changes: 1 addition & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion eventex/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ 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)
Original file line number Diff line number Diff line change
@@ -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'},
),
]
26 changes: 26 additions & 0 deletions eventex/core/migrations/0009_course.py
Original file line number Diff line number Diff line change
@@ -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',),
),
]
41 changes: 41 additions & 0 deletions eventex/core/migrations/0010_course_abc_to_mti.py
Original file line number Diff line number Diff line change
@@ -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)
]
16 changes: 16 additions & 0 deletions eventex/core/migrations/0011_delete_courseold.py
Original file line number Diff line number Diff line change
@@ -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",
),
]
12 changes: 5 additions & 7 deletions eventex/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -53,21 +53,19 @@ class Activity(models.Model):
objects = PeriodManager()

class Meta:
abstract = True
ordering = ['start']
verbose_name_plural = 'palestras'
verbose_name = 'palestra'

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'
6 changes: 0 additions & 6 deletions eventex/core/templates/core/talk_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ <h2>Tarde</h2>
{% empty %}
<p>Ainda não existem palestras de tarde.</p>
{% endfor %}

<h2>Mini-cursos</h2>
{% for course in courses %}
{% include 'core/talk_list_snippet.html' with talk=course only %}
{% endfor %}

</div>
</section>
{% endblock content %}
6 changes: 6 additions & 0 deletions eventex/core/tests/test_model_talk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
1 change: 0 additions & 1 deletion eventex/core/tests/test_view_talk_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def test_context(self):
variables = [
'morning_talks',
'afternoon_talks',
'courses'
]

for key in variables:
Expand Down
3 changes: 1 addition & 2 deletions eventex/core/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.shortcuts import render, get_object_or_404

from eventex.core.models import Speaker, Talk, Course
from eventex.core.models import Speaker, Talk


def home(request):
Expand All @@ -17,7 +17,6 @@ def talk_list(request):
context = {
'morning_talks': Talk.objects.at_morning(),
'afternoon_talks': Talk.objects.at_afternoon(),
'courses': Course.objects.all(),
}

return render(request, 'core/talk_list.html', context)

0 comments on commit 714545b

Please sign in to comment.