64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
from django import forms
|
|
from django.contrib.admin import widgets
|
|
from django.forms import (
|
|
BaseInlineFormSet,
|
|
Form,
|
|
HiddenInput,
|
|
ModelForm,
|
|
ModelMultipleChoiceField,
|
|
ModelChoiceField,
|
|
ChoiceField,
|
|
CharField,
|
|
ValidationError,
|
|
modelformset_factory,
|
|
CheckboxSelectMultiple,
|
|
)
|
|
|
|
from rcr.models import Item, RadiologyCategory, OncologyCategory, Level
|
|
from django.contrib.auth.models import User
|
|
from atlas.models import Condition
|
|
|
|
|
|
class ItemForm(ModelForm):
|
|
|
|
#radiology_category = ModelMultipleChoiceField(queryset=RadiologyCategory.objects.all())
|
|
#oncology_category = ModelMultipleChoiceField(queryset=OncologyCategory.objects.all())
|
|
radiology_condition = ModelMultipleChoiceField(queryset=Condition.objects.filter(rcr_curriculum=True), required=False)
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
model = Item
|
|
exclude = [
|
|
"rcr_platform_id",
|
|
"name",
|
|
"description",
|
|
"content_type",
|
|
"created_on",
|
|
"number_of_items",
|
|
"specialty",
|
|
"access_count",
|
|
"targeted_to_group",
|
|
"assessed_by",
|
|
"assessed_date",
|
|
"assigned_to_radiology",
|
|
"assigned_to_oncology",
|
|
"review_link",
|
|
"review_link_password",
|
|
]
|
|
# fields = ["category", "level"]
|
|
widgets = {
|
|
"radiology_categories": forms.SelectMultiple(attrs={"size": 12}),
|
|
#"radiology_condition": forms.SelectMultiple(attrs={"size": 12}),
|
|
#"oncology_category": CheckboxSelectMultiple(),
|
|
#"level": CheckboxSelectMultiple(),
|
|
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(ItemForm, self).__init__(*args, **kwargs)
|
|
self.fields['radiology_condition'].label_from_instance = lambda obj: "%s" % obj.get_with_subspecialty()
|
|
|
|
class AssessorAssignmentForm(Form):
|
|
items = ModelMultipleChoiceField(queryset=Item.objects.all(), widget=forms.SelectMultiple(attrs={'size': 20})) |