ajout plusieurs illustrations par évenement
This commit is contained in:
parent
6f51c60335
commit
e78ae9e05d
18
default.nix
18
default.nix
@ -1,17 +1,25 @@
|
|||||||
{ pkgs ? import <nixpkgs> {} }:
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
pkgs.stdenv.mkDerivation rec {
|
pkgs.python3.pkgs.buildPythonPackage rec {
|
||||||
name= "site-musique";
|
pname= "site-musique";
|
||||||
|
version = "1.0";
|
||||||
|
|
||||||
inherit (pkgs) stdenv;
|
inherit (pkgs) stdenv;
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
installPhase = ''
|
propagatedBuildInputs = [ pkgs.python3.pkgs.django_2_2 pkgs.python3.pkgs.pillow ];
|
||||||
mkdir -p $out/
|
|
||||||
cp -R . $out/
|
postFixup = ''
|
||||||
|
wrapPythonProgramsIn $out/bin/manage.py
|
||||||
|
#HACK wrapper breaks django manage.py
|
||||||
|
sed -i "$out/bin/.manage.py-wrapped" -e '
|
||||||
|
0,/sys.argv\[0\].*;/s/sys.argv\[0\][^;]*;//
|
||||||
|
'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Site de présentation de l'association Musique Fraternité de Meyenheim";
|
description = "Site de présentation de l'association Musique Fraternité de Meyenheim";
|
||||||
homepage = https://musique-meyenheim.fr;
|
homepage = https://musique-meyenheim.fr;
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from .models import Timeline
|
from .models import Evenement, Illustration
|
||||||
|
|
||||||
@admin.register(Timeline)
|
class IllustrationInline(admin.TabularInline):
|
||||||
class TimelineAdmin(admin.ModelAdmin):
|
model = Illustration
|
||||||
|
|
||||||
|
@admin.register(Evenement)
|
||||||
|
class EvenementAdmin(admin.ModelAdmin):
|
||||||
ordering=["-date"]
|
ordering=["-date"]
|
||||||
|
inlines = [
|
||||||
|
IllustrationInline,
|
||||||
|
]
|
||||||
|
39
timeline/migrations/0002_auto_20190908_1550.py
Normal file
39
timeline/migrations/0002_auto_20190908_1550.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# Generated by Django 2.2.4 on 2019-09-08 13:50
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('timeline', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Evenement',
|
||||||
|
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)),
|
||||||
|
('description', models.TextField(blank=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Illustration',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('nom', models.CharField(max_length=200)),
|
||||||
|
('image', models.ImageField(upload_to='timeline')),
|
||||||
|
('evenement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='timeline.Evenement')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Timeline',
|
||||||
|
),
|
||||||
|
]
|
@ -1,13 +1,12 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
class Timeline(models.Model):
|
class Evenement(models.Model):
|
||||||
titre = models.CharField(max_length=200)
|
titre = models.CharField(max_length=200)
|
||||||
date = models.DateField(default=date.today)
|
date = models.DateField(default=date.today)
|
||||||
heure_debut = models.TimeField(null=True, blank=True)
|
heure_debut = models.TimeField(null=True, blank=True)
|
||||||
heure_fin = models.TimeField(null=True, blank=True)
|
heure_fin = models.TimeField(null=True, blank=True)
|
||||||
lieu = models.CharField(max_length=200, blank=True)
|
lieu = models.CharField(max_length=200, blank=True)
|
||||||
illustration = models.ImageField(upload_to='timeline')
|
|
||||||
description = models.TextField(blank=True)
|
description = models.TextField(blank=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -20,3 +19,12 @@ class Timeline(models.Model):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"[{self.date}] {self.titre}"
|
return f"[{self.date}] {self.titre}"
|
||||||
|
|
||||||
|
|
||||||
|
class Illustration(models.Model):
|
||||||
|
nom = models.CharField(max_length=200)
|
||||||
|
image = models.ImageField(upload_to='timeline')
|
||||||
|
evenement = models.ForeignKey(Evenement, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"[{self.evenement}] {self.nom}"
|
||||||
|
@ -82,23 +82,64 @@
|
|||||||
<small class="text-muted"><i class="glyphicon glyphicon-map-marker"></i>{{ evenement.lieu }}</small></p>
|
<small class="text-muted"><i class="glyphicon glyphicon-map-marker"></i>{{ evenement.lieu }}</small></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="timeline-body">
|
<div class="timeline-body">
|
||||||
<a href="#pop_timeline_{{ forloop.counter }}" data-toggle="modal">
|
{% if evenement.illustration_set.count > 1 %}
|
||||||
<img src="{{ evenement.illustration.url }}" class="img-responsive">
|
<div id="carousel-{{ forloop.counter }}" class="carousel slide" data-ride="carousel">
|
||||||
</a>
|
<div class="carousel-inner" role="listbox">
|
||||||
|
{% for illustration in evenement.illustration_set.all %}
|
||||||
|
<div class="item{% if forloop.first %} active{% endif %}">
|
||||||
|
<a href="#pop_timeline_{{ forloop.parentloop.counter }}_{{ forloop.counter }}" data-toggle="modal">
|
||||||
|
<img src="{{ illustration.image.url }}" class="img-responsive">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a class="left carousel-control" href="#carousel-{{ forloop.counter }}" role="button" data-slide="prev">
|
||||||
|
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
|
||||||
|
<span class="sr-only">Previous</span>
|
||||||
|
</a>
|
||||||
|
<a class="right carousel-control" href="#carousel-{{ forloop.counter }}" role="button" data-slide="next">
|
||||||
|
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
|
||||||
|
<span class="sr-only">Next</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p>{{ evenement.description }}</p>
|
<p>{{ evenement.description }}</p>
|
||||||
|
|
||||||
<!-- Popup -->
|
{% for illustration in evenement.illustration_set.all %}
|
||||||
<div id="pop_timeline_{{ forloop.counter }}" class="modal fade">
|
<div id="pop_timeline_{{ forloop.parentloop.counter }}_{{ forloop.counter }}" class="modal fade">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<img src="{{ evenement.illustration.url }}" class="img-responsive">
|
<img src="{{ illustration.image.url }}" class="img-responsive">
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% with evenement.illustration_set.all|first as illustration %}
|
||||||
|
<a href="#pop_timeline_{{ forloop.counter }}" data-toggle="modal">
|
||||||
|
<img src="{{ illustration.image.url }}" class="img-responsive">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>{{ evenement.description }}</p>
|
||||||
|
|
||||||
|
<div id="pop_timeline_{{ forloop.counter }}" class="modal fade">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-body">
|
||||||
|
<img src="{{ illustration.image.url }}" class="img-responsive">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
from .models import Timeline
|
from .models import Evenement
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
liste_evenements = Timeline.objects.order_by('-date')
|
liste_evenements = Evenement.objects.order_by('-date')
|
||||||
context = {
|
context = {
|
||||||
'liste_evenements': liste_evenements,
|
'liste_evenements': liste_evenements,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user