Exemple #1
0
 def delete(self, request, data_key=None):
     if data_key is None:
         qs, cl=QueryData(request, self.model)
         qs.delete()
     else:
         obj = self.model.objects.get(kp=data_key)
         obj.delete()
Exemple #2
0
 def read(self, request, data_key):
     if data_key is None:
         if hasattr(self,'qs') and self.qs!=None:return self.qs
         qs, cl=QueryData(request, self.model)
         #print dict(request.GET)
         recordtype=int(request.GET.get('t', '1'))
         if recordtype==1:
             if qs.count()>10000:
                 qs, cl=QueryData(request, self.model)
                 return qs[:10000]
             return qs[:]
         elif recordtype==2:
             l=int(request.GET.get('l', '15'))
             p1=int(request.GET.get('p1', '1'))
             p2=int(request.GET.get('p2', '1'))
             if p1<=0:
                 p1=1
             if p2<=0:
                 p2=1
             return qs[(p1-1)*l:p2*l]
         else:
             s1=int(request.GET.get('s1', '1'))
             s2=int(request.GET.get('s2', '1'))          
             if s1<=0:
                 s1=1
             if s2<=0:
                 s2=1                                
             return qs[s1-1:s1+s2-1]
     return self.model.objects.get(pk=data_key)
Exemple #3
0
 def delete(self, request, data_key=None):
     if data_key is None:
         qs, cl = QueryData(request, self.model)
         qs.delete()
     else:
         obj = self.model.objects.get(kp=data_key)
         obj.delete()
Exemple #4
0
 def read(self, request, data_key):
     if data_key is None:
         if hasattr(self, 'qs') and self.qs != None: return self.qs
         qs, cl = QueryData(request, self.model)
         #print dict(request.GET)
         recordtype = int(request.GET.get('t', '1'))
         if recordtype == 1:
             if qs.count() > 10000:
                 qs, cl = QueryData(request, self.model)
                 return qs[:10000]
             return qs[:]
         elif recordtype == 2:
             l = int(request.GET.get('l', '15'))
             p1 = int(request.GET.get('p1', '1'))
             p2 = int(request.GET.get('p2', '1'))
             if p1 <= 0:
                 p1 = 1
             if p2 <= 0:
                 p2 = 1
             return qs[(p1 - 1) * l:p2 * l]
         else:
             s1 = int(request.GET.get('s1', '1'))
             s2 = int(request.GET.get('s2', '1'))
             if s1 <= 0:
                 s1 = 1
             if s2 <= 0:
                 s2 = 1
             return qs[s1 - 1:s1 + s2 - 1]
     return self.model.objects.get(pk=data_key)
Exemple #5
0
 def update(self, request, data_key=None):
     if data_key is None:
         qs, cl = QueryData(request, self.model)
         qs.update(**dict(request.POST))
     else:
         obj = self.model.objects.get(kp=data_key)
         for p in request.POST:
             setattr(obj, p, request.POST[p])
         obj.save()
Exemple #6
0
 def read(self, request):
     qs, cl = QueryData(request, self.model)
     return {'count': len(qs)}
Exemple #7
-1
 def update(self, request, data_key=None):
     if data_key is None:
         qs, cl=QueryData(request, self.model)
         qs.update(**dict(request.POST))
     else:
         obj = self.model.objects.get(kp=data_key)
         for p in request.POST: 
             setattr(obj, p, request.POST[p])
         obj.save()