remove all the debug stuff, re-get object from db, see if that works

This commit is contained in:
Thomas Steen Rasmussen 2016-06-01 01:25:14 +02:00
parent 6379537b05
commit ed54cde150

View file

@ -387,30 +387,16 @@ class CoinifyRedirectView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureUn
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
order = self.get_object() order = self.get_object()
print "checking if order %s has coinifyapiinvoice" % order.pk
if hasattr(order, 'coinifyapiinvoice'): if hasattr(order, 'coinifyapiinvoice'):
# we already have a coinifyinvoice for this order, # we already have a coinifyinvoice for this order,
# check if it expired # check if it expired
print "order %s has coinifyapiinvoice, check expire time.." % order.pk
if parse_datetime(order.coinifyapiinvoice.invoicejson['expire_time']) < timezone.now(): if parse_datetime(order.coinifyapiinvoice.invoicejson['expire_time']) < timezone.now():
# this coinifyinvoice expired, delete it # this coinifyinvoice expired, delete it
print "order %s has an expired coinifyapiinvoice, delete it.." % order.pk
order.coinifyapiinvoice.delete() order.coinifyapiinvoice.delete()
if hasattr(order, 'coinifyapiinvoice'): order = self.get_object()
print "deleted coinifyapiinvoice but order %s still hasattr(coinifyapiinvoice), sleeping 5 secs" % order.pk
time.sleep(2)
if hasattr(order, 'coinifyapiinvoice'):
print "deleted coinifyapiinvoice and slept 2 secs but order %s still hasattr(coinifyapiinvoice), what the fuck" % order.pk
order.refresh_from_db()
if hasattr(order, 'coinifyapiinvoice'):
print "refreshed order %s from db but it still hasattr(coinifyapiinvoice), what the fuck" % order.pk
else:
print "refreshed order %s from db which helped" % order.pk
# create a new coinify invoice if needed # create a new coinify invoice if needed
print "checking if order %s has coinifyapiinvoice" % order.pk
if not hasattr(order, 'coinifyapiinvoice'): if not hasattr(order, 'coinifyapiinvoice'):
print "order %s has no coinifyapiinvoice, creating one.." % order.pk
# Initiate coinify API # Initiate coinify API
coinifyapi = CoinifyAPI( coinifyapi = CoinifyAPI(
settings.COINIFY_API_KEY, settings.COINIFY_API_KEY,
@ -445,7 +431,6 @@ class CoinifyRedirectView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureUn
order = order, order = order,
) )
print "done"
return super(CoinifyRedirectView, self).dispatch( return super(CoinifyRedirectView, self).dispatch(
request, *args, **kwargs request, *args, **kwargs
) )