mysociety / sayit

SayIt - a component for recording and storing public statements.
http://sayit.mysociety.org/
Other
105 stars 38 forks source link

Some bugs occur for overlaying sections #463

Open girogiro opened 9 years ago

girogiro commented 9 years ago

Assume the following section structure:

and some speeches in each sitting. Section.get_descendants_tree() transforms it to:

because of earliest speech dates. There are some bugs related to displaying it:

  1. When rendering template section_detail.html, the line

    <span class="section-title"><a href="{% url 'speeches:section-view' node.get_path %}">{{ node.title }}</a></span>

    causes error

    Reverse for 'section-view' with arguments '('',)' and keyword arguments '{}' not found. ...

    because of empty result from Section.get_path().

    Also the copy of session 1 is considered a leaf node because of no children attribute (although it actually has children) and it tries to show speech count in parentheses.

    Those two issues can be cured by copying also the id attribute to the section copy. (I am not sure if this can cause some unwanted side-effects.)

  2. Furthermore, the copy of session 1 has no speech_min attribute, so it is moved to the very end of the page by Section._interleave_speeches().

    A line

    section_copy.speech_min = node.speech_min

    is needed just behind creation of the section copy in Section.get_descendants_tree().

Those simple findings took some hours of my life.

Footnote: I would prefer to show the above section structure in its original form without splitting the session 1, but I think there is no simple way to get it. SayIt just handles it differently.

dracos commented 9 years ago

Sorry about this, and for wasting some hours of your time. As I wrote in #460, we want to replace this with an order field so that the database will remember the Akoma Ntoso import order of speeches/sections and display them in that order, not trying to be clever, as it just causes problems such as you note and isn't worth it.