Première version de misael

This commit is contained in:
Mysaa 2024-01-16 16:31:53 +01:00
commit 4c975e7a37
Signed by: Mysaa
GPG Key ID: 7054D5D6A90F084F
18 changed files with 411 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/

0
lists/__init__.py Normal file
View File

11
lists/admin.py Normal file
View File

@ -0,0 +1,11 @@
from django.contrib import admin
from .models import *
admin.site.register(Oeuvre)
admin.site.register(JeuVideo)
admin.site.register(Film)
admin.site.register(Serie)
admin.site.register(Livre)
admin.site.register(Avis)
admin.site.register(Todo)

6
lists/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ListsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'lists'

View File

@ -0,0 +1,22 @@
# Generated by Django 5.0.1 on 2024-01-16 01:18
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='JeuVideo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('sortie', models.DateTimeField(verbose_name='Date de publication')),
],
),
]

View File

@ -0,0 +1,75 @@
# Generated by Django 5.0.1 on 2024-01-16 13:25
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('lists', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Oeuvre',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
],
),
migrations.RemoveField(
model_name='jeuvideo',
name='id',
),
migrations.RemoveField(
model_name='jeuvideo',
name='name',
),
migrations.CreateModel(
name='Film',
fields=[
('oeuvre_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='lists.oeuvre')),
('sortie', models.DateTimeField(verbose_name='Date de publication')),
],
bases=('lists.oeuvre',),
),
migrations.CreateModel(
name='Livre',
fields=[
('oeuvre_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='lists.oeuvre')),
('sortie', models.DateTimeField(verbose_name='Date de publication')),
],
bases=('lists.oeuvre',),
),
migrations.CreateModel(
name='Serie',
fields=[
('oeuvre_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='lists.oeuvre')),
('sortie', models.DateTimeField(verbose_name='Date de publication')),
],
bases=('lists.oeuvre',),
),
migrations.CreateModel(
name='Avis',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('texte', models.CharField()),
('oeuvre', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lists.oeuvre')),
],
),
migrations.AddField(
model_name='jeuvideo',
name='oeuvre_ptr',
field=models.OneToOneField(auto_created=True, default=0, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='lists.oeuvre'),
preserve_default=False,
),
migrations.CreateModel(
name='Todo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('rank', models.IntegerField()),
('oeuvre', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lists.oeuvre')),
],
),
]

View File

@ -0,0 +1,45 @@
# Generated by Django 5.0.1 on 2024-01-16 15:27
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('lists', '0002_oeuvre_remove_jeuvideo_id_remove_jeuvideo_name_film_and_more'),
]
operations = [
migrations.RemoveField(
model_name='film',
name='sortie',
),
migrations.RemoveField(
model_name='jeuvideo',
name='sortie',
),
migrations.RemoveField(
model_name='livre',
name='sortie',
),
migrations.RemoveField(
model_name='serie',
name='sortie',
),
migrations.AddField(
model_name='oeuvre',
name='sortie',
field=models.IntegerField(default=0, verbose_name='Année de sortie'),
preserve_default=False,
),
migrations.AlterField(
model_name='avis',
name='texte',
field=models.TextField(),
),
migrations.AlterField(
model_name='oeuvre',
name='name',
field=models.CharField(max_length=200, verbose_name='Nom'),
),
]

View File

29
lists/models.py Normal file
View File

@ -0,0 +1,29 @@
from django.db import models
class Oeuvre(models.Model):
name = models.CharField("Nom",max_length=200)
sortie = models.IntegerField("Année de sortie")
def __str__(self):
return self.name + (" (" + str(self.sortie) + ")" if self.sortie else "")
class JeuVideo(Oeuvre):
pass
class Film(Oeuvre):
pass
class Serie(Oeuvre):
pass
class Livre(Oeuvre):
pass
class Avis(models.Model):
oeuvre = models.ForeignKey(Oeuvre, on_delete=models.CASCADE)
texte = models.TextField()
class Todo(models.Model):
oeuvre = models.ForeignKey(Oeuvre, on_delete=models.CASCADE)
rank = models.IntegerField()

3
lists/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

8
lists/urls.py Normal file
View File

@ -0,0 +1,8 @@
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
]

6
lists/views.py Normal file
View File

@ -0,0 +1,6 @@
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")

22
manage.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'misael.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

0
misael/__init__.py Normal file
View File

16
misael/asgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
ASGI config for misael project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'misael.settings')
application = get_asgi_application()

128
misael/settings.py Normal file
View File

@ -0,0 +1,128 @@
"""
Django settings for misael project.
Generated by 'django-admin startproject' using Django 5.0.1.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-xww0xj_dh_2xtex&q%y6zlsa_$anz&4ijs(94skyhu_ijt43m@'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'lists.apps.ListsConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'misael.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'misael.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'misael',
'USER': 'misael',
'PASSWORD': 'UCmRhUBXS6HX9NeUs15oKxLZAZvixE7N+ONLHWRk1ag=',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

23
misael/urls.py Normal file
View File

@ -0,0 +1,23 @@
"""
URL configuration for misael project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include,path
urlpatterns = [
path("lists/", include("lists.urls")),
path('admin/', admin.site.urls),
]

16
misael/wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for misael project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'misael.settings')
application = get_wsgi_application()