-
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
17ac92f
commit 955374d
Showing
17 changed files
with
212 additions
and
15 deletions.
There are no files selected for viewing
Binary file not shown.
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,5 +1,6 @@ | ||
from django.contrib import admin | ||
from .models import Filme | ||
from .models import Filme, Episodio | ||
|
||
# Register your models here. | ||
admin.site.register(Filme) | ||
admin.site.register(Filme) | ||
admin.site.register(Episodio) |
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,28 @@ | ||
# Generated by Django 4.2.5 on 2023-09-17 17:32 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('filme', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='filme', | ||
name='categoria', | ||
field=models.CharField(choices=[('ANALISES', 'Análises'), ('PROGRAMACAO', 'Programação'), ('APRESENTACAO', 'Apresentação'), ('OUTROS', 'Outros'), {'ANIMES', 'Animes'}], max_length=15), | ||
), | ||
migrations.CreateModel( | ||
name='Episodio', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('titulo', models.CharField(max_length=100)), | ||
('video', models.URLField()), | ||
('filme', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='episodios', to='filme.filme')), | ||
], | ||
), | ||
] |
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,13 @@ | ||
from .models import Filme | ||
|
||
|
||
def lista_filmes_recentes(request): | ||
# Lista de todos os filmes ordenados em ordem de data_criacao decrescente colocando -data_criacao | ||
lista_filmes = Filme.objects.all().order_by( | ||
'-data_criacao')[0:10] # Pegando os 10 primeiros | ||
return {"lista_filmes_recentes": lista_filmes} | ||
|
||
|
||
def lista_filmes_emalta(request): | ||
lista_filmes = Filme.objects.all().order_by('-visualizacoes')[0:10] | ||
return {"lista_filmes_emalta": lista_filmes} |
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 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block title %} | ||
DetalhesFilme Hashflix | ||
{% endblock %} | ||
|
||
{% block head %} | ||
{% load static %} | ||
<link rel="stylesheet" type="text/css" href="{% static 'css/style_detalhesfilmes.css' %}"/> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="content"> | ||
<h1>Detalhes do filme: {{ object.titulo }}</h1> | ||
<p>{{ object }}<p/> | ||
<p>{{ object.descricao }}</p> | ||
<img src="{{ object.thumb.url }}" alt=""> | ||
|
||
<h2>Episódios</h2> | ||
|
||
{% for episodio in object.episodios.all %} | ||
<a href="{{ episodio.video }}"> | ||
<p>Episódio {{ forloop.counter }}: {{ episodio.titulo }}</p> | ||
</a> | ||
{% endfor %} | ||
|
||
<h2>Filmes Relacionados</h2> | ||
<div class="films-list"> | ||
{% for film_rel in filmes_relacionados %} | ||
<div class="item-list"> | ||
<img src="{{ film_rel.thumb.url }}" alt="" class="images-list"> | ||
<a href="{% url 'filme:detalhesfilme' film_rel.pk %}"><p class="text-list">{{ film_rel.titulo }}</p></a> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
|
||
|
||
</div> | ||
{% endblock %} |
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 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block title %} | ||
HomeFilmes Hashflix | ||
{% endblock %} | ||
|
||
{% block head %} | ||
{% load static %} | ||
<link rel="stylesheet" type="text/css" href="{% static 'css/style_homefilmes.css' %}"/> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="content"> | ||
<h1>Esta é a HomeFilmes</h1> | ||
|
||
{% for filme in object_list %} | ||
<a href="{% url 'filme:detalhesfilme' filme.pk %}"><p>{{ filme.titulo }}</p></a> | ||
<hr> | ||
<p>{{ filme.descricao }}</p> | ||
<img src="{{ filme.thumb.url }}" alt=""> | ||
{% endfor %} | ||
</div> | ||
|
||
<div class=""> | ||
<h2>Novo</h2> | ||
{% for filme in lista_filmes_recentes %} | ||
<p>{{ filme }}</p> | ||
{% endfor %} | ||
</div> | ||
|
||
<div class=""> | ||
<h2>Em Alta</h2> | ||
{% for filme in lista_filmes_emalta %} | ||
<p>{{ filme }}</p> | ||
{% endfor %} | ||
</div> | ||
|
||
|
||
{% endblock %} |
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,6 +1,12 @@ | ||
from django.urls import path, include | ||
from .views import homepage | ||
from .views import Homepage, HomeFilmes, DetalhesFilme | ||
|
||
|
||
app_name = 'filme' | ||
|
||
|
||
urlpatterns = [ | ||
path('', homepage) # para ser o index | ||
path('', Homepage.as_view(), name='homepage'), | ||
path('filmes/', HomeFilmes.as_view(), name='homefilmes'), | ||
path('filmes/<int:pk>', DetalhesFilme.as_view(), name='detalhesfilme'), | ||
] |
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,7 +1,38 @@ | ||
from django.shortcuts import render | ||
from .models import Filme | ||
from django.views.generic import TemplateView, ListView, DetailView | ||
|
||
# Create your views here. | ||
|
||
|
||
def homepage(request): | ||
return render(request, "homepage.html") | ||
class Homepage(TemplateView): | ||
template_name = 'homepage.html' | ||
|
||
|
||
class HomeFilmes(ListView): | ||
template_name = "homefilmes.html" | ||
model = Filme | ||
|
||
|
||
class DetalhesFilme(DetailView): | ||
template_name = "detalhesfilme.html" | ||
model = Filme | ||
|
||
def get_context_data(self, **kwargs): | ||
# Executa primeiro a função da superClass | ||
context = super(DetalhesFilme, self).get_context_data(**kwargs) | ||
# Lista dos filmes relacionados de acordo com a categoria | ||
filmes_relacionados = Filme.objects.filter( | ||
categoria=self.get_object().categoria) | ||
context['filmes_relacionados'] = filmes_relacionados | ||
return context | ||
|
||
# def homepage(request): | ||
# return render(request, "homepage.html") | ||
|
||
#url - view - template | ||
# def homefilmes(request): | ||
# context = {} | ||
# lista_filmes = Filme.objects.all() # pega todos os objetos do banco de dados | ||
# context['lista_filmes'] = lista_filmes | ||
# return render(request, "homefilmes.html", context) |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
.content { | ||
padding-top: 4.68rem; /*Ajuste isso de acordo com a altura da sua barra de navegação */ | ||
} | ||
|
||
.films-list{ | ||
display: flex; | ||
flex-direction: row; | ||
gap: 1rem; | ||
} | ||
|
||
.text-list{ | ||
text-align: center; | ||
} | ||
|
||
.images-list{ | ||
height: 10rem; | ||
width: auto; | ||
} |
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,3 @@ | ||
.content { | ||
padding-top: 4.68rem; /*Ajuste isso de acordo com a altura da sua barra de navegação */ | ||
} |
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