예제 #1
0
def select(request):
    qs = Drug.objects.all()
    mai = MAI(criterion.get_matrix())
    pks = [item.pk for item in qs]
    for cr in criterion.iter():
        alternative = Matrix()
        for drug in qs:
            alternative.append(CompareValue.matrix_row(cr, drug.pk, pks))
        mai.add_alter(alternative)
    result = [item for item in mai()]
    for i in range(len(result)):
        print '%s - %s' % (qs[i].pk, result[i])    
    return HttpResponse('Text!')
예제 #2
0
 def search(self):
     self._alters = []
     cr_matrix = criterion.get_matrix(int(self.cleaned_data['type']))      
     if not self.cleaned_data['farm']:
         return []
     qs = self._get_qs(self.cleaned_data['farm'], self.cleaned_data['strong'])
     pks = [item.pk for item in qs]
     if not pks:
         return []                
     mai = MAI(cr_matrix, qs)
     for cr in criterion.iter():
         alternative = Matrix()
         print cr[1]
         for drug in qs:
             print drug
             print CompareValue.matrix_row(cr, drug.pk, pks)
             alternative.append(CompareValue.matrix_row(cr, drug.pk, pks))
         self._alters.append({
             'cr': cr,
             'm': alternative
         })
         
         mai.add_alter(alternative)
     return mai.sort()