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
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"core.apps.AppConfig",
|
||||
"rescue.apps.RescueConfig",
|
||||
"people.apps.PeopleConfig",
|
||||
"error.apps.ErrorConfig",
|
||||
|
|
|
@ -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]
|
||||
})
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% load static %}
|
||||
{% load md5 %}
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">
|
||||
|
@ -11,14 +12,18 @@
|
|||
<div class="left">
|
||||
<a href="" class="logo">LSDD</a>
|
||||
<div class="submenu">
|
||||
<a href="">Articles</a>
|
||||
<a href="">Personnes</a>
|
||||
<a href="">Equipages</a>
|
||||
<a href="/a/">Articles</a>
|
||||
<a href="/p/">Personnes</a>
|
||||
<a href="/c/">Equipages</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<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>
|
||||
</nav>
|
||||
|
||||
|
@ -27,4 +32,3 @@
|
|||
{% endblock %}
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -9,42 +9,20 @@
|
|||
<section>
|
||||
<h2>Articles récents</h2>
|
||||
<div class="flex-card">
|
||||
{% for rescue in rescues %}
|
||||
<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 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>
|
||||
<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>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% include 'quicksearch.html' %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% block content %}
|
||||
<p>Logged out!</p>
|
||||
<a href="{% url 'login'%}">Click here to login again.</a>
|
||||
<a href="/">Click here to go home.</a>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue