Closed tcouch closed 2 years ago
Preferred option is to remove pagination on /anonymous/list and just list the topics, clicking on a topic shows all the relevant anonymous fragments in one page (not sure the url /anonymous/list makes sense in that case)
Richard confirms they would not want to move anon fragments across topics
[x] test_new_link_order_is_last_if_not_apposita
when a new AnonymousTopicLink is saved, if it is not an apposita, it should be given an order value equal to the number of pre-existing links associated with that topic plus one; e.g. if there are 10 non-apposita AnonymousTopicLinks associated with the topic "Monarchy", a new AnonymousTopicLink associated with "Monarchy" should have order = 11.
[x] test_new_link_order_is_zero_if_apposita
whan a new AnonymousTopicLink is saved, and the fragment is an apposita, it should be given an order of zero.
[x] test_links_reindexed_when_link_removed
when an AnonymousTopicLink is deleted, anonymous topic links within the affected topic should be reindexed
[x] test_link_order_change_updates_anon_fragment_order
when AnonymousTopicLinks are reordered within a topic, anonymous fragments should be reindexed to take this into account; e.g. assert AnonymousFragment.reindex_anonymous_fragments is called when link order changes
[x] test_apposita_not_in_related_queryset
apposita (anonymous fragments with links to fragments) should not appear in related_queryset
[x] test_related_queryset_relates_to_topic
setUpTestData():
two topics: topic1(name="Monarchy", order=0), topic2 (name="Law", order=1)
three anonymous fragments: anon1, anon2, anon3
one fragment: frag1
one appositum_link: (frag1, anon3)
add anon1, anon2, and anon3 to topic1 in that order
add anon2 and anon1 to topic2 in that order
[x] test_reindex_anonymous_fragments_order_by_topic
when reindexing anonymous fragments, topic order should take precedence over order within topic. With setUpData:
[x] test_reindex_anonymous_fragments_order_by_topic_link_order
when reindexing anonymous fragments, their order with respect to topics should be taken into account. Where two fragments both belong to the same two topics and their order relative to each other is different within those topics, their order with respect to the topic with lower order should take precedence. With the setUpData:
[ ] test_move_to
[ ] test_cannot_move_to_zero
[ ] test_cannot_move_beyond_end
[ ] test_no_gaps_in_order_after_move
Splitting this out from #290 as these requests can be tackled independently.
Description
On the /anonymous/list page, anonymous fragments are currently displayed under topic headings and the order in which they're displayed within those topics is determined by the fragment's order value. Users would like to be able to change the fragment's order within topics by dragging them up and down (or clicking up/down buttons) within the topic list (c.f. /topic/list/ page).
Current functionality
reindex_anonymous_fragments
function creates a queryset containing all AnonymousFragments ordered by topic order, then by their own order value; duplicates are removed; then order values are updated for each fragment according to its position in the queryset.Proposed solution
Luckily @peterbispham seems to have anticipated this and added an order field to AnonymousTopicLink which we can use to record the order with respect to Topic for Anonymous Fragments. A quick survey of the database confirms this field is not currently used.
Once we have an order wrt topic for each AnonymousTopicLink, we can change the reindex_anonymous_fragments function to order AnonymousFragments by Topic order, then by AnonymousTopicLink order to determine their overall order.