├── db.sqlite3 ├── genero ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── admin.cpython-38.pyc │ ├── forms.cpython-38.pyc │ ├── models.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── views.cpython-38.pyc ├── admin.py ├── apps.py ├── forms.py ├── migrations │ ├── 0001_initial.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-38.pyc │ │ └── __init__.cpython-38.pyc ├── models.py ├── tests.py ├── urls.py └── views.py ├── igtiflix ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── settings.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── wsgi.cpython-38.pyc ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py ├── manage.py ├── principal ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── admin.cpython-38.pyc │ ├── models.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── views.cpython-38.pyc ├── admin.py ├── apps.py ├── models.py ├── tests.py ├── urls.py └── views.py ├── serie ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── admin.cpython-38.pyc │ ├── forms.cpython-38.pyc │ ├── models.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── views.cpython-38.pyc ├── admin.py ├── apps.py ├── forms.py ├── migrations │ ├── 0001_initial.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-38.pyc │ │ └── __init__.cpython-38.pyc ├── models.py ├── tests.py ├── urls.py └── views.py ├── static └── css │ ├── genero.css │ ├── menu.css │ ├── principal.css │ └── reset.css └── templates ├── genero ├── genero.html └── genero_upd.html ├── menu.html ├── principal └── index.html └── serie ├── serie.html └── serie_upd.html /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/db.sqlite3 -------------------------------------------------------------------------------- /genero/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/__init__.py -------------------------------------------------------------------------------- /genero/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /genero/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /genero/__pycache__/forms.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/__pycache__/forms.cpython-38.pyc -------------------------------------------------------------------------------- /genero/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /genero/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /genero/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /genero/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from genero.models import Genero 3 | admin.site.register(Genero) 4 | -------------------------------------------------------------------------------- /genero/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class GeneroConfig(AppConfig): 5 | name = 'genero' 6 | -------------------------------------------------------------------------------- /genero/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from genero.models import Genero 3 | 4 | class GeneroForm(forms.ModelForm): 5 | 6 | class Meta: 7 | model = Genero 8 | fields = '__all__' -------------------------------------------------------------------------------- /genero/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.8 on 2020-07-26 23:05 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Genero', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('descricao', models.CharField(max_length=100)), 19 | ], 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /genero/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/migrations/__init__.py -------------------------------------------------------------------------------- /genero/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /genero/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/genero/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /genero/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | # Create your models here. 5 | class Genero(models.Model): 6 | descricao = models.CharField(max_length=100) 7 | 8 | def __str__(self): 9 | return self.descricao 10 | -------------------------------------------------------------------------------- /genero/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /genero/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path('',views.cadastro,name='cadastro'), 7 | path('delete/',views.delete,name='delete'), 8 | path('update/',views.update,name='update'), 9 | ] -------------------------------------------------------------------------------- /genero/views.py: -------------------------------------------------------------------------------- 1 | from django.http import HttpResponseNotAllowed 2 | from django.shortcuts import render 3 | 4 | from . import forms 5 | from . import models 6 | 7 | 8 | def cadastro(request): 9 | form = forms.GeneroForm() 10 | if request.method == 'POST': 11 | form = forms.GeneroForm(request.POST) 12 | if form.is_valid(): 13 | print("Saving") 14 | form.save(commit=True) 15 | else: 16 | print("ERROR") 17 | generos_list = models.Genero.objects.order_by('descricao') 18 | data_dict = {"genero_records": generos_list, 'form': form} 19 | 20 | return render(request, 'genero/genero.html', data_dict) 21 | 22 | 23 | def delete(request, id): 24 | try: 25 | models.Genero.objects.filter(id=id).delete() 26 | form = forms.GeneroForm() 27 | generos_list = models.Genero.objects.order_by('descricao') 28 | data_dict = {"genero_records": generos_list, 'form': form} 29 | return render(request, 'genero/genero.html', data_dict) 30 | except: 31 | 32 | return HttpResponseNotAllowed(); 33 | 34 | 35 | def update(request, id): 36 | item = models.Genero.objects.get(id=id); 37 | if request.method == "GET": 38 | form = forms.GeneroForm(initial={'descricao': item.descricao}) 39 | data_dict = {'form': form} 40 | return render(request, 'genero/genero_upd.html', data_dict) 41 | else: 42 | form = forms.GeneroForm(request.POST) 43 | item.descricao = form.data['descricao'] 44 | item.save() 45 | generos_list = models.Genero.objects.order_by('descricao') 46 | data_dict = {"genero_records": generos_list, 'form': form} 47 | return render(request, 'genero/genero.html', data_dict) 48 | -------------------------------------------------------------------------------- /igtiflix/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/igtiflix/__init__.py -------------------------------------------------------------------------------- /igtiflix/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/igtiflix/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /igtiflix/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/igtiflix/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /igtiflix/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/igtiflix/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /igtiflix/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/igtiflix/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /igtiflix/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for igtiflix project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igtiflix.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /igtiflix/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for igtiflix project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.0.8. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | TEMPLATE_DIR = os.path.join(BASE_DIR,'templates') 18 | STATIC_DIR = os.path.join(BASE_DIR,'static') 19 | 20 | # Quick-start development settings - unsuitable for production 21 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ 22 | 23 | # SECURITY WARNING: keep the secret key used in production secret! 24 | SECRET_KEY = 'rfl9)pvd@#a9p%*(m#pw&jpcqm&@2*^ki9r+6=23q^t=7mwx*6' 25 | 26 | # SECURITY WARNING: don't run with debug turned on in production! 27 | DEBUG = True 28 | 29 | ALLOWED_HOSTS = [] 30 | 31 | 32 | # Application definition 33 | 34 | INSTALLED_APPS = [ 35 | 'django.contrib.admin', 36 | 'django.contrib.auth', 37 | 'django.contrib.contenttypes', 38 | 'django.contrib.sessions', 39 | 'django.contrib.messages', 40 | 'django.contrib.staticfiles', 41 | 'principal', 42 | 'genero', 43 | 'serie' 44 | ] 45 | 46 | MIDDLEWARE = [ 47 | 'django.middleware.security.SecurityMiddleware', 48 | 'django.contrib.sessions.middleware.SessionMiddleware', 49 | 'django.middleware.common.CommonMiddleware', 50 | 'django.middleware.csrf.CsrfViewMiddleware', 51 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 52 | 'django.contrib.messages.middleware.MessageMiddleware', 53 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 54 | ] 55 | 56 | ROOT_URLCONF = 'igtiflix.urls' 57 | 58 | TEMPLATES = [ 59 | { 60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 61 | 'DIRS': [TEMPLATE_DIR], 62 | 'APP_DIRS': True, 63 | 'OPTIONS': { 64 | 'context_processors': [ 65 | 'django.template.context_processors.debug', 66 | 'django.template.context_processors.request', 67 | 'django.contrib.auth.context_processors.auth', 68 | 'django.contrib.messages.context_processors.messages', 69 | ], 70 | }, 71 | }, 72 | ] 73 | 74 | WSGI_APPLICATION = 'igtiflix.wsgi.application' 75 | 76 | 77 | # Database 78 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases 79 | 80 | DATABASES = { 81 | 'default': { 82 | 'ENGINE': 'django.db.backends.sqlite3', 83 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 84 | } 85 | } 86 | 87 | 88 | # Password validation 89 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators 90 | 91 | AUTH_PASSWORD_VALIDATORS = [ 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 103 | }, 104 | ] 105 | 106 | 107 | # Internationalization 108 | # https://docs.djangoproject.com/en/3.0/topics/i18n/ 109 | 110 | LANGUAGE_CODE = 'en-us' 111 | 112 | TIME_ZONE = 'UTC' 113 | 114 | USE_I18N = True 115 | 116 | USE_L10N = True 117 | 118 | USE_TZ = True 119 | 120 | 121 | # Static files (CSS, JavaScript, Images) 122 | # https://docs.djangoproject.com/en/3.0/howto/static-files/ 123 | 124 | STATIC_URL = '/static/' 125 | STATICFILES_DIRS = [ 126 | STATIC_DIR, 127 | ] 128 | -------------------------------------------------------------------------------- /igtiflix/urls.py: -------------------------------------------------------------------------------- 1 | """igtiflix URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path(route='principal/',view=include('principal.urls')), 22 | path(route=r'genero/',view=include('genero.urls')), 23 | path(route=r'serie/', view=include('serie.urls')) 24 | ] 25 | -------------------------------------------------------------------------------- /igtiflix/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for igtiflix project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igtiflix.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igtiflix.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /principal/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/principal/__init__.py -------------------------------------------------------------------------------- /principal/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/principal/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /principal/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/principal/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /principal/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/principal/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /principal/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/principal/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /principal/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/principal/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /principal/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /principal/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class PrincipalConfig(AppConfig): 5 | name = 'principal' 6 | -------------------------------------------------------------------------------- /principal/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /principal/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /principal/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | urlpatterns = [ 5 | path('',views.index,name='index') 6 | ] -------------------------------------------------------------------------------- /principal/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | # Create your views here. 3 | 4 | def index(request): 5 | return render(request,'principal/index.html') -------------------------------------------------------------------------------- /serie/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/__init__.py -------------------------------------------------------------------------------- /serie/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /serie/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /serie/__pycache__/forms.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/__pycache__/forms.cpython-38.pyc -------------------------------------------------------------------------------- /serie/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /serie/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /serie/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /serie/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from serie.models import Serie 4 | 5 | admin.site.register(Serie) 6 | -------------------------------------------------------------------------------- /serie/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SerieConfig(AppConfig): 5 | name = 'serie' 6 | -------------------------------------------------------------------------------- /serie/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | from serie.models import Serie 4 | 5 | 6 | class SerieForm(forms.ModelForm): 7 | 8 | class Meta: 9 | model = Serie 10 | fields = '__all__' -------------------------------------------------------------------------------- /serie/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.8 on 2020-07-28 22:42 2 | 3 | import django.db.models.deletion 4 | from django.db import migrations, models 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | initial = True 10 | 11 | dependencies = [ 12 | ('genero', '0001_initial'), 13 | ] 14 | 15 | operations = [ 16 | migrations.CreateModel( 17 | name='Serie', 18 | fields=[ 19 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 20 | ('nome', models.CharField(max_length=100)), 21 | ('idGenero', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='genero.Genero')), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /serie/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/migrations/__init__.py -------------------------------------------------------------------------------- /serie/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /serie/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brigolini/django-series/88832f69ad96eb8a26b372df0e185c9a91a57cc0/serie/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /serie/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | class Serie(models.Model): 5 | idGenero = models.ForeignKey("genero.Genero",on_delete=models.PROTECT) 6 | nome = models.CharField(max_length=100) 7 | 8 | def __str__(self): 9 | return self.nome 10 | -------------------------------------------------------------------------------- /serie/tests.py: -------------------------------------------------------------------------------- 1 | # Create your tests here. 2 | -------------------------------------------------------------------------------- /serie/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path('',views.cadastro,name='cadastro'), 7 | path('delete/',views.delete,name='delete'), 8 | path('update/',views.update,name='update'), 9 | ] -------------------------------------------------------------------------------- /serie/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | from . import forms 4 | from . import models 5 | 6 | 7 | def cadastro(request): 8 | print("insert") 9 | print(request.method); 10 | form = forms.SerieForm() 11 | if request.method == 'POST': 12 | form = forms.SerieForm(request.POST) 13 | if form.is_valid(): 14 | print("Saving") 15 | form.save(commit=True) 16 | else: 17 | print("ERROR") 18 | serie_list = models.Serie.objects.order_by('nome') 19 | data_dict = {"serie_records": serie_list, 'form': form} 20 | 21 | return render(request, 'serie/serie.html', data_dict) 22 | 23 | 24 | def delete(request, id): 25 | print("delete") 26 | models.Serie.objects.filter(id=id).delete() 27 | form = forms.SerieForm() 28 | serie_list = models.Serie.objects.order_by('nome') 29 | data_dict = {"serie_records": serie_list, 'form': form} 30 | return render(request, 'serie/serie.html', data_dict) 31 | 32 | 33 | def update(request, id): 34 | item = models.Serie.objects.get(id=id); 35 | if request.method == "GET": 36 | form = forms.SerieForm(initial={'nome': item.nome}) 37 | data_dict = {'form': form} 38 | return render(request, 'serie/serie_upd.html', data_dict) 39 | else: 40 | form = forms.SerieForm(request.POST) 41 | item.nome = form.data['nome'] 42 | item.save() 43 | serie_list = models.Serie.objects.order_by('nome') 44 | data_dict = {"serie_records": serie_list, 'form': form} 45 | return render(request, 'serie/serie.html', data_dict) 46 | -------------------------------------------------------------------------------- /static/css/genero.css: -------------------------------------------------------------------------------- 1 | table { 2 | margin: 30px auto; 3 | text-align: center; 4 | } 5 | 6 | thead { 7 | background: #20c997; 8 | color: white; 9 | font-weight: bold; 10 | } 11 | 12 | td, th { 13 | border: 1px solid; 14 | border-color: black; 15 | padding: 8px 15px; 16 | } 17 | 18 | form label { 19 | display: block; 20 | text-align: center; 21 | font-size: 1.3em; 22 | padding-bottom: 0.5em; 23 | } 24 | 25 | .input-padrao { 26 | display: block; 27 | margin: auto; 28 | padding: 10px 25px; 29 | width: 100%; 30 | border-radius: 5px; 31 | } 32 | 33 | .enviar-button { 34 | background: #20c997; 35 | color: white; 36 | border: none; 37 | border-radius: 5px; 38 | padding: 10px 20px; 39 | font-size: 1em; 40 | } 41 | 42 | .list-button { 43 | border: none; 44 | border-radius: 5px; 45 | padding: 2px 10px; 46 | font-size: 1em; 47 | } 48 | 49 | .apagar-button { 50 | background: mediumslateblue; 51 | } 52 | 53 | .editar-button { 54 | background: darkseagreen; 55 | } 56 | 57 | .enviar:hover { 58 | color: white; 59 | background: #00a293; 60 | transform: scale(1.2); 61 | } 62 | 63 | .conteiner-center { 64 | display: flex; 65 | justify-content: center; 66 | align-items: stretch; 67 | padding-top: 10px; 68 | border: solid; 69 | border-width: 1px; 70 | } 71 | 72 | .div-conteiner-center { 73 | padding-top: 5px; 74 | width: 100%; 75 | } 76 | 77 | .errorlist li { 78 | background-color: white; 79 | color: red; 80 | } 81 | 82 | .errorlist { 83 | background-color: white; 84 | } -------------------------------------------------------------------------------- /static/css/menu.css: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none; 3 | margin: 0; 4 | padding: 0; 5 | overflow: hidden; 6 | background-color: #20c997; 7 | } 8 | 9 | li { 10 | float: left; 11 | } 12 | 13 | li a { 14 | display: block; 15 | color: white; 16 | text-align: center; 17 | padding: 14px 16px; 18 | text-decoration: none; 19 | } 20 | 21 | li a:hover { 22 | color: white; 23 | background: #00a293; 24 | font-weight: bolder; 25 | 26 | } 27 | 28 | .titulo { 29 | text-align: center;; 30 | font-size: 40px; 31 | padding: 50px 50px; 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /static/css/principal.css: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none; 3 | margin: 0; 4 | padding: 0; 5 | overflow: hidden; 6 | background-color: #20c997; 7 | } 8 | 9 | li { 10 | float: left; 11 | } 12 | 13 | li a { 14 | display: block; 15 | color: white; 16 | text-align: center; 17 | padding: 14px 16px; 18 | text-decoration: none; 19 | } 20 | 21 | li a:hover { 22 | color: white; 23 | background: #00a293; 24 | font-weight: bolder; 25 | 26 | } 27 | 28 | .titulo { 29 | text-align: center;; 30 | font-size: 40px; 31 | padding: 50px 50px; 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /static/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ 2 | v2.0 | 20110126 3 | License: none (public domain) 4 | */ 5 | 6 | html, body, div, span, applet, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | a, abbr, acronym, address, big, cite, code, 9 | del, dfn, em, img, ins, kbd, q, s, samp, 10 | small, strike, strong, sub, sup, tt, var, 11 | b, u, i, center, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, embed, 16 | figure, figcaption, footer, header, hgroup, 17 | menu, nav, output, ruby, section, summary, 18 | time, mark, audio, video { 19 | margin: 0; 20 | padding: 0; 21 | border: 0; 22 | font-size: 100%; 23 | font: inherit; 24 | vertical-align: baseline; 25 | } 26 | /* HTML5 display-role reset for older browsers */ 27 | article, aside, details, figcaption, figure, 28 | footer, header, hgroup, menu, nav, section { 29 | display: block; 30 | } 31 | body { 32 | line-height: 1; 33 | } 34 | ol, ul { 35 | list-style: none; 36 | } 37 | blockquote, q { 38 | quotes: none; 39 | } 40 | blockquote:before, blockquote:after, 41 | q:before, q:after { 42 | content: ''; 43 | content: none; 44 | } 45 | table { 46 | border-collapse: collapse; 47 | border-spacing: 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /templates/genero/genero.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | IGTIFlix 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% include "../menu.html" %} 15 |
16 |
17 | 18 | {% if genero_records %} 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | {% for genero in genero_records %} 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {% endfor %} 38 | 39 |
GeneroClique para alterarClique para excluir
{{genero.descricao}}
40 | {% else %} 41 |

