Commit a9183704 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

wip Remove CallSerial model and related calls

parent 292e2022
......@@ -44,10 +44,10 @@ from astakos.quotaholder.api import QH_PRACTICALLY_INFINITE
from django.db.models import Q, Count
from django.db.models import Q
from .models import (Policy, Holding,
Commission, Provision, ProvisionLog, CallSerial,
Commission, Provision, ProvisionLog,
now,
db_get_holding, db_get_policy,
db_get_commission, db_filter_provision, db_get_callserial)
db_get_commission, db_filter_provision)
class QuotaholderDjangoDBCallpoint(object):
......@@ -345,22 +345,11 @@ class QuotaholderDjangoDBCallpoint(object):
return rejected
def add_quota(self,
context=None, clientkey=None, serial=None,
context=None,
sub_quota=(), add_quota=()):
rejected = []
append = rejected.append
if serial is not None:
if clientkey is None:
all_pairs = [(q[0], q[1]) for q in sub_quota + add_quota]
raise QuotaholderError(all_pairs)
try:
cs = CallSerial.objects.get(serial=serial, clientkey=clientkey)
all_pairs = [(q[0], q[1]) for q in sub_quota + add_quota]
raise QuotaholderError(all_pairs)
except CallSerial.DoesNotExist:
pass
sources = sub_quota + add_quota
q_holdings = Q()
holders = []
......@@ -431,44 +420,8 @@ class QuotaholderDjangoDBCallpoint(object):
if rejected:
raise QuotaholderError(rejected)
if serial is not None and clientkey is not None:
CallSerial.objects.create(serial=serial, clientkey=clientkey)
return rejected
def ack_serials(self, context=None, clientkey=None, serials=()):
if clientkey is None:
return
for serial in serials:
try:
c = db_get_callserial(clientkey=clientkey,
serial=serial,
for_update=True)
c.delete()
except CallSerial.DoesNotExist:
pass
return
def query_serials(self, context=None, clientkey=None, serials=()):
result = []
append = result.append
if clientkey is None:
return result
if not serials:
cs = CallSerial.objects.filter(clientkey=clientkey)
return [c.serial for c in cs]
for serial in serials:
try:
db_get_callserial(clientkey=clientkey, serial=serial)
append(serial)
except CallSerial.DoesNotExist:
pass
return result
def issue_commission(self,
context=None,
clientkey=None,
......
......@@ -170,16 +170,6 @@ class ProvisionLog(Model):
def target_outbound(self):
return self.target_outbound_through() + self.target_exported
class CallSerial(Model):
serial = BigIntegerField(null=False)
clientkey = CharField(max_length=4096, null=False)
objects = ForUpdateManager()
class Meta:
unique_together = (('serial', 'clientkey'),)
def _get(*args, **kwargs):
model = args[0]
......@@ -211,8 +201,5 @@ def db_get_policy(*args, **kwargs):
def db_get_commission(*args, **kwargs):
return _get(Commission, *args, **kwargs)
def db_get_callserial(*args, **kwargs):
return _get(CallSerial, *args, **kwargs)
def db_filter_provision(*args, **kwargs):
return _filter(Provision, *args, **kwargs)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment