refonte avec Django
This commit is contained in:
parent
bcb37a8862
commit
bc6add0029
162 changed files with 572 additions and 1558 deletions
0
timeline/__init__.py
Normal file
0
timeline/__init__.py
Normal file
7
timeline/admin.py
Normal file
7
timeline/admin.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Timeline
|
||||
|
||||
@admin.register(Timeline)
|
||||
class TimelineAdmin(admin.ModelAdmin):
|
||||
ordering=["-date"]
|
5
timeline/apps.py
Normal file
5
timeline/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TimelineConfig(AppConfig):
|
||||
name = 'timeline'
|
28
timeline/migrations/0001_initial.py
Normal file
28
timeline/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 2.2.4 on 2019-09-01 08:30
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Timeline',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('titre', models.CharField(max_length=200)),
|
||||
('date', models.DateField(default=datetime.date.today)),
|
||||
('heure_debut', models.TimeField(blank=True, null=True)),
|
||||
('heure_fin', models.TimeField(blank=True, null=True)),
|
||||
('lieu', models.CharField(blank=True, max_length=200)),
|
||||
('illustration', models.ImageField(upload_to='timeline')),
|
||||
('description', models.TextField(blank=True)),
|
||||
],
|
||||
),
|
||||
]
|
0
timeline/migrations/__init__.py
Normal file
0
timeline/migrations/__init__.py
Normal file
BIN
timeline/migrations/__pycache__/0001_initial.cpython-37.pyc
Normal file
BIN
timeline/migrations/__pycache__/0001_initial.cpython-37.pyc
Normal file
Binary file not shown.
BIN
timeline/migrations/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
timeline/migrations/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
22
timeline/models.py
Normal file
22
timeline/models.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from django.db import models
|
||||
from datetime import date
|
||||
|
||||
class Timeline(models.Model):
|
||||
titre = models.CharField(max_length=200)
|
||||
date = models.DateField(default=date.today)
|
||||
heure_debut = models.TimeField(null=True, blank=True)
|
||||
heure_fin = models.TimeField(null=True, blank=True)
|
||||
lieu = models.CharField(max_length=200, blank=True)
|
||||
illustration = models.ImageField(upload_to='timeline')
|
||||
description = models.TextField(blank=True)
|
||||
|
||||
@property
|
||||
def evenement_passe(self):
|
||||
return date.today() > self.date
|
||||
|
||||
@property
|
||||
def annee(self):
|
||||
return self.date.year
|
||||
|
||||
def __str__(self):
|
||||
return f"[{self.date}] {self.titre}"
|
155
timeline/templates/timeline/evenements.html
Normal file
155
timeline/templates/timeline/evenements.html
Normal file
|
@ -0,0 +1,155 @@
|
|||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="Site de la musique de Meyenheim">
|
||||
<meta name="author" content="Paul TREHIOU">
|
||||
|
||||
<title>Musique fraternité - Évènements</title>
|
||||
|
||||
{% include "include_head.html" %}
|
||||
|
||||
<link href="{% static "timeline.css" %}" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
@media (min-width: 768px) {
|
||||
.navbar-default .nav > li > a,
|
||||
.navbar-default .nav > li > a:focus {
|
||||
color: #222222;
|
||||
}
|
||||
.navbar-default .nav > li > a:hover,
|
||||
.navbar-default .nav > li > a:focus:hover {
|
||||
color: #F05F40;
|
||||
}
|
||||
}
|
||||
|
||||
.timeline-body > a > img {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: block;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body id="page-top">
|
||||
|
||||
{% include "navbar.html" %}
|
||||
|
||||
{% if liste_evenements %}
|
||||
|
||||
{% for evenement in liste_evenements %}
|
||||
|
||||
{% ifchanged evenement.annee evenement.evenement_passe %}
|
||||
|
||||
{% if not forloop.first %}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section id="timeline">
|
||||
<div class="container">
|
||||
|
||||
{% ifchanged evenement.evenement_passe %}
|
||||
<div class="page-header">
|
||||
<h1 id="timeline">{{ evenement.evenement_passe | yesno:"Évènements passés, Evènements à venir" }}</h1>
|
||||
</div>
|
||||
{% endifchanged %}
|
||||
|
||||
{% ifchanged evenement.annee evenement.evenement_passe %}
|
||||
<h2>{{ evenement.annee }}</h2>
|
||||
{% endifchanged %}
|
||||
|
||||
<ul class="timeline">
|
||||
|
||||
{% endifchanged %}
|
||||
|
||||
<li class="{% cycle 'timeline-inverted' 'timeline' %}">
|
||||
<div class="timeline-badge info"><i class="glyphicon {% cycle 'glyphicon-menu-right' 'glyphicon-menu-left' %}"></i></div>
|
||||
<div class="timeline-panel">
|
||||
<div class="timeline-heading">
|
||||
<h4 class="timeline-title">{{ evenement.titre }}</h4>
|
||||
<p><small class="text-muted"><i class="glyphicon glyphicon-calendar"></i>{{ evenement.date }}</small></br>
|
||||
<small class="text-muted"><i class="glyphicon glyphicon-time"></i>{{ evenement.heure_debut }} - {{ evenement.heure_fin }}</small></br>
|
||||
<small class="text-muted"><i class="glyphicon glyphicon-map-marker"></i>{{ evenement.lieu }}</small></p>
|
||||
</div>
|
||||
<div class="timeline-body">
|
||||
<a href="#pop_timeline_{{ forloop.counter }}" data-toggle="modal">
|
||||
<img src="{{ evenement.illustration.url }}" class="img-responsive">
|
||||
</a>
|
||||
<hr>
|
||||
|
||||
<p>{{ evenement.description }}</p>
|
||||
|
||||
<!-- Popup -->
|
||||
<div id="pop_timeline_{{ forloop.counter }}" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<img src="{{ evenement.illustration.url }}" class="img-responsive">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
{% if forloop.last %}
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% include "contact.html" %}
|
||||
|
||||
{% include "footer.html" %}
|
||||
|
||||
{% include "include_foot.html" %}
|
||||
|
||||
<script>
|
||||
window.onload = function(){$('.carousel').each(function(){
|
||||
var items = $(this).find(".item"),
|
||||
heights = [],
|
||||
tallest;
|
||||
|
||||
if (items.length) {
|
||||
function normalizeHeights() {
|
||||
items.each(function() { //add heights to array
|
||||
heights.push($(this).height());
|
||||
});
|
||||
tallest = Math.max.apply(null, heights); //cache largest value
|
||||
items.each(function() {
|
||||
$(this).css('min-height',tallest + 'px');
|
||||
});
|
||||
};
|
||||
normalizeHeights();
|
||||
|
||||
$(window).on('resize orientationchange', function () {
|
||||
tallest = 0, heights.length = 0; //reset vars
|
||||
items.each(function() {
|
||||
$(this).css('min-height','0'); //reset min-height
|
||||
});
|
||||
normalizeHeights(); //run it again
|
||||
});
|
||||
}
|
||||
})}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
3
timeline/tests.py
Normal file
3
timeline/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
7
timeline/urls.py
Normal file
7
timeline/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.index, name='evenements'),
|
||||
]
|
10
timeline/views.py
Normal file
10
timeline/views.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
from .models import Timeline
|
||||
|
||||
def index(request):
|
||||
liste_evenements = Timeline.objects.order_by('-date')
|
||||
context = {
|
||||
'liste_evenements': liste_evenements,
|
||||
}
|
||||
return render(request, 'timeline/evenements.html', context)
|
Loading…
Add table
Add a link
Reference in a new issue