fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Banners only for authenticated users.
[wolnelektury.git]
/
src
/
club
/
payu
/
models.py
diff --git
a/src/club/payu/models.py
b/src/club/payu/models.py
index
1a49dd7
..
5764f88
100644
(file)
--- a/
src/club/payu/models.py
+++ b/
src/club/payu/models.py
@@
-7,6
+7,7
@@
from urllib.request import HTTPError
from django.contrib.sites.models import Site
from django.db import models
from django.urls import reverse
from django.contrib.sites.models import Site
from django.db import models
from django.urls import reverse
+from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from . import POSS
from django.utils.translation import ugettext_lazy as _
from . import POSS
@@
-36,6
+37,7
@@
class Order(models.Model):
('CANCELED', _('Canceled')),
('REJECTED', _('Rejected')),
])
('CANCELED', _('Canceled')),
('REJECTED', _('Rejected')),
])
+ completed_at = models.DateTimeField(null=True, blank=True)
class Meta:
abstract = True
class Meta:
abstract = True
@@
-124,6
+126,8
@@
class Order(models.Model):
token.save()
# else?
token.save()
# else?
+ if 'orderId' not in response:
+ raise ValueError("Expecting dict with `orderId` key, got: %s" % response)
self.order_id = response['orderId']
self.save()
self.order_id = response['orderId']
self.save()
@@
-148,5
+152,7
@@
class Notification(models.Model):
status = self.get_status()
if self.order.status not in (status, 'COMPLETED'):
self.order.status = status
status = self.get_status()
if self.order.status not in (status, 'COMPLETED'):
self.order.status = status
+ if status == 'COMPLETED':
+ self.order.completed_at = now()
self.order.save()
self.order.status_updated()
self.order.save()
self.order.status_updated()