Unable to directly access a resource contained in a resource
In United4Earth, I have the following models for ActionGroups
and their Events
:
class ActionGroup(Model):
name = models.CharField(max_length=255, verbose_name=u"Nom du groupe")
objective = models.TextField(verbose_name=u"Objectif")
kind = models.ForeignKey(ActionGroupTheme, verbose_name=u"Type d'action")
description = models.TextField(blank=True, null=True, verbose_name=u"Description")
place = models.TextField(blank=True, null=True, verbose_name=u"Lieu")
frequency = models.ForeignKey(ActionGroupFrequency, null=True, verbose_name=u"Fréquence")
image = models.URLField(verbose_name=u"Image", blank=True)
representatives = models.ManyToManyField(Representative, blank=True, related_name='action_groups')
members = models.ManyToManyField(User, blank=True)
actiongroups = models.ManyToManyField("self", blank=True)
author = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='created_groups', blank=True)
conversation = models.ManyToManyField(Conversation, blank=True)
loomios = models.ManyToManyField(LoomioTopic, blank=True)
slug = models.SlugField(blank=True, null=True, unique=True)
class Meta:
auto_author = 'author'
serializer_fields = [ '@id','name', 'author', 'objective', 'description', 'kind', 'place', 'frequency', 'image', 'representatives', 'members', 'actiongroups', 'loomios', 'conversation', ]
nested_fields=[ "author", "representatives", "loomios", "actiongroups", "conversation", "members", "event_set"]
permission_classes=[AnonymousReadOnly]
depth = 0
def __str__(self):
return self.name
class Event(Model):
name = models.CharField(max_length=255, verbose_name=u"Nom de l'évenement")
image = models.URLField(verbose_name=u"Image", blank=True)
date = models.DateField(blank=True, null=True, verbose_name=u"Date de l'action")
location = models.CharField(max_length=255, blank=True, null=True, verbose_name=u"Lieu")
theme = models.CharField(max_length=255, blank=True, null=True, verbose_name=u"Theme")
organization = models.CharField(max_length=255, blank=True, null=True, verbose_name=u"Organisation")
actiongroup = models.ForeignKey(ActionGroup, blank=True, null=True)
description = models.TextField(blank=True, null=True, verbose_name=u"Description")
class Meta:
serializer_fields = ['@id','image', 'name', 'description', 'date', 'location', 'theme', 'actiongroup', 'organization']
ordering=['-date']
def __str__(self):
return self.name
The URL of a given event is something like : https://u4e.happy-dev.fr/PATH TO ACTION GROUP PAGE/ACTION GROUP ID/PATH TO ACTION GROUP EVENTS/PATH TO ACTION GROUP EVENTS DETAIL/ID OF EVENT
I manage to access it if I first click of the action group detail route, and then on the event detail subroute. However, I can't access the event's detail page directly from the home page. I end up with a URL containing only the event's ID. It does display the event correctly, but not the "surrounding" action group as its ID is not in the URL.
Here is the related issue on the project if that helps to understand the issue : https://git.happy-dev.fr/startinblox/applications/united4earth/issues/170
Not so easy for me to suggest a spec here. At the moment the sib-display
via which I try to access the events detail pages from the home page is the following :
<sib-display
next="action-group-detail-events-detail"
data-fields="image, infos"
data-src="https://u4e.happy-dev.fr/api/events/"
></sib-display>
Its associated route is :
<sib-route name="action-group-detail-events-detail" hidden use-id></sib-route>
Maybe something like :
<sib-route name="action-group-detail-events-detail" hidden use-id="actiongroup, self"></sib-route>