コード例 #1
0
 def process(self, user, curveset):
     if self.type == 'processing':
         if self.cleaned_data.get('method') in self.methods:
             a = mmodels.Processing(
                 owner=user,
                 curveSet=curveset,
                 method=self.cleaned_data.get('method'),
                 name="",
                 step=0,
                 deleted=False,
                 completed=False)
             a.save()
             return a.id
         else:
             return None
     elif self.type == 'analysis':
         if self.cleaned_data.get('method') in self.methods:
             a = mmodels.Analysis(
                 owner=user,
                 curveSet=curveset,
                 method=self.cleaned_data.get('method'),
                 name="",
                 step=0,
                 deleted=False,
                 completed=False)
             a.save()
             curveset.locked = True  #CurveSet cannot be changed when used by Analysis method.
             curveset.save()
             return a.id
         else:
             return None
コード例 #2
0
ファイル: methodmanager.py プロジェクト: efce/voltPy
 def process(self, user, dataset):
     if self.type == 'processing':
         mname = self.cleaned_data.get('method', None)
         if mname in self.methods:
             a = mmodels.Processing(
                 owner=user,
                 dataset=dataset,
                 method=mname,
                 method_display_name=self.methods[mname].__str__(),
                 name='',
                 active_step_num=0,
                 deleted=False,
                 completed=False
             )
             a.save()
             dataset.prepareUndo(processingObject=a)
             return a.id
         return None
     elif self.type == 'analysis':
         mname = self.cleaned_data.get('method', None)
         if mname in self.methods:
             a = mmodels.Analysis(
                 owner=user,
                 dataset=dataset,
                 method=mname,
                 method_display_name=self.methods[mname].__str__(),
                 name='',
                 active_step_num=0,
                 deleted=False,
                 completed=False
             )
             a.save()
             dataset.save()
             return a.id
     return None
コード例 #3
0
    def test_methods_usage(self):
        # TODO: This requires better test, using Client model
        return
        manager.helpers.functions.get_user = lambda: self.user
        p = mmodels.Processing(owner=self.user,
                               dataset=self.dataset,
                               date=timezone.now(),
                               name='PROC',
                               method='TestMethod',
                               active_step_num=0,
                               deleted=False,
                               completed=False)
        p.save()
        mema = mm.MethodManager(user=self.user, processing_id=p.id)

        class req:
            method = 'POST'
            POST = {}

            def __init__(self):
                self.POST['query'] = 'methodmanager'

        request = req()
        mema.process(request=request, user=self.user)
        p = mmodels.Processing.objects.get(id=p.id)
        self.assertEqual(p.custom_data['FINALIZED'], self.user.id)
コード例 #4
0
ファイル: methodmanager.py プロジェクト: efce/voltPy
 def process(self, user, dataset):
     self._checkDataset(dataset)
     if self.type == 'processing':
         mname = self.cleaned_data.get('method', None)
         if mname in self.methods:
             if self.methods[mname].errors:
                 errors = '\n'.join([str(x) for x in self.methods[mname].errors])
                 raise VoltPyFailed('Data does not meets requirements for selected method: %s' % errors)
             a = mmodels.Processing(
                 owner=user,
                 dataset=dataset,
                 method=mname,
                 method_display_name=self.methods[mname].__str__(),
                 name='',
                 active_step_num=0,
                 deleted=False,
                 completed=False
             )
             a.save()
             dataset.prepareUndo(processing_instance=a)
             return a.id
         return None
     elif self.type == 'analysis':
         mname = self.cleaned_data.get('method', None)
         if mname in self.methods:
             if self.methods[mname].errors:
                 errors = '\n'.join([str(x) for x in self.methods[mname].errors])
                 raise VoltPyFailed('Data does not meets requirements for selected method: %s' % errors)
             a = mmodels.Analysis(
                 owner=user,
                 dataset=dataset,
                 method=mname,
                 method_display_name=self.methods[mname].__str__(),
                 name='',
                 active_step_num=0,
                 deleted=False,
                 completed=False
             )
             a.save()
             dataset.save()
             return a.id
     return None
コード例 #5
0
ファイル: tests.py プロジェクト: burandobata/voltPy
    def test_methods_usage(self):
        p = mmodels.Processing(owner=self.user,
                               curveSet=self.curveset,
                               date=timezone.now(),
                               customData={},
                               name='PROC',
                               method='TestMethod',
                               step=0,
                               deleted=False,
                               completed=False)
        p.save()
        mema = mm.MethodManager(user=self.user, processing_id=p.id)

        class req:
            method = 'POST'
            POST = {}

            def __init__(self):
                self.POST['query'] = 'methodmanager'

        request = req()
        mema.process(request=request, user=self.user)
        p = mmodels.Processing.objects.get(id=p.id)
        self.assertEqual(p.customData['FINALIZED'], self.user.id)