parent
61a449cc77
commit
3bf1f24a4a
@ -95,7 +95,6 @@ class Overview(TemplateView):
|
|||||||
|
|
||||||
@transaction.commit_manually
|
@transaction.commit_manually
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
context = self.get_context_data(**kwargs)
|
|
||||||
if not request.user.has_perm('agenda.can_manage_agenda'):
|
if not request.user.has_perm('agenda.can_manage_agenda'):
|
||||||
messages.error(
|
messages.error(
|
||||||
request,
|
request,
|
||||||
@ -116,9 +115,11 @@ class Overview(TemplateView):
|
|||||||
transaction.rollback()
|
transaction.rollback()
|
||||||
messages.error(
|
messages.error(
|
||||||
request, _('Errors when reordering of the agenda'))
|
request, _('Errors when reordering of the agenda'))
|
||||||
return self.render_to_response(context)
|
break
|
||||||
|
else:
|
||||||
Item.objects.rebuild()
|
Item.objects.rebuild()
|
||||||
# TODO: assure, that it is a valid tree
|
# TODO: assure, that it is a valid tree
|
||||||
|
context = self.get_context_data(**kwargs)
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
||||||
|
@ -198,6 +198,25 @@ class ViewTest(TestCase):
|
|||||||
response = c.get('/agenda/%s/' % item.id)
|
response = c.get('/agenda/%s/' % item.id)
|
||||||
self.assertContains(response, 'quai5OTeephaequ0xei0')
|
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):
|
class ConfigTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user