Move the logic for selecting previous and next sections into python in the form of an inclusion tag