def browseAnalysis(request, user): anals = mmodels.Analysis.objects.filter(owner=user, deleted=False) context = { 'user': user, 'list_header': 'Displaying Analysis:', 'list_to_disp': anals, 'action1': "showAnalysis", 'action2': "deleteAnalysis", 'action2_text': ' (delete) ', 'whenEmpty': ''.join([ "Analysis can only be performed on the CurveSet. ", "<a href='{url}'>Choose one</a>.".format( url=reverse('browseCurveSet', args=[user.id])), ]) } return voltpy_render(request=request, template_name='manager/browse.html', context=context)
def showCurveFile(request, user, file_id): try: cf = mmodels.CurveFile.objects.get(id=file_id, deleted=False) except ObjectDoesNotExist: raise VoltPyNotAllowed(user) if not cf.canBeReadBy(user): raise VoltPyNotAllowed(user) if (__debug__): print(cf) plotScr, plotDiv = generate_plot(request=request, user=user, plot_type='file', value_id=cf.id) context = { 'scripts': plotScr, 'mainPlot': plotDiv, 'user': user, 'curvefile_id': curvefile_id, 'form': form } return voltpy_render(request=request, template_name='manager/showFile.html', context=context)
def browseCurveFile(request, user): files = mmodels.CurveFile.objects.filter(owner=user, deleted=False) context = { 'user': user, 'list_header': 'Displaying Uploaded files:', 'list_to_disp': files, 'action1': "editCurveFile", 'action2': "deleteCurveFile", 'action2_text': ' (delete) ', 'whenEmpty': ''.join([ "You have no files uploaded. ", "<a href='{url}'>Upload one</a>.".format( url=reverse('upload', args=[user.id])), ]) } return voltpy_render(request=request, template_name='manager/browse.html', context=context)
def showAnalysis(request, user, analysis_id): try: an = mmodels.Analysis.objects.get(id=analysis_id) except ObjectDoesNotExist: an = None if not an.canBeReadBy(user): raise VoltPyNotAllowed(user) if an.completed == False: return HttpResponseRedirect(reverse('analyze', args=[user.id, an.id])) mm = mmm.MethodManager(user=user, analysis_id=analysis_id) info = mm.getInfo(request=request, user=user) plotScr, plotDiv = generate_plot(request=request, user=user, plot_type='curveset', value_id=an.curveSet.id) context = { 'scripts': plotScr, 'mainPlot': plotDiv, 'head': info.get('head', ''), 'user': user, 'analysis': an, 'text': info.get('body', '') } return voltpy_render(request=request, template_name='manager/showAnalysis.html', context=context)
def editCurveFile( request, user, file_id, ): if request.method == 'POST': form = mforms.AddAnalytesForm(user, "File", file_id, request.POST) if form.is_valid(): if (form.process(user) == True): return HttpResponseRedirect( reverse('browseCurveFile', args=[user.id])) else: form = mforms.AddAnalytesForm(user, "File", file_id) plotScr, plotDiv = generate_plot(request=request, user=user, plot_type='file', value_id=file_id) context = { 'scripts': plotScr, 'mainPlot': plotDiv, 'user': user, 'file_id': file_id, 'form': form, } return voltpy_render(request=request, template_name='manager/editFile.html', context=context)
def createCurveSet(request, user): """ from pyinstrument import Profiler profiler = Profiler(use_signal=False) profiler.start() """ if request.method == 'POST': form = mforms.SelectCurvesForCurveSetForm(user, request.POST) if form.is_valid(): if (form.process(user) == True): cs_id = form.curvesetid if cs_id and cs_id > -1: return HttpResponseRedirect( reverse('editCurveSet', args=[user.id, cs_id])) else: form = mforms.SelectCurvesForCurveSetForm(user) context = {'formHTML': form.drawByHand(request), 'user': user} ret = voltpy_render(request=request, template_name='manager/createCurveSet.html', context=context) """ profiler.stop() print(profiler.output_text()) """ return ret
def browseCurveSet(request, user): csets = mmodels.CurveSet.objects.filter(owner=user, deleted=False) if (__debug__): print(csets) context = { 'user': user, 'list_header': 'Displaying CurveSets:', 'list_to_disp': csets, 'action1': 'editCurveSet', 'action2': 'deleteCurveSet', 'action2_text': ' (delete) ', 'whenEmpty': ''.join([ "You have no CurveSets. ", "<a href='{url}'>Prepare one</a>.".format( url=reverse('createCurveSet', args=[user.id])), ]) } return voltpy_render(request=request, template_name='manager/browse.html', context=context)
def showProcessed(request, user, processing_id): try: cf = mmodels.Processing.objects.get(id=processing_id, owner=user) except ObjectDoesNotExist: cf = None context = { 'user': user, 'processing': processing_id, } return voltpy_render(request=request, template_name='manager/showAnalysis.html', context=context)
def upload(request, user): if request.method == 'POST': form = mforms.UploadFileForm(request.POST, request.FILES) if form.is_valid(): if (form.process(user, request) == True): file_id = form.file_id return HttpResponseRedirect( reverse('editCurveFile', args=[user.id, file_id])) else: form = mforms.UploadFileForm() context = {'form': form, 'user': user} return voltpy_render(request=request, template_name='manager/uploadFile.html', context=context)
def showCurveSet(request, user, curveset_id): try: cs = mmodels.CurveSet.objects.get(id=curveset_id) except ObjectDoesNotExist: raise VoltPyDoesNotExists() if not cs.canBeReadBy(user): raise VoltPyNotAllowed(user) plotScr, plotDiv = generate_plot(request=request, user=user, plot_type='curveset', value_id=cs.id) context = { 'scripts': plotScr, 'mainPlot': plotDiv, 'user': user, 'curveset_id': curveset_id, } return voltpy_render(request=request, template_name='manager/showCurveSet.html', context=context)
def editCurveSet(request, user, curveset_id): try: cs = mmodels.CurveSet.objects.get(id=curveset_id) except ObjectDoesNotExist: raise VoltPyDoesNotExists('Cannot be accessed.') if not cs.canBeUpdatedBy(user): raise VoltPyNotAllowed(user) txt = '' if (cs.locked): txt = "This curveset is used by analysis method and cannot be modified." mm = mmm.MethodManager(user=user, curveset_id=curveset_id) if request.method == 'POST': if ('startAnalyze' in request.POST): formGenerate = mm.getAnalysisSelectionForm(request.POST) if (formGenerate.is_valid()): analyzeid = formGenerate.process(user, cs) return HttpResponseRedirect( reverse('analyze', args=[user.id, analyzeid])) else: formGenerate = mm.getAnalysisSelectionForm() if (not cs.locked and 'startProcessing' in request.POST): formProc = mm.getProcessingSelectionForm(request.POST) if (formProc.is_valid()): procid = formProc.process(user, cs) return HttpResponseRedirect( reverse('process', args=[user.id, procid])) else: formProc = mm.getProcessingSelectionForm(disabled=cs.locked) if ('submitFormAnalyte' in request.POST): formAnalyte = mforms.AddAnalytesForm(user, "CurveSet", curveset_id, request.POST) if formAnalyte.is_valid(): if (formAnalyte.process(user) == True): return HttpResponseRedirect( reverse('showCurveSet', args=[user.id, curveset_id])) else: formAnalyte = mforms.AddAnalytesForm(user, "CurveSet", curveset_id) else: formAnalyte = mforms.AddAnalytesForm(user, "CurveSet", curveset_id) formGenerate = mm.getAnalysisSelectionForm() formProc = mm.getProcessingSelectionForm(disabled=cs.locked) try: cs = mmodels.CurveSet.objects.get(id=curveset_id) if not cs.canBeReadBy(user): raise VoltPyNotAllowed(user) except ObjectDoesNotExist: raise VoltPyNotAllowed(user) cal_disp = "" plotScr, plotDiv = generate_plot(request=request, user=user, plot_type='curveset', value_id=cs.id) context = { 'scripts': plotScr + formProc.getJS(request) + formGenerate.getJS(request), 'mainPlot': plotDiv, 'formAnalyte': formAnalyte, 'startAnalyze': formGenerate, 'startProcessing': formProc, 'user': user, 'curveset_id': curveset_id, 'cal_disp': cal_disp } return voltpy_render(request=request, template_name='manager/editCurveSet.html', context=context)
def index(request, user): context = {'user': user} return voltpy_render(request=request, template_name='manager/index.html', context=context)
def indexNoUser(request): context = {'user': None} return voltpy_render(request=request, template_name='manager/index.html', context=context)
def getStepContent(self, request, user): """ Provides contents of processing step of methods. """ if self.__model.deleted: add_notification(request, 'Procedure delted.', 0) return HttpResponseRedirect(self.__model.dataset.getUrl()) if any([ self.__method.has_next is False, self.__method.step is None ]): return HttpResponseRedirect(self.__model.getUrl()) if not self.isMethodSelected(): return HttpResponseRedirect(reverse("browseDataset")) stepText = { 'head': '', 'body': 'No text' } if self.__method.step: stepText = self.__method.getStepContent( request=request, user=user ) step_numInfo = '{0} out of {1}'.format( self.__model.active_step_num+1, len(self.__method._steps) ) plotScr, plotDiv, butDiv = generate_plot( request=request, user=user, to_plot=self.__model.dataset, vtype=self.__method.type(), vid=self.__model.id, interactionName=self.__method.step['class'].plot_interaction, add=self.__method.addToMainPlot() ) context = { 'scripts': '\n'.join([ plotScr, stepText.get('head', '') ]), 'main_plot': plotDiv, 'main_plot_buttons': butDiv, 'method_content': ''.join([ '<fieldset class="mt_rest"><legend class="mt_name">Step</legend>%s</fieldset>' % step_numInfo, '<fieldset class="mt_rest"><legend class="mt_name">Description</legend>%s</fieldset>' % stepText.get('desc', ''), '<div class="mt_rest">%s</div>' % stepText.get('body', ''), ]), 'user': user, 'model': self.__model, 'dataset_id': self.__model.dataset.id, } return voltpy_render( request=request, template_name='manager/method.html', context=context, )