Skip to content
Snippets Groups Projects
Commit c3e84e85 authored by Dorian Lesbre's avatar Dorian Lesbre
Browse files

Fix planning links for multiple activities

parent 5fb78447
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,8 @@ class InterludesActivityAdmin(ExportCsvMixin, admin.ModelAdmin): ...@@ -28,7 +28,8 @@ class InterludesActivityAdmin(ExportCsvMixin, admin.ModelAdmin):
"display", "display",
"room", "start", "room", "start",
"on_planning", "on_planning",
"notes" "notes",
"canonical",
) )
list_per_page = 100 list_per_page = 100
save_as = True # Allow to duplicate models save_as = True # Allow to duplicate models
......
...@@ -69,6 +69,14 @@ class InterludesActivity(models.Model): ...@@ -69,6 +69,14 @@ class InterludesActivity(models.Model):
start = models.DateTimeField("début", null=True, blank=True) start = models.DateTimeField("début", null=True, blank=True)
room = models.CharField("salle", max_length=100, null=True, blank=True) room = models.CharField("salle", max_length=100, null=True, blank=True)
canonical = models.ForeignKey("self",
on_delete=models.SET_NULL, null=True, blank=True,
verbose_name="Représentant canonique",
help_text="Si plusieurs copie d'une activité existe (pour plusieurs crénaux), "
"et une seule est affichée, sélectionner là dans les copie pour réparer les liens "
"du planning vers la description"
)
notes = models.TextField("Notes privées", max_length=2000, blank=True) notes = models.TextField("Notes privées", max_length=2000, blank=True)
@property @property
...@@ -106,6 +114,14 @@ class InterludesActivity(models.Model): ...@@ -106,6 +114,14 @@ class InterludesActivity(models.Model):
status_repr = "présentiel" status_repr = "présentiel"
return "{} ({})".format(type, status_repr) return "{} ({})".format(type, status_repr)
@property
def slug(self) -> str:
"""Returns the planning/display slug for this activity"""
id = self.id
if self.canonical:
id = self.canonical.id
return "act-{}".format(id)
def conflicts(self, other: "InterludesActivity") -> bool: def conflicts(self, other: "InterludesActivity") -> bool:
"""Check whether these activites overlap""" """Check whether these activites overlap"""
if self.end is None or other.end is None: if self.end is None or other.end is None:
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
{% for act in planning %} {% for act in planning %}
{ {
id: {{ act.id }}, id: {{ act.id }},
content: '<a class="hidden" href="#act-{{act.id}}"><div><strong>{{ act.title }}</strong><br>{{ act.room }}</div></a>', content: '<a class="hidden" href="#{{ act.slug }}"><div><strong>{{ act.title }}</strong><br>{{ act.room }}</div></a>',
title: '<strong>{{ act.title }}</strong><br>{{ act.room }}', title: '<strong>{{ act.title }}</strong><br>{{ act.room }}',
start: '{{ settings.date_start|date:"Y-m-d"}} {{ act.start|date:"H:i:s" }}', start: '{{ settings.date_start|date:"Y-m-d"}} {{ act.start|date:"H:i:s" }}',
align: 'left', align: 'left',
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
{% endif %} {% endif %}
{% for activity in activities %} {% for activity in activities %}
<h3 id="act-{{ activity.id }}">{{ activity.title }}</h3> <h3 id="{{ activity.slug }}">{{ activity.title }}</h3>
<dl> <dl>
<dt>Durée :</dt><dd>{{ activity.pretty_duration }}</dd> <dt>Durée :</dt><dd>{{ activity.pretty_duration }}</dd>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment