les tags ne sont plus des sous-catégories
This commit is contained in:
parent
11bd53cbeb
commit
d39ea43efb
@ -284,13 +284,11 @@ class EventFilter(django_filters.FilterSet):
|
||||
def is_selected_tag(self, tag):
|
||||
return "tags" in self.form.cleaned_data and tag in self.form.cleaned_data["tags"]
|
||||
|
||||
def get_url_add_tag(self, tag, category=None):
|
||||
def get_url_add_tag(self, tag):
|
||||
full_path = self.request.get_full_path()
|
||||
|
||||
result = full_path + ('&' if '?' in full_path else '?') + 'tags=' + str(tag)
|
||||
|
||||
if not category is None:
|
||||
result = self.get_url_add_categories([category.pk], result)
|
||||
return result
|
||||
|
||||
def tag_exists(self, tag):
|
||||
|
@ -46,7 +46,7 @@ class TagForm(ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Tag
|
||||
fields = ["name", "description", "in_included_suggestions", "in_excluded_suggestions", "principal", "category"]
|
||||
fields = ["name", "description", "in_included_suggestions", "in_excluded_suggestions", "principal"]
|
||||
widgets = {
|
||||
"name": HiddenInput()
|
||||
}
|
||||
|
17
src/agenda_culturel/migrations/0113_remove_tag_category.py
Normal file
17
src/agenda_culturel/migrations/0113_remove_tag_category.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 4.2.9 on 2024-11-20 21:40
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('agenda_culturel', '0112_place_description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='tag',
|
||||
name='category',
|
||||
),
|
||||
]
|
@ -203,15 +203,6 @@ class Tag(models.Model):
|
||||
default=False,
|
||||
)
|
||||
|
||||
category = models.ForeignKey(
|
||||
Category,
|
||||
verbose_name=_("Category"),
|
||||
help_text=_("This tags corresponds to a sub-category of the given category"),
|
||||
null=True,
|
||||
blank=True,
|
||||
default=None,
|
||||
on_delete=models.SET_NULL,
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("view_tag", kwargs={"t": self.name})
|
||||
|
@ -198,7 +198,6 @@ details[role="list"] summary + ul li.selected>a:hover {
|
||||
@extend .outline;
|
||||
font-size: 90%;
|
||||
padding: 0.15em 0.4em 0.3em 0.4em;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
@ -32,20 +32,11 @@
|
||||
<div>
|
||||
{% if tag.obj %}
|
||||
{% if not tag.obj.description|html_vide %}{{ tag.obj.description|safe }}{% endif %}
|
||||
{% if tag.obj.category or tag.obj.principal or tag.obj.in_included_suggestions or tag.obj.in_excluded_suggestions %}
|
||||
<ul class="remarque">
|
||||
{% if tag.obj.category %}
|
||||
<li>Cette étiquette est une sous-catégorie de {{ tag.obj.category| small_cat:tag.obj.category.get_absolute_url }}</li>
|
||||
{% endif %}
|
||||
{% if tag.obj.principal %}
|
||||
<li>Cette étiquette est mise en avant parmi les étiquettes principales.</li>
|
||||
{% endif %}
|
||||
{% if tag.obj.in_included_suggestions %}
|
||||
<li>Cette étiquette fait partie des étiquettes suggérées à inclure.</li>
|
||||
{% endif %}
|
||||
{% if tag.obj.in_excluded_suggestions %}
|
||||
<li>Cette étiquette fait partie des étiquettes suggérées à exclure.</li>
|
||||
{% endif %}
|
||||
{% if tag.obj.principal or tag.obj.in_included_suggestions or tag.obj.in_excluded_suggestions %}
|
||||
<p class="remarque">Cette étiquette
|
||||
{% if tag.obj.principal %}est mise en avant parmi les <em>étiquettes principales</em>{% endif %}{% if tag.obj.principal and tag.obj.in_included_suggestions %}, {% endif %}
|
||||
{% if tag.obj.in_included_suggestions %}fait partie des <em>étiquettes suggérées à inclure</em>{% endif %}{% if tag.obj.in_excluded_suggestions %}{% if tag.obj.in_included_suggestions or tag.obj.principal %} et {% endif %}{% endif %}
|
||||
{% if tag.obj.in_excluded_suggestions %}fait partie des <em>étiquettes suggérées à exclure</em>{% endif %}.</p>
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
|
@ -53,16 +53,12 @@ def tag_not_in_db(tag, tags):
|
||||
@register.simple_tag
|
||||
def show_suggested_tags(filter):
|
||||
filter.form.full_clean()
|
||||
tags = Tag.objects.all().filter(principal=True).order_by("name").prefetch_related("category")
|
||||
tags = Tag.objects.all().filter(principal=True).order_by("name")
|
||||
result = "Suggestion :"
|
||||
|
||||
for t in tags:
|
||||
if filter.tag_exists(t.name) and not filter.is_selected_tag(t.name):
|
||||
if not filter.has_category() or t.category is None or filter.get_categories()[0] == t.category:
|
||||
if filter.has_category():
|
||||
result += ' ' + t_button(t.name, filter.get_url_add_tag(t.name), category=t.category)
|
||||
else:
|
||||
result += ' ' + t_button(t.name, filter.get_url_add_tag(t.name, t.category), category=t.category)
|
||||
result += ' ' + t_button(t.name, filter.get_url_add_tag(t.name))
|
||||
|
||||
return mark_safe(result)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user