From bbad0e1a9eaf93c9ee58e9e202547f16f84b0bef Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 8 Dec 2017 10:02:56 +0100
Subject: [PATCH] voucher type structuctures

---
 .../0090_vouchertype_vouchertypeprice.py      | 35 +++++++++++++++++++
 smash/web/models/__init__.py                  |  4 ++-
 smash/web/models/voucher_type.py              | 25 +++++++++++++
 smash/web/models/voucher_type_price.py        | 19 ++++++++++
 4 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 smash/web/migrations/0090_vouchertype_vouchertypeprice.py
 create mode 100644 smash/web/models/voucher_type.py
 create mode 100644 smash/web/models/voucher_type_price.py

diff --git a/smash/web/migrations/0090_vouchertype_vouchertypeprice.py b/smash/web/migrations/0090_vouchertype_vouchertypeprice.py
new file mode 100644
index 00000000..8697161b
--- /dev/null
+++ b/smash/web/migrations/0090_vouchertype_vouchertypeprice.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.7 on 2017-12-08 09:00
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('web', '0089_unfinshed_appointment_list'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='VoucherType',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('code', models.CharField(max_length=20, verbose_name=b'Code')),
+                ('description', models.CharField(blank=True, max_length=1024, verbose_name=b'Description')),
+                ('study', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='web.Study')),
+            ],
+        ),
+        migrations.CreateModel(
+            name='VoucherTypePrice',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('price', models.DecimalField(decimal_places=2, max_digits=6, verbose_name=b'Price')),
+                ('start_date', models.DateField(verbose_name=b'Start date')),
+                ('end_date', models.DateField(verbose_name=b'End date')),
+                ('voucher_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='web.VoucherType')),
+            ],
+        ),
+    ]
diff --git a/smash/web/models/__init__.py b/smash/web/models/__init__.py
index d9ee4dab..6b9eac7e 100644
--- a/smash/web/models/__init__.py
+++ b/smash/web/models/__init__.py
@@ -14,6 +14,8 @@ from study_columns import StudyColumns
 from visit_columns import VisitColumns
 from notification_columns import StudyNotificationParameters
 from study import Study
+from voucher_type import VoucherType
+from voucher_type_price import VoucherTypePrice
 from room import Room
 from visit import Visit
 from worker import Worker
@@ -36,5 +38,5 @@ from inconsistent_subject import InconsistentSubject, InconsistentField
 __all__ = [Study, FlyingTeam, Appointment, AppointmentType, Availability, Holiday, Item, Language, Location, Room,
            Subject, StudySubject, StudySubjectList, SubjectColumns, StudyNotificationParameters,
            AppointmentList, AppointmentColumns, Visit, Worker, ContactAttempt, ConfigurationItem, MailTemplate,
-           AppointmentTypeLink,
+           AppointmentTypeLink, VoucherType, VoucherTypePrice,
            MissingSubject, InconsistentSubject, InconsistentField, Country, StudyColumns, VisitColumns, StudyVisitList]
diff --git a/smash/web/models/voucher_type.py b/smash/web/models/voucher_type.py
new file mode 100644
index 00000000..c4b7885e
--- /dev/null
+++ b/smash/web/models/voucher_type.py
@@ -0,0 +1,25 @@
+# coding=utf-8
+from django.db import models
+
+from web.models import Study
+
+
+class VoucherType(models.Model):
+    class Meta:
+        app_label = 'web'
+
+    code = models.CharField(max_length=20, verbose_name='Code', blank=False, null=False)
+
+    description = models.CharField(max_length=1024, verbose_name='Description', blank=True, null=False)
+
+    study = models.ForeignKey(
+        Study,
+        on_delete=models.CASCADE,
+        null=False,
+    )
+
+    def __str__(self):
+        return "%s" % self.code
+
+    def __unicode__(self):
+        return "%s" % self.code
diff --git a/smash/web/models/voucher_type_price.py b/smash/web/models/voucher_type_price.py
new file mode 100644
index 00000000..d3a8d56b
--- /dev/null
+++ b/smash/web/models/voucher_type_price.py
@@ -0,0 +1,19 @@
+# coding=utf-8
+from django.db import models
+
+from web.models import VoucherType
+
+
+class VoucherTypePrice(models.Model):
+    class Meta:
+        app_label = 'web'
+
+    price = models.DecimalField(max_digits=6, decimal_places=2, verbose_name='Price', null=False, blank=False)
+    start_date = models.DateField(verbose_name='Start date', null=False, blank=False)
+    end_date = models.DateField(verbose_name='End date', null=False, blank=False)
+
+    voucher_type = models.ForeignKey(
+        VoucherType,
+        on_delete=models.CASCADE,
+        null=False,
+    )
-- 
GitLab