-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout d'un système de labellisation (#6462)
Co-authored-by: Alexandre Bertin <abertin002@enseirb-matmeca.fr>
- Loading branch information
1 parent
a1fccea
commit e3da299
Showing
20 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
- model: tutorialv2.Label | ||
pk: 1 | ||
fields: | ||
name: Les plus lus | ||
description: Les contenus les plus visités du site. | ||
slug: populaires | ||
- model: tutorialv2.Label | ||
pk: 2 | ||
fields: | ||
name: Les mieux notés | ||
description: Les contenus les mieux notés du site. | ||
slug: note | ||
- model: tutorialv2.Label | ||
pk: 3 | ||
fields: | ||
name: A ne pas manquer | ||
description: Contenu jugé intéressant par un grand nombre de personnes. | ||
slug: manquer | ||
- model: tutorialv2.Label | ||
pk: 4 | ||
fields: | ||
name: Suggestion | ||
description: Contenu suggéré par l'équipe de développement. | ||
slug: suggestion | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% load i18n %} | ||
|
||
{% if labels %} | ||
<p> | ||
{% trans "Label" %}{{ labels|pluralize }}{%trans " :" %} | ||
{% comment %} | ||
Warning: whitespace in the loop below is crucial to ensure correct rendering. | ||
That's why it is written as a one-liner. Take care when modifying it. | ||
{% endcomment %} | ||
{% for label in labels %}{% if not forloop.first %}, {% endif %}<a href="{% url 'content:view-labels' label.slug %}">{{ label }}</a>{% endfor %} | ||
</p> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{% extends "base.html" %} | ||
{% load profile %} | ||
{% load thumbnail %} | ||
{% load date %} | ||
{% load i18n %} | ||
{% load captureas %} | ||
{% load times %} | ||
|
||
|
||
{% block title %} | ||
{{ headline }} | ||
{% endblock %} | ||
|
||
|
||
{% block breadcrumb %} | ||
<li>{{ headline }}</li> | ||
{% endblock %} | ||
|
||
{% block headline %} | ||
{{ headline }} | ||
{% endblock %} | ||
|
||
{% block sidebar %} | ||
<div class="sidebar"> | ||
<div class="mobile-menu-bloc mobile-all-links" data-title="Filtrer"> | ||
<h3>Filtrer</h3> | ||
<ul> | ||
{% for label in labels %} | ||
<li> | ||
<a href="{% url 'content:view-labels' label.slug %}" class="{% if current_filter_pk == label.pk %}selected{% endif %}">{{ label.name }} ({{ label.num_contents }})</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<section class="flexpage-wrapper"> | ||
{% if current_description %} | ||
<p>{{ current_description }}</p> | ||
{% endif %} | ||
{% if not contents %} | ||
<p>{% trans "Il n'y a pas de publication avec ce label." %}</p> | ||
{% else %} | ||
{% include "misc/paginator.html" with position="top" %} | ||
<div class="content-item-list"> | ||
{% for content in contents %} | ||
{% include "tutorialv2/includes/content_item.part.html" with public_content=content.public_version show_description=True show_reactions=True ignore_categories=ignore_categories %} | ||
{% endfor %} | ||
{% for i in 1|times %} | ||
<div class="fill"></div> | ||
{% endfor %} | ||
</div> | ||
{% include "misc/paginator.html" with position="bottom" %} | ||
{% endif %} | ||
|
||
</section> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Generated by Django 3.2.15 on 2023-04-20 23:29 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("tutorialv2", "0036_alter_contentsuggestion_options"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Label", | ||
fields=[ | ||
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("name", models.CharField(help_text="Nom du label", max_length=80, verbose_name="Nom")), | ||
( | ||
"description", | ||
models.TextField(blank=True, help_text="Description du label", verbose_name="Description"), | ||
), | ||
( | ||
"slug", | ||
models.SlugField( | ||
help_text="L'URL pour voir les contenus associés au label est de la forme contenus/labels/slug", | ||
max_length=80, | ||
unique=True, | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Label", | ||
"verbose_name_plural": "Labels", | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name="publishablecontent", | ||
name="labels", | ||
field=models.ManyToManyField( | ||
blank=True, | ||
db_index=True, | ||
related_name="contents", | ||
to="tutorialv2.Label", | ||
verbose_name="Labels du contenu", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.db import models | ||
|
||
|
||
class Label(models.Model): | ||
""" | ||
This model represents the labels used to highlight the quality of publications. | ||
Here few example of labels: "well-written", "comprehensive", "well-researched", etc. | ||
""" | ||
|
||
class Meta: | ||
verbose_name = "Label" | ||
verbose_name_plural = "Labels" | ||
|
||
name = models.CharField("Nom", max_length=80, help_text="Nom du label") | ||
description = models.TextField("Description", blank=True, help_text="Description du label") | ||
slug = models.SlugField( | ||
max_length=80, | ||
unique=True, | ||
help_text="L'URL pour voir les contenus associés au label est de la forme contenus/labels/slug", | ||
) | ||
|
||
def __str__(self): | ||
return self.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.