Amélioration des légendes
This commit is contained in:
parent
e2bc278ca9
commit
01387ff5b9
@ -14,7 +14,7 @@ class CExtractor(TwoStepsExtractor):
|
|||||||
for e in events:
|
for e in events:
|
||||||
e_url = e.find("a")
|
e_url = e.find("a")
|
||||||
if e_url:
|
if e_url:
|
||||||
if self.add_event_url(e_url["href"]):
|
self.add_event_url(e_url["href"])
|
||||||
|
|
||||||
def add_event_from_content(
|
def add_event_from_content(
|
||||||
self,
|
self,
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 4.2.9 on 2024-09-14 13:18
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('agenda_culturel', '0074_category_pictogram_alter_event_category_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='category',
|
||||||
|
field=models.ForeignKey(default=1, help_text='Category of the event', null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='agenda_culturel.category', verbose_name='Category'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='recurrentimport',
|
||||||
|
name='defaultCategory',
|
||||||
|
field=models.ForeignKey(default=1, help_text='Category of each imported event', on_delete=django.db.models.deletion.SET_DEFAULT, to='agenda_culturel.category', verbose_name='Category'),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.9 on 2024-09-14 17:47
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('agenda_culturel', '0075_alter_event_category_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='category',
|
||||||
|
name='pictogram',
|
||||||
|
field=models.FileField(blank=True, help_text='Pictogram of the category (svg format)', max_length=1024, null=True, upload_to='', verbose_name='Pictogram'),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,29 @@
|
|||||||
|
# Generated by Django 4.2.9 on 2024-09-14 20:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('agenda_culturel', '0076_alter_category_pictogram'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='category',
|
||||||
|
name='position',
|
||||||
|
field=models.IntegerField(default=0, verbose_name='Position for ordering categories'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='category',
|
||||||
|
field=models.ForeignKey(default=None, help_text='Category of the event', null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='agenda_culturel.category', verbose_name='Category'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='recurrentimport',
|
||||||
|
name='defaultCategory',
|
||||||
|
field=models.ForeignKey(default=None, help_text='Category of each imported event', on_delete=django.db.models.deletion.SET_DEFAULT, to='agenda_culturel.category', verbose_name='Category'),
|
||||||
|
),
|
||||||
|
]
|
@ -107,14 +107,18 @@ class Category(models.Model):
|
|||||||
null=True,
|
null=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
pictogram = models.ImageField(
|
pictogram = models.FileField(
|
||||||
verbose_name=_("Pictogram"),
|
verbose_name=_("Pictogram"),
|
||||||
help_text=_("Pictogram of the category"),
|
help_text=_("Pictogram of the category (svg format)"),
|
||||||
max_length=1024,
|
max_length=1024,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
position = models.IntegerField(
|
||||||
|
verbose_name=_("Position for ordering categories"), default=0
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.color is None:
|
if self.color is None:
|
||||||
|
@ -170,7 +170,10 @@ details[role="list"] summary + ul li.selected>a:hover {
|
|||||||
height: 2.6em;
|
height: 2.6em;
|
||||||
width: 2.6em;
|
width: 2.6em;
|
||||||
border-radius: 1.3em;
|
border-radius: 1.3em;
|
||||||
|
img {
|
||||||
|
width: 80%;
|
||||||
|
margin: .2em 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.reduced {
|
.reduced {
|
||||||
opacity: .3;
|
opacity: .3;
|
||||||
|
@ -214,12 +214,17 @@ def circle_cat(category, recurrence=False):
|
|||||||
'<span class="cat ' + c + ' circ-cat" data-tooltip="' + n + '"></span>'
|
'<span class="cat ' + c + ' circ-cat" data-tooltip="' + n + '"></span>'
|
||||||
)
|
)
|
||||||
|
|
||||||
def large_circle_cat(category, url, selected=True):
|
def legend_cat(category, url, selected=True):
|
||||||
c = category.css_class()
|
c = category.css_class()
|
||||||
n = category.name
|
n = category.name
|
||||||
class_reduced = '' if selected else 'reduced'
|
class_reduced = '' if selected else 'reduced'
|
||||||
|
|
||||||
return mark_safe(
|
if category.pictogram:
|
||||||
|
return mark_safe(
|
||||||
|
'<a href="' + url + '"<span class="cat ' + class_reduced + ' ' + c + ' circ-cat circ-large" data-tooltip="' + n + '">' + '<img src="' + category.pictogram.url + '" alt="' + category.name + '" /></span></a>'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return mark_safe(
|
||||||
'<a href="' + url + '"<span class="cat ' + class_reduced + ' ' + c + ' circ-cat circ-large" data-tooltip="' + n + '"></span></a>'
|
'<a href="' + url + '"<span class="cat ' + class_reduced + ' ' + c + ' circ-cat circ-large" data-tooltip="' + n + '"></span></a>'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -227,12 +232,12 @@ def large_circle_cat(category, url, selected=True):
|
|||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def show_legend(filter):
|
def show_legend(filter):
|
||||||
filter.form.full_clean()
|
filter.form.full_clean()
|
||||||
cats = Category.objects.all()
|
cats = Category.objects.all().order_by("position")
|
||||||
if filter.is_active(only_categories=True):
|
if filter.is_active(only_categories=True):
|
||||||
return mark_safe('<div class="button-bar">' +
|
return mark_safe('<div class="button-bar">' +
|
||||||
" ".join(
|
" ".join(
|
||||||
[
|
[
|
||||||
large_circle_cat(
|
legend_cat(
|
||||||
c,
|
c,
|
||||||
filter.get_url_add_categories([c.pk])
|
filter.get_url_add_categories([c.pk])
|
||||||
if not filter.is_selected(c)
|
if not filter.is_selected(c)
|
||||||
@ -246,6 +251,6 @@ def show_legend(filter):
|
|||||||
else:
|
else:
|
||||||
return mark_safe("<div>" +
|
return mark_safe("<div>" +
|
||||||
" ".join(
|
" ".join(
|
||||||
[large_circle_cat(c, filter.get_url_add_categories([c.pk])) for c in cats]
|
[legend_cat(c, filter.get_url_add_categories([c.pk])) for c in cats]
|
||||||
) + "</div>"
|
) + "</div>"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user