Apps split and base of error page
This commit is contained in:
parent
e3d1a776be
commit
691afa7298
43 changed files with 197 additions and 8 deletions
0
crew/__init__.py
Normal file
0
crew/__init__.py
Normal file
3
crew/admin.py
Normal file
3
crew/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
crew/apps.py
Normal file
6
crew/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class CrewConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'crew'
|
0
crew/migrations/__init__.py
Normal file
0
crew/migrations/__init__.py
Normal file
10
crew/models.py
Normal file
10
crew/models.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from django.db.models import Model, CharField, ManyToManyField, TextField
|
||||||
|
|
||||||
|
from nuitdelinfo_2021.models import People
|
||||||
|
|
||||||
|
|
||||||
|
class Crew(Model):
|
||||||
|
name = CharField()
|
||||||
|
members = ManyToManyField(People)
|
||||||
|
|
||||||
|
description = TextField()
|
3
crew/tests.py
Normal file
3
crew/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
7
crew/urls.py
Normal file
7
crew/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('<int:crew_id>', views.index, name='index'),
|
||||||
|
]
|
6
crew/views.py
Normal file
6
crew/views.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
|
||||||
|
def index(request, crew_id: int):
|
||||||
|
context = {}
|
||||||
|
return render(request, "crew.html", context)
|
0
error/__init__.py
Normal file
0
error/__init__.py
Normal file
3
error/admin.py
Normal file
3
error/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
error/apps.py
Normal file
6
error/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'error'
|
0
error/migrations/__init__.py
Normal file
0
error/migrations/__init__.py
Normal file
5
error/models.py
Normal file
5
error/models.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.db.models import Model, TextField
|
||||||
|
|
||||||
|
|
||||||
|
class ThomasPesquetQuotes(Model):
|
||||||
|
text = TextField()
|
3
error/tests.py
Normal file
3
error/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
error/urls.py
Normal file
3
error/urls.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
22
error/views.py
Normal file
22
error/views.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
from django.http import Http404
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
from error.models import ThomasPesquetQuotes
|
||||||
|
|
||||||
|
|
||||||
|
def index(request, exception=None):
|
||||||
|
try:
|
||||||
|
quote = ThomasPesquetQuotes.objects.order_by("?")[0].text
|
||||||
|
except:
|
||||||
|
quote = None
|
||||||
|
|
||||||
|
response = render(request, "error.html", {
|
||||||
|
"quote": quote
|
||||||
|
})
|
||||||
|
|
||||||
|
response.status_code = 500
|
||||||
|
|
||||||
|
if isinstance(exception, Http404):
|
||||||
|
response.status_code = 404
|
||||||
|
|
||||||
|
return response
|
|
@ -1,6 +0,0 @@
|
||||||
from django.db.models import Model, CharField, TextField
|
|
||||||
|
|
||||||
|
|
||||||
class Rescue(Model):
|
|
||||||
name = CharField(max_length="256")
|
|
||||||
text = TextField()
|
|
|
@ -31,6 +31,9 @@ ALLOWED_HOSTS = ["3cab-134-214-214-199.ngrok.io", "localhost"]
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
"rescue.apps.RescueConfig",
|
||||||
|
"people.apps.PeopleConfig",
|
||||||
|
"error.apps.ErrorConfig",
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
|
|
|
@ -14,11 +14,17 @@ Including another URLconf
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path, include
|
||||||
|
|
||||||
from nuitdelinfo_2021 import views
|
from nuitdelinfo_2021 import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name="index"),
|
path('', views.index, name="index"),
|
||||||
|
path("a/", include("rescue.urls")),
|
||||||
|
path("p/", include("people.urls")),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
handler400 = "error.views.index"
|
||||||
|
handler404 = "error.views.index"
|
||||||
|
handler500 = "error.views.index"
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
from .index import index
|
|
0
people/__init__.py
Normal file
0
people/__init__.py
Normal file
3
people/admin.py
Normal file
3
people/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
people/apps.py
Normal file
6
people/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class PeopleConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'people'
|
0
people/migrations/__init__.py
Normal file
0
people/migrations/__init__.py
Normal file
20
people/models.py
Normal file
20
people/models.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
from django.db.models import Model, CharField, DateField, TextField
|
||||||
|
|
||||||
|
|
||||||
|
class People(Model):
|
||||||
|
first_name = CharField(max_length=40, null=False)
|
||||||
|
last_name = CharField(max_length=60, null=False)
|
||||||
|
|
||||||
|
title = CharField(max_length=70)
|
||||||
|
description = TextField(null=False)
|
||||||
|
|
||||||
|
birth = DateField(null=False)
|
||||||
|
death = DateField()
|
||||||
|
|
||||||
|
history = TextField()
|
||||||
|
genealogy = TextField()
|
||||||
|
awards = TextField()
|
||||||
|
pro_life = TextField()
|
||||||
|
|
||||||
|
testimonials = TextField()
|
||||||
|
sources = TextField(null=False)
|
3
people/tests.py
Normal file
3
people/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
7
people/urls.py
Normal file
7
people/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('<int:people_id>/', views.index, name='index'),
|
||||||
|
]
|
15
people/views.py
Normal file
15
people/views.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from django.http import Http404
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
from people.models import People
|
||||||
|
|
||||||
|
|
||||||
|
def index(request, people_id: int):
|
||||||
|
try:
|
||||||
|
people = People.objects.get(pk=people_id)
|
||||||
|
except People.DoesNotExist:
|
||||||
|
raise Http404("People does not exist")
|
||||||
|
|
||||||
|
return render(request, "people.html", {
|
||||||
|
"people": people
|
||||||
|
})
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
asgiref==3.4.1
|
||||||
|
Django==3.2.9
|
||||||
|
pytz==2021.3
|
||||||
|
sqlparse==0.4.2
|
0
rescue/__init__.py
Normal file
0
rescue/__init__.py
Normal file
3
rescue/admin.py
Normal file
3
rescue/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
rescue/apps.py
Normal file
6
rescue/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class RescueConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'rescue'
|
0
rescue/migrations/__init__.py
Normal file
0
rescue/migrations/__init__.py
Normal file
20
rescue/models.py
Normal file
20
rescue/models.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
from django.db.models import Model, CharField, TextField, DateField, ManyToManyField, DecimalField
|
||||||
|
|
||||||
|
from people.models import People
|
||||||
|
|
||||||
|
|
||||||
|
class Rescue(Model):
|
||||||
|
name = CharField(max_length=70, null=False)
|
||||||
|
date = DateField(null=False)
|
||||||
|
|
||||||
|
location_long = DecimalField(max_digits=9, decimal_places=6)
|
||||||
|
location_lat = DecimalField(max_digits=9, decimal_places=6)
|
||||||
|
|
||||||
|
resume = CharField(max_length=125, null=False)
|
||||||
|
|
||||||
|
saved = ManyToManyField(People, related_name="saved")
|
||||||
|
rescuers = ManyToManyField(People, related_name="rescued")
|
||||||
|
|
||||||
|
description = TextField()
|
||||||
|
|
||||||
|
sources = TextField(null=False)
|
3
rescue/tests.py
Normal file
3
rescue/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
7
rescue/urls.py
Normal file
7
rescue/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('<int:article_id>', views.index, name='index'),
|
||||||
|
]
|
7
rescue/views.py
Normal file
7
rescue/views.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
|
||||||
|
def index(request, article_id: int):
|
||||||
|
context = {}
|
||||||
|
return render(request, "article.html", context)
|
||||||
|
|
0
templates/article.html
Normal file
0
templates/article.html
Normal file
0
templates/crew.html
Normal file
0
templates/crew.html
Normal file
6
templates/error.html
Normal file
6
templates/error.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<h1>Oups, une erreur est survenue :/</h1>
|
||||||
|
|
||||||
|
{% if quote %}
|
||||||
|
<h2>Pour nous faire pardonner voici une citation de Thomas Pesquet:</h2>
|
||||||
|
<p>{{ quote }}</p>
|
||||||
|
{% endif %}
|
0
templates/people.html
Normal file
0
templates/people.html
Normal file
Loading…
Reference in a new issue