merge rapids commit
This commit is contained in:
Executable
+102
@@ -0,0 +1,102 @@
|
||||
from django.forms import ModelForm, ModelMultipleChoiceField, ModelChoiceField, ChoiceField
|
||||
from django.forms import inlineformset_factory
|
||||
|
||||
from rapids.models import Abnormality, Examination, Note, Rapid, RapidCreationDefault, RapidImage, Region
|
||||
|
||||
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||
from django.forms.widgets import RadioSelect
|
||||
|
||||
|
||||
class ExaminationForm(ModelForm):
|
||||
class Meta:
|
||||
model = Examination
|
||||
fields = ['examination']
|
||||
|
||||
|
||||
class NoteForm(ModelForm):
|
||||
class Meta:
|
||||
model = Note
|
||||
fields = ['note']
|
||||
|
||||
|
||||
class RegionForm(ModelForm):
|
||||
class Meta:
|
||||
model = Region
|
||||
fields = ['name']
|
||||
|
||||
|
||||
class AbnormalityForm(ModelForm):
|
||||
class Meta:
|
||||
model = Abnormality
|
||||
fields = ['name']
|
||||
|
||||
|
||||
class RapidCreationDefaultForm(ModelForm):
|
||||
class Meta:
|
||||
model = RapidCreationDefault
|
||||
fields = ['site']
|
||||
exclude = ["author"]
|
||||
|
||||
|
||||
class RapidForm(ModelForm):
|
||||
class Media:
|
||||
# Django also includes a few javascript files necessary
|
||||
# for the operation of this form element. You need to
|
||||
# include <script src="/admin/jsi18n"></script>
|
||||
# in the template.
|
||||
css = {
|
||||
'all': ['css/widgets.css'],
|
||||
}
|
||||
# Adding this javascript is crucial
|
||||
js = ['jsi18n.js', "tesseract.min.js"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RapidForm, self).__init__(*args, **kwargs)
|
||||
#self.fields['question'].widget.attrs = {'class': 'question-form', 'rows': 10, 'cols': 100}
|
||||
#self.fields['feedback'].widget.attrs = {'class': 'feedback-form', 'rows': 10, 'cols': 100}
|
||||
self.fields['abnormality'] = ModelMultipleChoiceField(
|
||||
required=False,
|
||||
queryset=Abnormality.objects.all(),
|
||||
widget=FilteredSelectMultiple(verbose_name="Abnormality",
|
||||
is_stacked=False))
|
||||
|
||||
self.fields['region'] = ModelMultipleChoiceField(
|
||||
required=False,
|
||||
queryset=Region.objects.all(),
|
||||
widget=FilteredSelectMultiple(verbose_name="Region",
|
||||
is_stacked=False))
|
||||
|
||||
self.fields['examination'] = ModelMultipleChoiceField(
|
||||
queryset=Examination.objects.all(),
|
||||
widget=FilteredSelectMultiple(verbose_name="Examination",
|
||||
is_stacked=False))
|
||||
|
||||
self.fields['laterality'] = ChoiceField(
|
||||
choices=Rapid.LATERALITY_CHOICES,
|
||||
required=True,
|
||||
widget=RadioSelect())
|
||||
|
||||
class Meta:
|
||||
model = Rapid
|
||||
#fields = ['due_back']
|
||||
#fields = '__all__'
|
||||
fields = [
|
||||
"normal", "abnormality", "region", "laterality", "examination",
|
||||
"condition", "sign", "site", "feedback"
|
||||
]
|
||||
#fields = ['question', 'feedback', 'subspecialty', 'references']
|
||||
widgets = {
|
||||
# "normal": RadioSelect(
|
||||
# choices=[(True, 'Yes'),
|
||||
# (False, 'No')])
|
||||
}
|
||||
|
||||
|
||||
ImageFormSet = inlineformset_factory(Rapid,
|
||||
RapidImage,
|
||||
fields=['image', 'feedback_image'],
|
||||
exclude=[],
|
||||
can_delete=True,
|
||||
extra=4,
|
||||
max_num=10,
|
||||
field_classes="testing")
|
||||
Reference in New Issue
Block a user