diff --git a/core/__init__.py b/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/admin.py b/core/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/core/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/core/apps.py b/core/apps.py new file mode 100644 index 0000000..8115ae6 --- /dev/null +++ b/core/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CoreConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'core' diff --git a/core/migrations/__init__.py b/core/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/models.py b/core/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/core/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/core/templatetags/__init__.py b/core/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/templatetags/md5.py b/core/templatetags/md5.py new file mode 100644 index 0000000..dab2938 --- /dev/null +++ b/core/templatetags/md5.py @@ -0,0 +1,9 @@ +from django import template +import hashlib + +register = template.Library() + + +@register.filter(name='md5') +def md5_string(value: str): + return hashlib.md5(value.encode()).hexdigest() diff --git a/core/tests.py b/core/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/core/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/core/views.py b/core/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/core/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/nuitdelinfo_2021/settings.py.exemple b/nuitdelinfo_2021/settings.py.exemple index 2cafeae..b54ae13 100644 --- a/nuitdelinfo_2021/settings.py.exemple +++ b/nuitdelinfo_2021/settings.py.exemple @@ -31,6 +31,7 @@ ALLOWED_HOSTS = ["3cab-134-214-214-199.ngrok.io", "localhost", "4125-134-214-214 # Application definition INSTALLED_APPS = [ + "core.apps.AppConfig", "rescue.apps.RescueConfig", "people.apps.PeopleConfig", "error.apps.ErrorConfig", diff --git a/nuitdelinfo_2021/views.py b/nuitdelinfo_2021/views.py index b49be7a..be7c5de 100644 --- a/nuitdelinfo_2021/views.py +++ b/nuitdelinfo_2021/views.py @@ -1,6 +1,9 @@ from django.shortcuts import render +from rescue.models import Rescue + def index(request): - context = {} - return render(request, "index.html", context) + return render(request, "index.html", { + "rescues": Rescue.objects.order_by("date")[:3] + }) diff --git a/templates/base.html b/templates/base.html index f7b2d86..325bbda 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,5 @@ {% load static %} +{% load md5 %} @@ -11,15 +12,19 @@
-
- search - -
+
+ search + {% if user.is_authenticated %} + + {% else %} + Login + {% endif %} +
@@ -27,4 +32,3 @@ {% endblock %}
- diff --git a/templates/index.html b/templates/index.html index 8d6ad7a..c0f5797 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9,42 +9,20 @@

Articles récents

-
-
-
- + {% for rescue in rescues %} +
+
+
+ +
+
+

{{ rescue.date }}

+

{{ rescue.name }}

+ Voir l'article +
+
-
-

16/02/2020

-

Sauvetage risqué en côte d'Ivoire

- Voir l'article -
-
-
-
-
-
- -
-
-

16/02/2020

-

Sauvetage risqué en côte d'Ivoire

- Voir l'article -
-
-
-
-
-
- -
-
-

16/02/2020

-

Sauvetage risqué en côte d'Ivoire

- Voir l'article -
-
-
+ {% endfor %}
{% include 'quicksearch.html' %} diff --git a/templates/registration/logged_out.html b/templates/registration/logged_out.html index 61badb0..d31cc31 100644 --- a/templates/registration/logged_out.html +++ b/templates/registration/logged_out.html @@ -1,4 +1,4 @@ {% block content %}

Logged out!

- Click here to login again. + Click here to go home. {% endblock %}