Temp fix for loading too many people for father/mother on Family edit page. Need to have an auto-complete solution

svn: r19836
This commit is contained in:
Doug Blank 2012-06-13 01:42:45 +00:00
parent e00296fa98
commit f6d6b9c990
2 changed files with 19 additions and 0 deletions

View File

@ -127,6 +127,15 @@ class FamilyForm(forms.ModelForm):
model = Family
exclude = ["handle"]
def __init__(self, *args, **kwargs):
super(FamilyForm, self).__init__(*args, **kwargs)
self.fields['father'].queryset = Person.objects.filter(
gender_type=get_type_from_name(GenderType, "Male")) \
.order_by("name__surname__surname", "name__first_name")
self.fields['mother'].queryset = Person.objects.filter(
gender_type=get_type_from_name(GenderType, "Female")) \
.order_by("name__surname__surname", "name__first_name")
class EventForm(forms.ModelForm):
class Meta:
model = Event

View File

@ -42,6 +42,16 @@ from webapp.grampsdb.profile import Profile
#
#---------------------------------------------------------------------------
def get_type_from_name(the_type, name):
"""
Gets the type for a given name.
>>> get_type_from_name(GenderType, "Female")
<GenderType: Female>
>>> get_type_from_name(GenderType, "Male")
<GenderType: Male>
"""
return the_type.objects.get(name=name)
def get_type(the_type, data, get_or_create=False):
"""
Gets the default row for a given Type and data. Data is