コード例 #1
0
ファイル: views.py プロジェクト: BenoitNorrin/treeio
def field_add(request, response_format='html'):
    "ContactField add"
    
    if not request.user.get_profile().is_admin('treeio.identities'):
        return user_denied(request, 
                           message="You don't have administrator access to the Infrastructure module", 
                           response_format=response_format)
    
    if request.POST:
        if not 'cancel' in request.POST:
            field = ContactField()
            form = ContactFieldForm(request.POST, instance=field)
            if form.is_valid():
                field = form.save(request)
                field.set_user_from_request(request)
                return HttpResponseRedirect(reverse('identities_field_view', args=[field.id]))
        else:
            return HttpResponseRedirect(reverse('identities_settings_view'))
    else:
        form = ContactFieldForm()

    context = _get_default_context(request)
    context.update({'form': form})
    
    return render_to_response('identities/field_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
コード例 #2
0
ファイル: views.py プロジェクト: BenoitNorrin/treeio
def field_edit(request, field_id, response_format='html'):
    "ContactField edit"
    
    field = get_object_or_404(ContactField, pk=field_id)
    if not request.user.get_profile().has_permission(field, mode='w'):
        return user_denied(request, message="You don't have access to this Field Type", 
                           response_format=response_format)
    
    if request.POST:
        if not 'cancel' in request.POST:
            form = ContactFieldForm(request.POST, instance=field)
            if form.is_valid():
                field = form.save(request)
                return HttpResponseRedirect(reverse('identities_field_view', args=[field.id]))
        else:
            return HttpResponseRedirect(reverse('identities_field_view', args=[field.id]))
    else:
        form = ContactFieldForm(instance=field)

    context = _get_default_context(request)
    context.update({'form': form,
                    'field': field})
    
    return render_to_response('identities/field_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
コード例 #3
0
ファイル: views.py プロジェクト: natasha-white/treeio-1
def field_add(request, response_format='html'):
    "ContactField add"

    if not request.user.get_profile().is_admin('treeio.identities'):
        return user_denied(
            request,
            message=
            "You don't have administrator access to the Infrastructure module",
            response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            field = ContactField()
            form = ContactFieldForm(request.POST, instance=field)
            if form.is_valid():
                field = form.save(request)
                field.set_user_from_request(request)
                return HttpResponseRedirect(
                    reverse('identities_field_view', args=[field.id]))
        else:
            return HttpResponseRedirect(reverse('identities_settings_view'))
    else:
        form = ContactFieldForm()

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('identities/field_add',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
コード例 #4
0
ファイル: views.py プロジェクト: natasha-white/treeio-1
def field_edit(request, field_id, response_format='html'):
    "ContactField edit"

    field = get_object_or_404(ContactField, pk=field_id)
    if not request.user.get_profile().has_permission(field, mode='w'):
        return user_denied(request,
                           message="You don't have access to this Field Type",
                           response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            form = ContactFieldForm(request.POST, instance=field)
            if form.is_valid():
                field = form.save(request)
                return HttpResponseRedirect(
                    reverse('identities_field_view', args=[field.id]))
        else:
            return HttpResponseRedirect(
                reverse('identities_field_view', args=[field.id]))
    else:
        form = ContactFieldForm(instance=field)

    context = _get_default_context(request)
    context.update({'form': form, 'field': field})

    return render_to_response('identities/field_edit',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)