.
This commit is contained in:
+20
-15
@@ -17,18 +17,21 @@ from atlas.models import (
|
||||
from anatomy.models import Modality
|
||||
|
||||
from generic.models import Examination, Condition, Sign
|
||||
#from generic.models import Examination, Site, Condition, Sign
|
||||
|
||||
# from generic.models import Examination, Site, Condition, Sign
|
||||
|
||||
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||
from django.forms.widgets import RadioSelect, TextInput, Textarea
|
||||
|
||||
from tinymce.widgets import TinyMCE
|
||||
|
||||
|
||||
class ExaminationForm(ModelForm):
|
||||
class Meta:
|
||||
model = Examination
|
||||
fields = ["examination"]
|
||||
|
||||
|
||||
class SeriesForm(ModelForm):
|
||||
class Media:
|
||||
# Django also includes a few javascript files necessary
|
||||
@@ -43,10 +46,10 @@ class SeriesForm(ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SeriesForm, self).__init__(*args, **kwargs)
|
||||
#self.fields["examination"] = ModelChoiceField(
|
||||
# self.fields["examination"] = ModelChoiceField(
|
||||
# queryset=Examination.objects.all(),
|
||||
# widget=FilteredSelectMultiple(verbose_name="Examination", is_stacked=False),
|
||||
#)
|
||||
# )
|
||||
|
||||
self.fields["modality"] = ModelChoiceField(
|
||||
required=True,
|
||||
@@ -62,7 +65,7 @@ class SeriesForm(ModelForm):
|
||||
|
||||
class AtlasForm(ModelForm):
|
||||
|
||||
#exams = ModelMultipleChoiceField(required=False, queryset=Exam.objects.all(),widget=FilteredSelectMultiple(verbose_name="Exams", is_stacked=False))
|
||||
# exams = ModelMultipleChoiceField(required=False, queryset=Exam.objects.all(),widget=FilteredSelectMultiple(verbose_name="Exams", is_stacked=False))
|
||||
|
||||
class Media:
|
||||
# Django also includes a few javascript files necessary
|
||||
@@ -76,7 +79,9 @@ class AtlasForm(ModelForm):
|
||||
js = ["jsi18n.js", "tesseract.min.js"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop('user') # To get request.user. Do not use kwargs.pop('user', None) due to potential security hole
|
||||
self.user = kwargs.pop(
|
||||
"user"
|
||||
) # To get request.user. Do not use kwargs.pop('user', None) due to potential security hole
|
||||
if kwargs.get("instance"):
|
||||
# We get the 'initial' keyword argument or initialize it
|
||||
# as a dict if it didn't exist.
|
||||
@@ -89,14 +94,13 @@ class AtlasForm(ModelForm):
|
||||
|
||||
super(AtlasForm, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class Meta:
|
||||
model = Case
|
||||
# fields = ['due_back']
|
||||
# fields = '__all__'
|
||||
fields = [
|
||||
#"examination",
|
||||
#"site",
|
||||
# "examination",
|
||||
# "site",
|
||||
"title",
|
||||
"subspecialty",
|
||||
"description",
|
||||
@@ -111,10 +115,10 @@ class AtlasForm(ModelForm):
|
||||
# "normal": RadioSelect(
|
||||
# choices=[(True, 'Yes'),
|
||||
# (False, 'No')])
|
||||
"findings" : TinyMCE(attrs={'cols': 80, 'rows': 20}),
|
||||
"mark_scheme" : TinyMCE(attrs={'cols': 80, 'rows': 30}),
|
||||
"description" : Textarea(attrs={'cols': 80, 'rows': 5}),
|
||||
"history" : Textarea(attrs={'cols': 80, 'rows': 5}),
|
||||
"findings": TinyMCE(attrs={"cols": 80, "rows": 20}),
|
||||
"mark_scheme": TinyMCE(attrs={"cols": 80, "rows": 30}),
|
||||
"description": Textarea(attrs={"cols": 80, "rows": 5}),
|
||||
"history": Textarea(attrs={"cols": 80, "rows": 5}),
|
||||
}
|
||||
|
||||
def save(self, commit=True):
|
||||
@@ -126,8 +130,8 @@ class AtlasForm(ModelForm):
|
||||
|
||||
def save_m2m():
|
||||
old_save_m2m()
|
||||
#instance.exams.clear()
|
||||
#for exam in self.cleaned_data["exams"]:
|
||||
# instance.exams.clear()
|
||||
# for exam in self.cleaned_data["exams"]:
|
||||
# # We need the id here
|
||||
# instance.exams.add(exam.pk)
|
||||
|
||||
@@ -140,6 +144,7 @@ class AtlasForm(ModelForm):
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
SeriesFormSet = inlineformset_factory(
|
||||
Case,
|
||||
Series.case.through,
|
||||
@@ -159,4 +164,4 @@ SeriesImageFormSet = inlineformset_factory(
|
||||
extra=0,
|
||||
max_num=2000,
|
||||
field_classes="testing",
|
||||
)
|
||||
)
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
{% extends "atlas/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<a href="{% url 'atlas:series_update' pk=series.pk %}" title="Edit the Series">Edit</a>
|
||||
{% if request.user.is_superuser %}
|
||||
<a href="{% url 'admin:atlas_series_change' series.id %}" title="Edit the Series using the admin interface">Admin Edit</a>
|
||||
{% endif %}
|
||||
<a href="{% url 'atlas:series_update' pk=series.pk %}" title="Edit the Series">Edit</a>
|
||||
{% if request.user.is_superuser %}
|
||||
<a href="{% url 'admin:atlas_series_change' series.id %}" title="Edit the Series using the admin interface">Admin Edit</a>
|
||||
{% endif %}
|
||||
|
||||
{% include 'atlas/series_viewer.html' %}
|
||||
{% endblock %}
|
||||
{% include 'atlas/series_viewer.html' %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user