Exemple #1
0
def delete_column(request, col_slug, draft_slug):
    """Deletes the DesignerColumnName for the given col_slug."""
    _ = request
    draft = smartgrid_mgr.get_designer_draft(draft_slug)
    column = smartgrid_mgr.get_designer_column_name(draft, col_slug)
    column.delete()
    response = HttpResponse("/sgg_designer/?draft=%s" % draft.slug)
    return response
Exemple #2
0
def delete_column(request, col_slug, draft_slug):
    """Deletes the DesignerColumnName for the given col_slug."""
    _ = request
    draft = smartgrid_mgr.get_designer_draft(draft_slug)
    column = smartgrid_mgr.get_designer_column_name(draft, col_slug)
    column.delete()
    response = HttpResponse("/sgg_designer/?draft=%s" % draft.slug)
    return response
Exemple #3
0
 def testDeleteColumn(self):
     """Tests deleting a DesignerColumnName using the url interface."""
     # Setup the column to delete
     self.client.get(reverse('instantiate_column', \
                             args=(self.column_slug,
                                   self.level_slug,
                                   1,
                                   self.draft_slug)))
     response = self.client.get(reverse('delete_designer_column', \
                                args=(self.column_slug,
                                      self.draft_slug)))
     self.failUnlessEqual(response.status_code, 200)
     draft = smartgrid_mgr.get_designer_draft(self.draft_slug)
     try:
         smartgrid_mgr.get_designer_column_name(draft, self.column_slug)
         self.fail("Didn't delete DesignerColumnName %s" % self.column_slug)
     except Http404:
         pass
Exemple #4
0
 def testRevertToGrid(self):
     """Tests reverting the DesignerGrid to the SmartGrid using the url interface."""
     # set up really fake designer grid
     self.client.get(reverse('instantiate_action', \
                             args=(self.action_slug,
                                   self.level_slug,
                                   2,
                                   2,
                                   self.draft_slug)))
     # set up fake smartgrid
     level = Level(name='Foo', slug='foo', priority=1)
     level.save()
     action = Activity(name='Test', slug='test', title='test title', description='description', \
                       type='activity', expected_duration=2)
     action.save()
     column = ColumnName(name='Column', slug='column')
     column.save()
     loc = ColumnGrid(level=level, column=1, name=column)
     loc.save()
     loc = Grid(level=level, column=1, row=2, action=action)
     loc.save()
     response = self.client.post(reverse('revert_to_grid', args=(self.draft_slug, )), {}, \
                                 follow=True)
     self.failUnlessEqual(response.status_code, 200)
     draft = smartgrid_mgr.get_designer_draft(self.draft_slug)
     try:
         smartgrid_mgr.get_designer_action(draft, self.action_slug)
         self.fail("Old Action should be deleted")
     except Http404:
         pass
     try:
         level = smartgrid_mgr.get_designer_level(draft, slug='foo')
     except Http404:
         self.fail("Didn't copy Level Foo to designer.")
     try:
         action = smartgrid_mgr.get_designer_action(draft, slug='test')
     except Http404:
         self.fail("Didn't copy action Test to designer.")
     try:
         column = smartgrid_mgr.get_designer_column_name(draft, slug='column')
     except Http404:
         self.fail("Didn't copy the ColumnName to designer.")
     qs = DesignerColumnGrid.objects.filter(name=column)
     self.failUnlessEqual(len(qs), 1, "Column is not in Designer Grid")
     loc = qs[0]
     self.failUnlessEqual(loc.level, level, "Wrong level in Designer Grid")
     self.failUnlessEqual(loc.column, 1, "Wrong column in Designer Grid")
     self.failUnlessEqual(loc.name, column, "Wrong column name in Designer Grid")
     qs = DesignerGrid.objects.filter(action=action)
     self.failUnlessEqual(len(qs), 1, "Action is not in Designer Grid")
     loc = qs[0]
     self.failUnlessEqual(loc.level, level, "Wrong level in Designer Grid")
     self.failUnlessEqual(loc.column, 1, "Wrong column in Designer Grid")
     self.failUnlessEqual(loc.row, 2, "Wrong row in Designer Grid")
Exemple #5
0
 def testInstantiateColumn(self):
     """Test instantiating DesignerColumnName from LibraryColumnName using the url interface."""
     response = self.client.get(reverse('instantiate_column', \
                                        args=(self.column_slug,
                                              self.level_slug,
                                              1,
                                              self.draft_slug)))
     self.failUnlessEqual(response.status_code, 200)
     try:
         draft = smartgrid_mgr.get_designer_draft(self.draft_slug)
         level = smartgrid_mgr.get_designer_level(draft, self.level_slug)
         column_name = smartgrid_mgr.get_designer_column_name(draft, self.column_slug)
         qs = DesignerColumnGrid.objects.filter(draft=draft, name=column_name)
         self.assertEquals(len(qs), 1, "Got the wrong number of Columns expecting 1 got %s" % \
                           len(qs))
         grid = qs[0]
         self.assertIsNotNone(grid, "Didn't put %s in ColumnGrid" % self.column_slug)
         self.assertEqual(grid.column, 1, "Got column %s expecting 1" % grid.column)
         self.assertEqual(grid.level, level, "Got wrong level")
     except Http404:
         self.fail("Got 404 response, designer objects didn't instantiate")