Login/logout un header, gravatar
This commit is contained in:
parent
0e0016382c
commit
c56bcc041c
14 changed files with 59 additions and 46 deletions
0
core/__init__.py
Normal file
0
core/__init__.py
Normal file
3
core/admin.py
Normal file
3
core/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
core/apps.py
Normal file
6
core/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class CoreConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'core'
|
0
core/migrations/__init__.py
Normal file
0
core/migrations/__init__.py
Normal file
3
core/models.py
Normal file
3
core/models.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
0
core/templatetags/__init__.py
Normal file
0
core/templatetags/__init__.py
Normal file
9
core/templatetags/md5.py
Normal file
9
core/templatetags/md5.py
Normal 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
3
core/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
core/views.py
Normal file
3
core/views.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
|
@ -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",
|
||||||
|
|
|
@ -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]
|
||||||
|
})
|
||||||
|
|
|
@ -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,15 +12,19 @@
|
||||||
<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 %}
|
||||||
</div>
|
<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>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -27,4 +32,3 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -9,42 +9,20 @@
|
||||||
<section>
|
<section>
|
||||||
<h2>Articles récents</h2>
|
<h2>Articles récents</h2>
|
||||||
<div class="flex-card">
|
<div class="flex-card">
|
||||||
<div class="card">
|
{% for rescue in rescues %}
|
||||||
<div class="inner">
|
<div class="card">
|
||||||
<div class="img-container">
|
<div class="inner">
|
||||||
<img src="{% static 'images/sauvetage.png' %}">
|
<div class="img-container">
|
||||||
|
<img src="{% static 'images/sauvetage.png' %}">
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<p class="date">{{ rescue.date }}</p>
|
||||||
|
<p class="titre">{{ rescue.name }}</p>
|
||||||
|
<a class="btn" href="/a/{{ rescue.pk }}">Voir l'article</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
{% endfor %}
|
||||||
<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 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>
|
||||||
</section>
|
</section>
|
||||||
{% include 'quicksearch.html' %}
|
{% include 'quicksearch.html' %}
|
||||||
|
|
|
@ -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 %}
|
||||||
|
|
Loading…
Reference in a new issue