summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Ates <mates@entrouvert.com>2016-01-22 15:00:11 (GMT)
committerMikaël Ates <mates@entrouvert.com>2016-01-22 15:00:11 (GMT)
commit66562bf9b7151fc6b17b437e6b1071c20b027906 (patch)
tree4c0a5677984eaf2c4abaa411c929104db8d53368
parent24d09bd5fa2fc0458af0b35292484bcb96875238 (diff)
downloadbiomon-66562bf9b7151fc6b17b437e6b1071c20b027906.zip
biomon-66562bf9b7151fc6b17b437e6b1071c20b027906.tar.gz
biomon-66562bf9b7151fc6b17b437e6b1071c20b027906.tar.bz2
Add cbv for managing Reader model.
-rw-r--r--src/biomon/views.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/biomon/views.py b/src/biomon/views.py
index 109e8cb..e175fba 100644
--- a/src/biomon/views.py
+++ b/src/biomon/views.py
@@ -292,3 +292,60 @@ class RoomNumberToPid(View):
except models.Patient.DoesNotExist:
pass
return JsonResponse(infos)
+
+
+class ReaderList(ListView):
+ model = models.Reader
+
+ def get_context_data(self, **kwargs):
+ context = super(ReaderList, self).get_context_data(**kwargs)
+ try:
+ context['lastpatient'] = models.Patient.objects.get(
+ pk=int(self.request.COOKIES.get(LAST_PATIENT_COOKIE)))
+ except:
+ pass
+ return context
+
+
+class ReaderCreate(CreateView):
+ model = models.Reader
+ success_url = reverse_lazy('reader_list')
+ fields = ['ip_address', 'management_port', 'room']
+
+ def get_context_data(self, **kwargs):
+ context = super(ReaderCreate, self).get_context_data(**kwargs)
+ try:
+ context['lastpatient'] = models.Patient.objects.get(
+ pk=int(self.request.COOKIES.get(LAST_PATIENT_COOKIE)))
+ except:
+ pass
+ return context
+
+
+class ReaderUpdate(UpdateView):
+ model = models.Reader
+ success_url = reverse_lazy('reader_list')
+ fields = ['ip_address', 'management_port', 'room']
+
+ def get_context_data(self, **kwargs):
+ context = super(ReaderUpdate, self).get_context_data(**kwargs)
+ try:
+ context['lastpatient'] = models.Patient.objects.get(
+ pk=int(self.request.COOKIES.get(LAST_PATIENT_COOKIE)))
+ except:
+ pass
+ return context
+
+
+class ReaderDelete(DeleteView):
+ model = models.Reader
+ success_url = reverse_lazy('reader_list')
+
+ def get_context_data(self, **kwargs):
+ context = super(ReaderDelete, self).get_context_data(**kwargs)
+ try:
+ context['lastpatient'] = models.Patient.objects.get(
+ pk=int(self.request.COOKIES.get(LAST_PATIENT_COOKIE)))
+ except:
+ pass
+ return context