Nenhum dado cadastrado

42 | {% endif %} 43 |
44 |
45 | 46 |
47 |
48 | 49 | {{form}} 50 | {% csrf_token %} 51 | 52 | 53 | 54 | 55 | 56 | 57 |
58 |
59 |
60 | {{ msg }} 61 |
62 | 63 | 64 |
65 | 66 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /templates/genero/genero_upd.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | IGTIFlix 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% include "../menu.html" %} 15 |
16 |
17 |
18 | 19 | {{form}} 20 | {% csrf_token %} 21 | 22 | 23 | 24 |
25 |
26 | 27 | 28 |
29 | 30 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /templates/menu.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 10 |
11 | 12 | -------------------------------------------------------------------------------- /templates/principal/index.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | IGTIFlix 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% include "../menu.html" %} 15 | 16 | 17 | 18 |
19 |

IGTIFlix

20 | 21 |
22 | 23 | -------------------------------------------------------------------------------- /templates/serie/serie.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | IGTIFlix 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% include "../menu.html" %} 15 |
16 |
17 | 18 | {% if serie_records %} 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | {% for serie in serie_records %} 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {% endfor %} 38 | 39 |
SérieClique para alterarClique para excluir
{{serie.nome}}
40 | {% else %} 41 |

Nenhum dado cadastrado

42 | {% endif %} 43 |
44 |
45 | 46 |
47 |
48 | 49 | {{form}} 50 | {% csrf_token %} 51 | 52 | 53 | 54 | 55 |
56 |
57 | 58 | 59 |
60 | 61 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /templates/serie/serie_upd.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | IGTIFlix 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% include "../menu.html" %} 15 |
16 |
17 |
18 | 19 | {{form}} 20 | {% csrf_token %} 21 | 22 | 23 | 24 |
25 |
26 | 27 | 28 |
29 | 30 | 37 | 38 | 39 | --------------------------------------------------------------------------------