예제 #1
0
def delete_level(request):
    """Deletes the DesignerLevel for the given level_slug and removes all the location
    information for the level."""
    if request.method == 'POST':
        form = DeleteLevelForm(request.POST)
        if form.is_valid():
            level_slug = form.cleaned_data['level_slug']
            level = DesignerLevel.objects.get(slug=level_slug)
            for grid in DesignerColumnGrid.objects.filter(level=level):
                grid.delete()
            for grid in DesignerGrid.objects.filter(level=level):
                grid.delete()
            level.delete()
    response = HttpResponseRedirect("/sgg_designer/")
    return response
예제 #2
0
파일: views.py 프로젝트: csdl/makahiki
def delete_level(request, draft_slug):
    """Deletes the DesignerLevel for the given level_slug and removes all the location
    information for the level."""
    draft = smartgrid_mgr.get_designer_draft(draft_slug)
    if request.method == 'POST':
        form = DeleteLevelForm(request.POST)
        if form.is_valid():
            level_slug = form.cleaned_data['level_slug']
            level = smartgrid_mgr.get_designer_level(draft, slug=level_slug)
            for grid in DesignerColumnGrid.objects.filter(draft=draft, level=level):
                grid.delete()
            for grid in DesignerGrid.objects.filter(draft=draft, level=level):
                grid.delete()
            level.delete()
    response = HttpResponseRedirect("/sgg_designer/?draft=%s" % draft.slug)
    return response
예제 #3
0
def delete_level(request, draft_slug):
    """Deletes the DesignerLevel for the given level_slug and removes all the location
    information for the level."""
    draft = smartgrid_mgr.get_designer_draft(draft_slug)
    if request.method == 'POST':
        form = DeleteLevelForm(request.POST)
        if form.is_valid():
            level_slug = form.cleaned_data['level_slug']
            level = smartgrid_mgr.get_designer_level(draft, slug=level_slug)
            for grid in DesignerColumnGrid.objects.filter(draft=draft,
                                                          level=level):
                grid.delete()
            for grid in DesignerGrid.objects.filter(draft=draft, level=level):
                grid.delete()
            level.delete()
    response = HttpResponseRedirect("/sgg_designer/?draft=%s" % draft.slug)
    return response
예제 #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,
    }