Add expiry dates and individual conditions to gift cards (#1656)

* Add expiry dates and individual conditions to gift cards

* Display refund gift cards with more details and prettier interface

* Allow to set gift card expiry and conditions when cancelling event

* Extend gift card search

* Fix #1565 -- Some gift card filters

* Improve list of gift cards

* Allow to edit gift cards

* Note on validity
This commit is contained in:
Raphael Michel
2020-04-21 15:57:02 +02:00
committed by GitHub
parent d9fd4b33a0
commit f2844ac686
31 changed files with 450 additions and 70 deletions
+2
View File
@@ -27,6 +27,8 @@ TEST_GC_RES = {
"secret": "ABCDEF",
"value": "23.00",
"testmode": False,
"expires": None,
"conditions": None,
"currency": "EUR"
}
+10
View File
@@ -89,6 +89,16 @@ def test_card_detail_view_transact(organizer, admin_user, gift_card, client):
assert gift_card.all_logentries().count() == 1
@pytest.mark.django_db
def test_card_detail_edit(organizer, admin_user, gift_card, client):
client.login(email='dummy@dummy.dummy', password='dummy')
client.post('/control/organizer/dummy/giftcard/{}/edit'.format(gift_card.pk), {
'conditions': 'Foo'
})
gift_card.refresh_from_db()
assert gift_card.conditions == 'Foo'
@pytest.mark.django_db
def test_card_detail_view_transact_revert_refund(organizer, admin_user, gift_card, client):
with scopes_disabled():
+2
View File
@@ -150,6 +150,7 @@ organizer_urls = [
'organizer/abc/giftcards',
'organizer/abc/giftcard/add',
'organizer/abc/giftcard/1/',
'organizer/abc/giftcard/1/edit',
]
@@ -413,6 +414,7 @@ organizer_permission_urls = [
("can_manage_gift_cards", "organizer/dummy/giftcards", 200),
("can_manage_gift_cards", "organizer/dummy/giftcard/add", 200),
("can_manage_gift_cards", "organizer/dummy/giftcard/1/", 404),
("can_manage_gift_cards", "organizer/dummy/giftcard/1/edit", 404),
]
+15
View File
@@ -1027,6 +1027,21 @@ class CheckoutTestCase(BaseCheckoutTestCase, TestCase):
assert o.payments.get(provider='giftcard').amount == Decimal('18.00')
assert o.payments.get(provider='banktransfer').amount == Decimal('5.00')
def test_giftcard_expired(self):
gc = self.orga.issued_gift_cards.create(currency="EUR", expires=now() - timedelta(days=1))
gc.transactions.create(value=20)
self.event.settings.set('payment_banktransfer__enabled', True)
with scopes_disabled():
CartPosition.objects.create(
event=self.event, cart_id=self.session_key, item=self.ticket,
price=23, expires=now() + timedelta(minutes=10)
)
response = self.client.post('/%s/%s/checkout/payment/' % (self.orga.slug, self.event.slug), {
'payment': 'giftcard',
'giftcard': gc.secret
}, follow=True)
assert 'This gift card is no longer valid.' in response.rendered_content
def test_giftcard_invalid_currency(self):
gc = self.orga.issued_gift_cards.create(currency="USD")
gc.transactions.create(value=20)