Merge pull request #878 from ostcar/change_agenda_items
Fixed wrong ordering of agenda items after order change
This commit is contained in:
commit
7faf59a82b
@ -95,7 +95,6 @@ class Overview(TemplateView):
|
||||
|
||||
@transaction.commit_manually
|
||||
def post(self, request, *args, **kwargs):
|
||||
context = self.get_context_data(**kwargs)
|
||||
if not request.user.has_perm('agenda.can_manage_agenda'):
|
||||
messages.error(
|
||||
request,
|
||||
@ -116,9 +115,11 @@ class Overview(TemplateView):
|
||||
transaction.rollback()
|
||||
messages.error(
|
||||
request, _('Errors when reordering of the agenda'))
|
||||
return self.render_to_response(context)
|
||||
break
|
||||
else:
|
||||
Item.objects.rebuild()
|
||||
# TODO: assure, that it is a valid tree
|
||||
context = self.get_context_data(**kwargs)
|
||||
transaction.commit()
|
||||
return self.render_to_response(context)
|
||||
|
||||
|
@ -198,6 +198,25 @@ class ViewTest(TestCase):
|
||||
response = c.get('/agenda/%s/' % item.id)
|
||||
self.assertContains(response, 'quai5OTeephaequ0xei0')
|
||||
|
||||
def test_change_item_order(self):
|
||||
data = {
|
||||
'i1-self': 1,
|
||||
'i1-weight': 50,
|
||||
'i1-parent': 0,
|
||||
'i2-self': 2,
|
||||
'i2-weight': 50,
|
||||
'i2-parent': 1}
|
||||
response = self.adminClient.post('/agenda/', data)
|
||||
|
||||
# Test values in response.
|
||||
items = response.context['items']
|
||||
self.assertIsNone(items[0].parent)
|
||||
self.assertEqual(items[1].parent_id, 1)
|
||||
|
||||
# Test values in DB
|
||||
self.assertIsNone(Item.objects.get(pk=1).parent)
|
||||
self.assertEqual(Item.objects.get(pk=2).parent_id, 1)
|
||||
|
||||
|
||||
class ConfigTest(TestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user