.
This commit is contained in:
+11
-3
@@ -45,6 +45,14 @@ class SeriesForm(ModelForm):
|
|||||||
js = ["jsi18n.js", "tesseract.min.js"]
|
js = ["jsi18n.js", "tesseract.min.js"]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
if kwargs.get("instance"):
|
||||||
|
# We get the 'initial' keyword argument or initialize it
|
||||||
|
# as a dict if it didn't exist.
|
||||||
|
initial = kwargs.setdefault("initial", {})
|
||||||
|
# The widget for a ModelMultipleChoiceField expects
|
||||||
|
# a list of primary key for the selected data.
|
||||||
|
initial["long"] = [t.pk for t in kwargs["instance"].exams.all()]
|
||||||
|
|
||||||
super(SeriesForm, self).__init__(*args, **kwargs)
|
super(SeriesForm, self).__init__(*args, **kwargs)
|
||||||
# self.fields["examination"] = ModelChoiceField(
|
# self.fields["examination"] = ModelChoiceField(
|
||||||
# queryset=Examination.objects.all(),
|
# queryset=Examination.objects.all(),
|
||||||
@@ -71,7 +79,7 @@ class SeriesForm(ModelForm):
|
|||||||
exclude = ["author"]
|
exclude = ["author"]
|
||||||
|
|
||||||
|
|
||||||
class AtlasForm(ModelForm):
|
class CaseForm(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))
|
||||||
|
|
||||||
@@ -96,11 +104,11 @@ class AtlasForm(ModelForm):
|
|||||||
initial = kwargs.setdefault("initial", {})
|
initial = kwargs.setdefault("initial", {})
|
||||||
# The widget for a ModelMultipleChoiceField expects
|
# The widget for a ModelMultipleChoiceField expects
|
||||||
# a list of primary key for the selected data.
|
# a list of primary key for the selected data.
|
||||||
#initial["exams"] = [t.pk for t in kwargs["instance"].exams.all()]
|
# initial["exams"] = [t.pk for t in kwargs["instance"].exams.all()]
|
||||||
|
|
||||||
ModelForm.__init__(self, *args, **kwargs)
|
ModelForm.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
super(AtlasForm, self).__init__(*args, **kwargs)
|
super(CaseForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Case
|
model = Case
|
||||||
|
|||||||
+4
-8
@@ -25,7 +25,7 @@ from django.http import Http404, JsonResponse
|
|||||||
from django.http import HttpResponseRedirect, HttpResponse
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
|
|
||||||
from .forms import (
|
from .forms import (
|
||||||
AtlasForm,
|
CaseForm,
|
||||||
SeriesForm,
|
SeriesForm,
|
||||||
SeriesImageFormSet,
|
SeriesImageFormSet,
|
||||||
SeriesFormSet,
|
SeriesFormSet,
|
||||||
@@ -138,7 +138,6 @@ def author_list(request):
|
|||||||
return render(request, "atlas/author_list.html", {"authors": authors})
|
return render(request, "atlas/author_list.html", {"authors": authors})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AtlasDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
class AtlasDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
||||||
model = Case
|
model = Case
|
||||||
success_url = reverse_lazy("atlas:case_view")
|
success_url = reverse_lazy("atlas:case_view")
|
||||||
@@ -156,7 +155,7 @@ def case_clone(request, pk):
|
|||||||
new_item.pk = None # autogen a new pk (item_id)
|
new_item.pk = None # autogen a new pk (item_id)
|
||||||
# new_item.name = "Copy of " + new_item.name #need to change uniques
|
# new_item.name = "Copy of " + new_item.name #need to change uniques
|
||||||
|
|
||||||
form = AtlasForm(request.POST or None, instance=new_item)
|
form = CaseForm(request.POST or None, instance=new_item)
|
||||||
|
|
||||||
series_formset = SeriesFormSet()
|
series_formset = SeriesFormSet()
|
||||||
|
|
||||||
@@ -269,7 +268,7 @@ class SeriesUpdate(
|
|||||||
|
|
||||||
class AtlasCreateBase(RevisionMixin, LoginRequiredMixin, CreateView):
|
class AtlasCreateBase(RevisionMixin, LoginRequiredMixin, CreateView):
|
||||||
model = Case
|
model = Case
|
||||||
form_class = AtlasForm
|
form_class = CaseForm
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super(AtlasCreateBase, self).get_form_kwargs()
|
kwargs = super(AtlasCreateBase, self).get_form_kwargs()
|
||||||
@@ -326,12 +325,11 @@ class AtlasCreate(AtlasCreateBase):
|
|||||||
return self.initial
|
return self.initial
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AtlasUpdate(
|
class AtlasUpdate(
|
||||||
RevisionMixin, LoginRequiredMixin, AuthorOrCheckerRequiredMixin, UpdateView
|
RevisionMixin, LoginRequiredMixin, AuthorOrCheckerRequiredMixin, UpdateView
|
||||||
):
|
):
|
||||||
model = Case
|
model = Case
|
||||||
form_class = AtlasForm
|
form_class = CaseForm
|
||||||
|
|
||||||
# fields = '__all__'
|
# fields = '__all__'
|
||||||
# #fields = [ 'condition' ]
|
# #fields = [ 'condition' ]
|
||||||
@@ -503,7 +501,6 @@ def series_order_upload_filename(request, pk):
|
|||||||
return redirect("atlas:series_detail", pk=pk)
|
return redirect("atlas:series_detail", pk=pk)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SeriesImagesZipView(SuperuserRequiredMixin, BaseZipView):
|
class SeriesImagesZipView(SuperuserRequiredMixin, BaseZipView):
|
||||||
"""Download all images from an image series"""
|
"""Download all images from an image series"""
|
||||||
|
|
||||||
@@ -511,4 +508,3 @@ class SeriesImagesZipView(SuperuserRequiredMixin, BaseZipView):
|
|||||||
series = Series.objects.get(pk=self.kwargs["pk"])
|
series = Series.objects.get(pk=self.kwargs["pk"])
|
||||||
|
|
||||||
return [i.image.file for i in series.images.all()]
|
return [i.image.file for i in series.images.all()]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user