fix: Only allow users to create rels as source

There is now no field for users to define the source of a relationship
The source is always the person in the URL
And only that user or staff can access the form
This commit is contained in:
James Graham
2020-08-14 17:38:22 +01:00
parent 6435ec69a1
commit a94db2713e
4 changed files with 50 additions and 39 deletions

View File

@@ -8,7 +8,7 @@ from django import forms
from django.forms.widgets import SelectDateWidget
from django.utils import timezone
from django_select2.forms import Select2Widget, Select2MultipleWidget
from django_select2.forms import ModelSelect2Widget, Select2Widget, Select2MultipleWidget
from . import models
@@ -60,6 +60,12 @@ class PersonForm(forms.ModelForm):
years=get_date_year_range())
class RelationshipForm(forms.Form):
target = forms.ModelChoiceField(
models.Person.objects.all(),
widget=ModelSelect2Widget(search_fields=['name__icontains']))
class DynamicAnswerSetBase(forms.Form):
field_class = forms.ModelChoiceField
field_widget = None