Login/logout un header, gravatar

This commit is contained in:
Ethanell 2021-12-03 04:22:10 +01:00
parent 0e0016382c
commit c56bcc041c
14 changed files with 59 additions and 46 deletions

0
core/__init__.py Normal file
View file

3
core/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
core/apps.py Normal file
View file

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

View file

3
core/models.py Normal file
View file

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View file

9
core/templatetags/md5.py Normal file
View file

@ -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()

3
core/tests.py Normal file
View file

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

3
core/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View file

@ -31,6 +31,7 @@ ALLOWED_HOSTS = ["3cab-134-214-214-199.ngrok.io", "localhost", "4125-134-214-214
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
"core.apps.AppConfig",
"rescue.apps.RescueConfig", "rescue.apps.RescueConfig",
"people.apps.PeopleConfig", "people.apps.PeopleConfig",
"error.apps.ErrorConfig", "error.apps.ErrorConfig",

View file

@ -1,6 +1,9 @@
from django.shortcuts import render from django.shortcuts import render
from rescue.models import Rescue
def index(request): def index(request):
context = {} return render(request, "index.html", {
return render(request, "index.html", context) "rescues": Rescue.objects.order_by("date")[:3]
})

View file

@ -1,4 +1,5 @@
{% load static %} {% load static %}
{% load md5 %}
<head> <head>
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">
@ -11,14 +12,18 @@
<div class="left"> <div class="left">
<a href="" class="logo">LSDD</a> <a href="" class="logo">LSDD</a>
<div class="submenu"> <div class="submenu">
<a href="">Articles</a> <a href="/a/">Articles</a>
<a href="">Personnes</a> <a href="/p/">Personnes</a>
<a href="">Equipages</a> <a href="/c/">Equipages</a>
</div> </div>
</div> </div>
<div class="right"> <div class="right">
<a href="#quicksearch"><i class="material-icons search">search</i></a> <a href="#quicksearch"><i class="material-icons search">search</i></a>
<img src="{% static 'images/pesquet.jpg' %}"> {% if user.is_authenticated %}
<a href="{% url 'logout' %}"><img src="https://www.gravatar.com/avatar/{{ user.email | lower | md5 }}"></a>
{% else %}
<a href="{% url 'login' %}">Login</a>
{% endif %}
</div> </div>
</nav> </nav>
@ -27,4 +32,3 @@
{% endblock %} {% endblock %}
</div> </div>
</body> </body>

View file

@ -9,42 +9,20 @@
<section> <section>
<h2>Articles récents</h2> <h2>Articles récents</h2>
<div class="flex-card"> <div class="flex-card">
{% for rescue in rescues %}
<div class="card"> <div class="card">
<div class="inner"> <div class="inner">
<div class="img-container"> <div class="img-container">
<img src="{% static 'images/sauvetage.png' %}"> <img src="{% static 'images/sauvetage.png' %}">
</div> </div>
<div class="content"> <div class="content">
<p class="date">16/02/2020</p> <p class="date">{{ rescue.date }}</p>
<p class="titre">Sauvetage risqué en côte d'Ivoire</p> <p class="titre">{{ rescue.name }}</p>
<a class="btn" href="">Voir l'article</a> <a class="btn" href="/a/{{ rescue.pk }}">Voir l'article</a>
</div>
</div>
</div>
<div class="card">
<div class="inner">
<div class="img-container">
<img src="{% static 'images/sauvetage.png' %}">
</div>
<div class="content">
<p class="date">16/02/2020</p>
<p class="titre">Sauvetage risqué en côte d'Ivoire</p>
<a class="btn" href="">Voir l'article</a>
</div>
</div>
</div>
<div class="card">
<div class="inner">
<div class="img-container">
<img src="{% static 'images/sauvetage.png' %}">
</div>
<div class="content">
<p class="date">16/02/2020</p>
<p class="titre">Sauvetage risqué en côte d'Ivoire</p>
<a class="btn" href="">Voir l'article</a>
</div> </div>
</div> </div>
</div> </div>
{% endfor %}
</div> </div>
</section> </section>
{% include 'quicksearch.html' %} {% include 'quicksearch.html' %}

View file

@ -1,4 +1,4 @@
{% block content %} {% block content %}
<p>Logged out!</p> <p>Logged out!</p>
<a href="{% url 'login'%}">Click here to login again.</a> <a href="/">Click here to go home.</a>
{% endblock %} {% endblock %}