Пример #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')
Пример #2
0
Файл: views.py Проект: 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,})
Пример #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,})
Пример #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,
        })
Пример #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,
        })