Exemple #1
0
def run_lint(request, draft_slug):
    """Runs unlock_lint over the DesignerActions and shows the results in a page."""
    user = request.user
    draft = smartgrid_mgr.get_designer_draft(draft_slug)
    settings, _ = GccSettings.objects.get_or_create(user=user)
    results = gcc.run_designer_checks(draft, settings)
    trees = action_dependency.build_designer_grid_trees(draft)
    unlock_tree = ''
    for k in list(trees):
        unlock_tree += trees[k].tohtmlstring()
        unlock_tree += '<p></p>'
    return HttpResponse(json.dumps({
            "errors": results[_ERRORS],
            "warnings": results[_WARNINGS],
            "dependency_trees": unlock_tree,
            }), mimetype="application/json")
Exemple #2
0
def run_lint(request, draft_slug):
    """Runs unlock_lint over the DesignerActions and shows the results in a page."""
    user = request.user
    draft = smartgrid_mgr.get_designer_draft(draft_slug)
    settings, _ = GccSettings.objects.get_or_create(user=user)
    results = gcc.run_designer_checks(draft, settings)
    trees = action_dependency.build_designer_grid_trees(draft)
    unlock_tree = ''
    for k in list(trees):
        unlock_tree += trees[k].tohtmlstring()
        unlock_tree += '<p></p>'
    return HttpResponse(json.dumps({
        "errors": results[_ERRORS],
        "warnings": results[_WARNINGS],
        "dependency_trees": unlock_tree,
    }),
                        mimetype="application/json")
Exemple #3
0
def supply(request, page_name):
    """ supply view_objects for widget rendering."""
    _ = page_name
    user = request.user
    gcc_settings, _ = GccSettings.objects.get_or_create(user=user)
    draft_choices = Draft.objects.all()
    draft = None
    tree_list = None
    levels = []
    if len(draft_choices) != 0:
        try:
            draft_slug = request.REQUEST['draft']
        except KeyError:
            try:
                draft_slug = request.COOKIES['current-designer-draft']
            except KeyError:
                draft_slug = draft_choices[0].slug
        try:
            draft = smartgrid_mgr.get_designer_draft(draft_slug)
        except Http404:
            draft = draft_choices[0]
        levels = DesignerLevel.objects.filter(draft=draft)
        if len(levels) == 0:  # need to create default level
            l = DesignerLevel()
            l.name = "Level 1"  # no name
            l.slug = "default"
            l.unlock_condition = "True"
            l.unlock_condition_text = "Unlocked"
            l.draft = draft
            l.save()
        levels = DesignerLevel.objects.filter(draft=draft)
        ts = action_dependency.build_designer_grid_trees(draft)
        tree_list = []
        for k in list(ts):
            tree_list.append(ts[k].tohtmlstring())
    results = gcc.run_designer_checks(draft, gcc_settings)

    return {
        'draft': draft,
        'draft_choices': draft_choices,
        'levels': levels,
        'columns': LibraryColumnName.objects.all(),
        'activities': LibraryActivity.objects.all(),
        'commitments': LibraryCommitment.objects.all(),
        'events': LibraryEvent.objects.all(),
        'fillers': Filler.objects.all(),
        'reset_form': RevertToSmartgridForm(),
        'publish_form': DeployToSmartgridForm(),
        'example_grid_form': ExampleGridsForm(),
        'add_level_form': AddLevelForm(),
        'delete_level_form': DeleteLevelForm(),
        'event_date_form': EventDateForm(),
        'new_draft_form': NewDraftForm(),
        'delete_draft_form': DeleteDraftForm(),
        'load_template_form': LoadTemplateForm(),
        'gcc_settings_form': GccSettingsForm(instance=gcc_settings),
        'palette': smartgrid_mgr.get_designer_palette(draft),
        'designer_grid': smartgrid_mgr.get_designer_grid(draft),
        'designer_actions': smartgrid_mgr.get_designer_action_slugs(draft),
        'designer_columns':
        smartgrid_mgr.get_designer_column_name_slugs(draft),
        'errors': results[_ERRORS],
        'warnings': results[_WARNINGS],
        'trees': tree_list,
    }
Exemple #4
0
def supply(request, page_name):
    """ supply view_objects for widget rendering."""
    _ = page_name
    user = request.user
    gcc_settings, _ = GccSettings.objects.get_or_create(user=user)
    draft_choices = Draft.objects.all()
    draft = None
    tree_list = None
    levels = []
    if len(draft_choices) != 0:
        try:
            draft_slug = request.REQUEST['draft']
        except KeyError:
            try:
                draft_slug = request.COOKIES['current-designer-draft']
            except KeyError:
                draft_slug = draft_choices[0].slug
        try:
            draft = smartgrid_mgr.get_designer_draft(draft_slug)
        except Http404:
            draft = draft_choices[0]
        levels = DesignerLevel.objects.filter(draft=draft)
        if len(levels) == 0:  # need to create default level
            l = DesignerLevel()
            l.name = "Level 1"  # no name
            l.slug = "default"
            l.unlock_condition = "True"
            l.unlock_condition_text = "Unlocked"
            l.draft = draft
            l.save()
        levels = DesignerLevel.objects.filter(draft=draft)
        ts = action_dependency.build_designer_grid_trees(draft)
        tree_list = []
        for k in  list(ts):
            tree_list.append(ts[k].tohtmlstring())
    results = gcc.run_designer_checks(draft, gcc_settings)

    return {
        'draft': draft,
        'draft_choices': draft_choices,
        'levels': levels,
        'columns': LibraryColumnName.objects.all(),
        'activities': LibraryActivity.objects.all(),
        'commitments': LibraryCommitment.objects.all(),
        'events': LibraryEvent.objects.all(),
        'fillers': Filler.objects.all(),
        'reset_form': RevertToSmartgridForm(),
        'publish_form': DeployToSmartgridForm(),
        'example_grid_form': ExampleGridsForm(),
        'add_level_form': AddLevelForm(),
        'delete_level_form': DeleteLevelForm(),
        'event_date_form': EventDateForm(),
        'new_draft_form': NewDraftForm(),
        'delete_draft_form': DeleteDraftForm(),
        'load_template_form': LoadTemplateForm(),
        'gcc_settings_form': GccSettingsForm(instance=gcc_settings),
        'palette': smartgrid_mgr.get_designer_palette(draft),
        'designer_grid': smartgrid_mgr.get_designer_grid(draft),
        'designer_actions': smartgrid_mgr.get_designer_action_slugs(draft),
        'designer_columns': smartgrid_mgr.get_designer_column_name_slugs(draft),
        'errors': results[_ERRORS],
        'warnings': results[_WARNINGS],
        'trees': tree_list,
            }