diff --git a/pythonpro/core/templates/core/base.html b/pythonpro/core/templates/core/base.html index 15c44415..f482ab11 100644 --- a/pythonpro/core/templates/core/base.html +++ b/pythonpro/core/templates/core/base.html @@ -3,7 +3,7 @@ - Python Pro + {% block title %}Python Pro{% endblock %} diff --git a/pythonpro/promos/admin.py b/pythonpro/promos/admin.py index b97a94f6..b6941eb6 100644 --- a/pythonpro/promos/admin.py +++ b/pythonpro/promos/admin.py @@ -1,2 +1,10 @@ +from django.contrib import admin -# Register your models here. +from pythonpro.promos.models import Video + + +class VideoAdmin(admin.ModelAdmin): + list_display = ['title'] + + +admin.site.register(Video, VideoAdmin) diff --git a/pythonpro/promos/migrations/0001_initial.py b/pythonpro/promos/migrations/0001_initial.py new file mode 100644 index 00000000..a13b44de --- /dev/null +++ b/pythonpro/promos/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 2.0.1 on 2018-01-17 16:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Video', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=100)), + ('vimeo_id', models.CharField(max_length=100)), + ('slug', models.SlugField(max_length=100, unique=True)), + ], + ), + ] diff --git a/pythonpro/promos/models.py b/pythonpro/promos/models.py index 35e0d648..017c4f65 100644 --- a/pythonpro/promos/models.py +++ b/pythonpro/promos/models.py @@ -1,2 +1,7 @@ +from django.db import models -# Create your models here. + +class Video(models.Model): + title = models.CharField(max_length=100) + vimeo_id = models.CharField(max_length=100) + slug = models.SlugField(max_length=100, unique=True) diff --git a/pythonpro/promos/templates/promos/video_detail.html b/pythonpro/promos/templates/promos/video_detail.html index 1f29d697..28f78bff 100644 --- a/pythonpro/promos/templates/promos/video_detail.html +++ b/pythonpro/promos/templates/promos/video_detail.html @@ -1,10 +1,12 @@ {% extends 'core/base.html' %} {% load static %} +{% block title %}{{ video.title }}{% endblock %} {% block body %}
-
diff --git a/pythonpro/promos/tests/test_views.py b/pythonpro/promos/tests/test_views.py index 023795ed..d50956ec 100644 --- a/pythonpro/promos/tests/test_views.py +++ b/pythonpro/promos/tests/test_views.py @@ -1,15 +1,22 @@ import pytest - from django.urls import reverse +from model_mommy import mommy + +from pythonpro.promos.models import Video @pytest.fixture -def video_resp(client, transactional_db): +def video_resp(client, video): return client.get( - reverse(viewname='promos:video', args=('motivacao',)), + reverse(viewname='promos:video', args=(video.slug,)), ) +@pytest.fixture +def video(transactional_db): + return mommy.make(Video) + + def test_video_status(video_resp): assert 200 == video_resp.status_code @@ -24,7 +31,6 @@ def test_ty_status(client): @pytest.mark.parametrize( 'content', [ - '