Move live provider cbv to biomon cbv file.
This commit is contained in:
parent
cde9238fe1
commit
76146bed24
|
@ -19,11 +19,18 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
'''
|
||||
|
||||
import logging
|
||||
|
||||
from functools import partial
|
||||
|
||||
from django.views.generic import base, detail
|
||||
from django.forms import ModelForm
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.http import JsonResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
|
||||
permission_required = partial(permission_required, raise_exception=True)
|
||||
|
||||
|
||||
class AppTemplateFirstMixin(object):
|
||||
|
@ -294,3 +301,23 @@ class AjaxableResponseMixin(object):
|
|||
return JsonResponse(data)
|
||||
else:
|
||||
return response
|
||||
|
||||
|
||||
class LoggerMixin(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.logger = logging.getLogger(__name__)
|
||||
super(LoggerMixin, *args, **kwargs)
|
||||
|
||||
|
||||
class ProtectedView(base.View):
|
||||
@method_decorator(permission_required('biomon.delete_patient'))
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(ProtectedView, self).dispatch(*args, **kwargs)
|
||||
|
||||
|
||||
class BasicView(LoggerMixin, ProtectedView):
|
||||
pass
|
||||
|
||||
|
||||
class BasicDetailView(BasicView, detail.DetailView):
|
||||
pass
|
||||
|
|
|
@ -24,7 +24,6 @@ import urllib
|
|||
import urllib2
|
||||
import urlparse
|
||||
import json
|
||||
import logging
|
||||
import copy
|
||||
import dateutil.parser
|
||||
from datetime import datetime
|
||||
|
@ -32,23 +31,19 @@ from datetime import datetime
|
|||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
from django.views.generic import DetailView, View
|
||||
from django.http import Http404, HttpResponse
|
||||
from django.conf import settings
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from functools import partial
|
||||
|
||||
import matplotlib
|
||||
from matplotlib.backends.backend_agg import FigureCanvasAgg
|
||||
|
||||
from .. import cbv
|
||||
from .. import whisper_backend
|
||||
from .. import models
|
||||
from . import graphite_custom
|
||||
from ..medibot import models as medibot_models
|
||||
from ..medibot import definitions as definition_utils
|
||||
|
||||
permission_required = partial(permission_required, raise_exception=True)
|
||||
|
||||
CRITICAL_COLOR = "FF0000"
|
||||
DANGEROUS_COLOR = "FFA500"
|
||||
|
@ -71,23 +66,8 @@ def get_isodate_parameter(request, name, default):
|
|||
pass
|
||||
return default
|
||||
|
||||
class LoggerMixin(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.logger = logging.getLogger(__name__)
|
||||
super(LoggerMixin, *args, **kwargs)
|
||||
|
||||
|
||||
class ProtectedView(View):
|
||||
@method_decorator(permission_required('biomon.delete_patient'))
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(ProtectedView, self).dispatch(*args, **kwargs)
|
||||
|
||||
|
||||
class BasicDetailView(LoggerMixin, ProtectedView, DetailView):
|
||||
pass
|
||||
|
||||
|
||||
class RenderView(BasicDetailView):
|
||||
class RenderView(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -164,7 +144,7 @@ class RenderView(BasicDetailView):
|
|||
raise Http404('No graphite host specified')
|
||||
|
||||
|
||||
class InstantsView(BasicDetailView):
|
||||
class InstantsView(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -191,7 +171,7 @@ class InstantsView(BasicDetailView):
|
|||
return HttpResponse(json.dumps(values), content_type='application/json')
|
||||
|
||||
|
||||
class MeansView(BasicDetailView):
|
||||
class MeansView(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -223,7 +203,7 @@ def get_ax():
|
|||
return fig, ax
|
||||
|
||||
|
||||
class HistogramView(BasicDetailView):
|
||||
class HistogramView(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -253,7 +233,7 @@ class HistogramView(BasicDetailView):
|
|||
return response
|
||||
|
||||
|
||||
class MinMaxView(BasicDetailView):
|
||||
class MinMaxView(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -270,7 +250,7 @@ class MinMaxView(BasicDetailView):
|
|||
return HttpResponse(json.dumps(values), content_type='application/json')
|
||||
|
||||
|
||||
class PatientEpisodesOpened(BasicDetailView):
|
||||
class PatientEpisodesOpened(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -285,7 +265,7 @@ class PatientEpisodesOpened(BasicDetailView):
|
|||
content_type='application/json')
|
||||
|
||||
|
||||
class PatientEpisodesClosed(BasicDetailView):
|
||||
class PatientEpisodesClosed(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -302,7 +282,7 @@ class PatientEpisodesClosed(BasicDetailView):
|
|||
content_type='application/json')
|
||||
|
||||
|
||||
class PatientNextEpisode(BasicDetailView):
|
||||
class PatientNextEpisode(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -321,7 +301,7 @@ class PatientNextEpisode(BasicDetailView):
|
|||
content_type='application/json')
|
||||
|
||||
|
||||
class PatientPreviousEpisode(BasicDetailView):
|
||||
class PatientPreviousEpisode(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -340,7 +320,7 @@ class PatientPreviousEpisode(BasicDetailView):
|
|||
content_type='application/json')
|
||||
|
||||
|
||||
class PatientEpisodesStatsView(BasicDetailView):
|
||||
class PatientEpisodesStatsView(cbv.BasicDetailView):
|
||||
model = models.Patient
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
|
Reference in New Issue