Skip to content

Commit

Permalink
Introduce "courses" coupon print template
Browse files Browse the repository at this point in the history
  • Loading branch information
kedder committed Dec 13, 2020
1 parent 0a58e67 commit 068bde9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
31 changes: 31 additions & 0 deletions coupons/migrations/0008_auto_20201213_1325.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 3.1.4 on 2020-12-13 13:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("coupons", "0007_coupontype_print_template"),
]

operations = [
migrations.AlterField(
model_name="coupontype",
name="print_template",
field=models.CharField(
choices=[("flight", "Flight Coupon"), ("courses", "Courses Coupon")],
max_length=32,
),
),
migrations.AlterField(
model_name="coupontype",
name="validity_cond_text",
field=models.CharField(max_length=255, null=True),
),
migrations.AlterField(
model_name="coupontype",
name="welcome_text",
field=models.TextField(null=True),
),
]
7 changes: 4 additions & 3 deletions coupons/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ class CouponType(models.Model):
id = models.CharField(max_length=32, primary_key=True)
price = models.DecimalField(max_digits=10, decimal_places=2)
title = models.CharField(max_length=255)
welcome_text = models.TextField()
validity_cond_text = models.CharField(max_length=255)
welcome_text = models.TextField(null=True)
validity_cond_text = models.CharField(max_length=255, null=True)
deafult_expiration_date = models.DateField()
in_stock = models.BooleanField(default=True)
# Template to use when printing the coupon. Will use django template in
# `templates/coupons/{}.html`
print_template = models.CharField(
max_length=32, choices=[("flight", "Flight Coupon")]
max_length=32,
choices=[("flight", "Flight Coupon"), ("courses", "Courses Coupon")],
)

def __str__(self) -> str:
Expand Down
33 changes: 33 additions & 0 deletions coupons/templates/coupons/courses.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends "coupons/base_coupon.html" %}
{% block coupon_content %}

<p>Tai – pradžia, svajojantiems tapti pilotais.</p>

<p>Teorijos mokymai skirti, norintiems įgyti Sklandytojų (SPL), Pilotų mėgėjų
(PPL(A)) ar Ultralengvųjų orlaivių (ULO) pilotų licencijas.</p>

<p> Mokymų programą sudaro šios aviacinės disciplinos:</p>
<ul>
<li>bendrosios žinios apie orlaivius</li>
<li>navigacija</li>
<li>aerodinamika</li>
<li>meteorologija</li>
<li>radijo ryšio priemonės</li>
<li>oro teisė ir skrydžių procedūros</li>
<li>žmogaus galimybės skraidyti</li>
<li>skrydžio vykdymas ir planavimas</li>
</ul>

<p>Įsisavinus visas disciplinas ir sėkmingai išlaikius egzaminus, lieka tik skrydžiai.</p>

<p>Paskaitos vyksta nuo sausio iki balandžio.</p>

<p>Gavę šią dovaną, registruokitės kursams Vilniaus aeroklubo tinklapyje <a
href="http://sklandymas.lt/">www.sklandymas.lt</a>. Jei turite klausimų,
kreipkitės telefonu <span itemprop="telephone"><a
href="tel:+37061515060">+370&nbsp;615&nbsp;15060</a></span> arba e-paštu <a
href="mailto:aeroklubas@sklandymas.lt">aeroklubas@sklandymas.lt</a>.</p>



{% endblock %}
19 changes: 18 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,25 @@ def test_coupon_spawn_protected(client) -> None:
assert resp.status_code == 302 # Redirect to login


def test_coupon(client, sample_coupon_type) -> None:
def test_coupon_flight(client, sample_coupon_type) -> None:
# GIVEN
sample_coupon_type.print_template = "flight"
order = models.Order.from_type(sample_coupon_type)
order.save()
coupons = order.process(paid_amount=32.4, paid_currency="EUR")
assert len(coupons) == 1
cid = coupons[0].id

# WHEN
resp = client.get(f"/coupon/{cid}")

# THEN
assert cid.encode("utf-8") in resp.content


def test_coupon_courses(client, sample_coupon_type) -> None:
# GIVEN
sample_coupon_type.print_template = "courses"
order = models.Order.from_type(sample_coupon_type)
order.save()
coupons = order.process(paid_amount=32.4, paid_currency="EUR")
Expand Down

0 comments on commit 068bde9

Please sign in to comment.