def testLibraryToDesigner(self):
     """Tests instantiating a DesignerAction from a LibraryAction."""
     # LibraryAction -> DesignerAction
     lib_action = smartgrid_mgr.get_library_action(self.action_slug)
     des_action = smartgrid_mgr.instantiate_designer_action_from_library(self.draft, \
                                                                         lib_action.slug)
     self.assertTrue(des_action, "Couldn't instantiate designer action %s" % lib_action.slug)
     self.assertTrue(smartgrid_mgr.get_designer_action(self.draft, self.action_slug), \
                     "Couldn't retrieve the designer action %s" % self.action_slug)
     # ensure the TextPropmptQuestions are there
     for tpq in LibraryTextPromptQuestion.objects.filter(libraryaction=lib_action):
         try:
             des_tpq = get_object_or_404(DesignerTextPromptQuestion, draft=self.draft, \
                                         question=tpq.question, answer=tpq.answer, \
                                         action=des_action)
             self.assertTrue(des_tpq, "Couldn't get DesignerTextPromptQuestion")
         except Http404:
             self.fail("Couldn't find DesignerTextPromptQuestion for %s" % tpq)
     # LibraryColumnNames -> DesignerColumnNames
     lib_column = smartgrid_mgr.get_library_column_name(self.col_slug)
     self.assertTrue(lib_column, "Couldn't get LibraryColumnName %s" % self.col_slug)
     des_column = smartgrid_mgr.instantiate_designer_column_from_library(self.draft, \
                                                                         self.col_slug)
     self.assertTrue(des_column, "Couldn't get DesignerColumnName %s" % self.col_slug)
     self.assertEqual(self.draft, des_column.draft, "Drafts are not equal.")
Exemple #2
0
 def testLibraryToDesigner(self):
     """Tests instantiating a DesignerAction from a LibraryAction."""
     # LibraryAction -> DesignerAction
     lib_action = smartgrid_mgr.get_library_action(self.action_slug)
     des_action = smartgrid_mgr.instantiate_designer_action_from_library(self.draft, \
                                                                         lib_action.slug)
     self.assertTrue(
         des_action,
         "Couldn't instantiate designer action %s" % lib_action.slug)
     self.assertTrue(smartgrid_mgr.get_designer_action(self.draft, self.action_slug), \
                     "Couldn't retrieve the designer action %s" % self.action_slug)
     # ensure the TextPropmptQuestions are there
     for tpq in LibraryTextPromptQuestion.objects.filter(
             libraryaction=lib_action):
         try:
             des_tpq = get_object_or_404(DesignerTextPromptQuestion, draft=self.draft, \
                                         question=tpq.question, answer=tpq.answer, \
                                         action=des_action)
             self.assertTrue(des_tpq,
                             "Couldn't get DesignerTextPromptQuestion")
         except Http404:
             self.fail("Couldn't find DesignerTextPromptQuestion for %s" %
                       tpq)
     # LibraryColumnNames -> DesignerColumnNames
     lib_column = smartgrid_mgr.get_library_column_name(self.col_slug)
     self.assertTrue(lib_column,
                     "Couldn't get LibraryColumnName %s" % self.col_slug)
     des_column = smartgrid_mgr.instantiate_designer_column_from_library(self.draft, \
                                                                         self.col_slug)
     self.assertTrue(des_column,
                     "Couldn't get DesignerColumnName %s" % self.col_slug)
     self.assertEqual(self.draft, des_column.draft, "Drafts are not equal.")
Exemple #3
0
def preview_library_action(request, action_slug):
    """Pre-views the LibraryAction with the given action_slug."""
    action = smartgrid_mgr.get_library_action(action_slug)
    view_objects = {}
    # if there is embedded widget, get the supplied objects
    if action.embedded_widget:
        view_module_name = 'apps.widgets.' + action.embedded_widget + '.views'
        view_objects[action.embedded_widget] = importlib.import_module(
            view_module_name).supply(request, None)
        view_objects['embedded_widget_template'] = "widgets/" + \
            action.embedded_widget + "/templates/index.html"

    return render_to_response("action.html", {
    "action": action,
    "view_objects": view_objects,
    }, context_instance=RequestContext(request))
Exemple #4
0
def preview_library_action(request, action_slug):
    """Pre-views the LibraryAction with the given action_slug."""
    action = smartgrid_mgr.get_library_action(action_slug)
    view_objects = {}
    # if there is embedded widget, get the supplied objects
    if action.embedded_widget:
        view_module_name = 'apps.widgets.' + action.embedded_widget + '.views'
        view_objects[action.embedded_widget] = importlib.import_module(
            view_module_name).supply(request, None)
        view_objects['embedded_widget_template'] = "widgets/" + \
            action.embedded_widget + "/templates/index.html"

    return render_to_response("action.html", {
        "action": action,
        "view_objects": view_objects,
    },
                              context_instance=RequestContext(request))