27 lines
919 B
Python
27 lines
919 B
Python
from django.forms import ModelForm
|
|
from django import forms
|
|
|
|
from apps.synthea.models import Synthea
|
|
|
|
from .lib.utils import available_states, available_modules
|
|
|
|
class SyntheaForm(ModelForm):
|
|
|
|
class Meta:
|
|
model = Synthea
|
|
fields = ['state', 'population', 'gender', 'age', 'module']
|
|
|
|
# This is loaded only once during startup. So changing the state data will not be picked up after a restart
|
|
state_options = [('','Any')]
|
|
for item in available_states():
|
|
state_options.append((item,item))
|
|
|
|
module_options = [('','Any')]
|
|
for item in available_modules():
|
|
module_options.append((item['module'],item['name']))
|
|
|
|
widgets = {
|
|
'state': forms.Select(choices=state_options),
|
|
'gender': forms.Select(choices=[('','Any'),('m','Male'),('f','Female')]),
|
|
'module': forms.Select(choices=module_options)
|
|
} |