Esempio n. 1
0
def PersonCreate(request, membertype):
    family = user_to_person(request.user).family
    if request.method == "POST":
        person = Person()
        person.membertype = membertype
        person.family = family
        form = PersonForm(request.POST, instance=person)
        if form.is_valid():
            UpdatePersonFromForm(person, form)
            return HttpResponseRedirect(reverse("entry_page"))
    else:
        person = Person()
        person.membertype = membertype
        if family.person_set.count() > 0:
            first_person = family.person_set.first()
            person.family = family
            person.zipcode = first_person.zipcode
            person.city = first_person.city
            person.streetname = first_person.streetname
            person.housenumber = first_person.housenumber
            person.floor = first_person.floor
            person.door = first_person.door
            person.placename = first_person.placename
            person.dawa_id = first_person.dawa_id
        form = PersonForm(instance=person)
    return render(
        request,
        "members/person_create_or_update.html",
        {
            "form": form,
            "person": person,
            "family": family,
            "membertype": membertype
        },
    )
Esempio n. 2
0
def PersonCreate(request, unique, membertype):
    family = get_object_or_404(Family, unique=unique)
    if request.method == 'POST':
        person = Person()
        person.membertype = membertype
        person.family = family
        form = PersonForm(request.POST, instance=person)
        if form.is_valid():
            UpdatePersonFromForm(person,form)
            return HttpResponseRedirect(reverse('family_detail', args=[family.unique]))
    else:
        person = Person()
        person.membertype = membertype
        if family.person_set.count() > 0 :
            first_person = family.person_set.first()
            person.family = family
            person.zipcode = first_person.zipcode
            person.city = first_person.city
            person.streetname = first_person.streetname
            person.housenumber = first_person.housenumber
            person.floor = first_person.floor
            person.door = first_person.door
            person.placename = first_person.placename
            person.dawa_id = first_person.dawa_id
        form = PersonForm(instance=person)
    return render(request, 'members/person_create_or_update.html', {'form': form, 'person' : person, 'family': family, 'membertype': membertype})
Esempio n. 3
0
def PersonCreate(request, unique, membertype):
    family = get_object_or_404(Family, unique=unique)
    if request.method == 'POST':
        person = Person()
        person.membertype = membertype
        person.family = family
        form = PersonForm(request.POST, instance=person)
        if form.is_valid():
            UpdatePersonFromForm(person,form)
            return HttpResponseRedirect(reverse('family_detail', args=[family.unique]))
    else:
        person = Person()
        person.membertype = membertype
        if family.person_set.count() > 0 :
            first_person = family.person_set.first()
            person.family = family
            person.zipcode = first_person.zipcode
            person.city = first_person.city
            person.streetname = first_person.streetname
            person.housenumber = first_person.housenumber
            person.floor = first_person.floor
            person.door = first_person.door
            person.placename = first_person.placename
            person.dawa_id = first_person.dawa_id
        form = PersonForm(instance=person)
    return render(request, 'members/person_create_or_update.html', {'form': form, 'person' : person, 'family': family, 'membertype': membertype})
Esempio n. 4
0
def PersonUpdate(request, unique, id):
    person = get_object_or_404(Person, pk=id)
    if person.family.unique != unique:
        raise Http404("Person eksisterer ikke")
    if request.method == 'POST':
        form = PersonForm(request.POST, instance=person)
        if form.is_valid():
            UpdatePersonFromForm(person,form)
            return HttpResponseRedirect(reverse('family_detail', args=[person.family.unique]))
    else:
        form = PersonForm(instance=person)
    return render(request, 'members/person_create_or_update.html', {'form': form, 'person': person})
Esempio n. 5
0
def PersonUpdate(request, unique, id):
    person = get_object_or_404(Person, pk=id)
    if person.family.unique != unique:
        raise Http404("Person eksisterer ikke")
    if request.method == 'POST':
        form = PersonForm(request.POST, instance=person)
        if form.is_valid():
            UpdatePersonFromForm(person,form)
            return HttpResponseRedirect(reverse('family_detail', args=[person.family.unique]))
    else:
        form = PersonForm(instance=person)
    return render(request, 'members/person_create_or_update.html', {'form': form, 'person': person})
def PersonUpdate(request, id):
    person = Person.objects.get(pk=id)
    persons_in_family = Person.objects.filter(family=user_to_person(request.user).family)
    if person in persons_in_family:
        if request.method == 'POST':
            form = PersonForm(request.POST, instance=person)
            if form.is_valid():
                UpdatePersonFromForm(person, form)
                return HttpResponseRedirect(reverse('family_detail'))
        else:
            form = PersonForm(instance=person)
        return render(request, 'members/person_create_or_update.html', {'form': form, 'person': person})
    else:
        return HttpResponse("Du kan kun redigere en person i din egen familie")
def PersonUpdate(request, id):
    person = Person.objects.get(pk=id)
    persons_in_family = Person.objects.filter(
        family=user_to_person(request.user).family
    )
    if person in persons_in_family:
        if request.method == "POST":
            form = PersonForm(request.POST, instance=person)
            if form.is_valid():
                UpdatePersonFromForm(person, form)
                return HttpResponseRedirect(reverse("family_detail"))
        else:
            form = PersonForm(instance=person)
        return render(
            request,
            "members/person_create_or_update.html",
            {"form": form, "person": person},
        )
    else:
        return HttpResponse("Du kan kun redigere en person i din egen familie")