Ejemplo n.º 1
0
def edit(request, organization_id):
    if is_admin(request):
        organization = None
        if organization_id:
            organization = get_organization_by_id(organization_id)

        if request.method == 'POST':
            form = OrganizationForm(request.POST, instance=organization)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('organization:list'))
            else:
                return render(
                    request,
                    'organization/edit.html',
                    {'form': form, }
                    )
        else:
            form = OrganizationForm(instance=organization)
            return render(
                request,
                'organization/edit.html',
                {'form': form, }
                )
    else:
        return render(request, 'vms/no_admin_rights.html')
Ejemplo n.º 2
0
Archivo: views.py Proyecto: Ads7/vms
def create(request):
    if request.method == 'POST':
        form = OrganizationForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('organization:list'))
        else:
            return render(request, 'organization/create.html', {'form' : form,})
    else:
        form = OrganizationForm()
        return render(request, 'organization/create.html', {'form' : form,})
Ejemplo n.º 3
0
def create(request):
    if request.method == 'POST':
        form = OrganizationForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'organization/create_success.html') 
        else:
            return render(request, 'organization/create.html', {'form' : form,})
    else:
        form = OrganizationForm()
        return render(request, 'organization/create.html', {'form' : form,})
Ejemplo n.º 4
0
def create(request):
    if request.method == 'POST':
        form = OrganizationForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('organization:list'))
        else:
            return render(request, 'organization/create.html', {
                'form': form,
            })
    else:
        form = OrganizationForm()
        return render(request, 'organization/create.html', {
            'form': form,
        })
Ejemplo n.º 5
0
def edit(request, organization_id):

    organization = None
    if organization_id:
        organization = get_organization_by_id(organization_id)

    if request.method == 'POST':
        form = OrganizationForm(request.POST, instance=organization)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('organization:list'))
        else:
            return render(request, 'organization/edit.html', {
                'form': form,
            })
    else:
        form = OrganizationForm(instance=organization)
        return render(request, 'organization/edit.html', {
            'form': form,
        })