diff --git a/apps/payment/migrations/0025_giftcertificate_usergiftcertificate.py b/apps/payment/migrations/0025_giftcertificate_usergiftcertificate.py index d5ac1b08..3f9dcc34 100644 --- a/apps/payment/migrations/0025_giftcertificate_usergiftcertificate.py +++ b/apps/payment/migrations/0025_giftcertificate_usergiftcertificate.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): name='UserGiftCertificate', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('recipient', models.EmailField(max_length=254)), + ('recipient', models.EmailField(max_length=254, blank=True, null=True,)), ('bonuses_sent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='payment.UserBonus')), ('gift_certificate', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='payment.GiftCertificate')), ('payment', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='payment.Payment')), diff --git a/apps/payment/migrations/0027_auto_20181109_1402.py b/apps/payment/migrations/0027_auto_20181109_1402.py new file mode 100644 index 00000000..a228e06b --- /dev/null +++ b/apps/payment/migrations/0027_auto_20181109_1402.py @@ -0,0 +1,22 @@ +# Generated by Django 2.0.6 on 2018-11-09 14:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('payment', '0026_auto_20181101_1546'), + ] + + operations = [ + migrations.RemoveField( + model_name='usergiftcertificate', + name='recipient', + ), + migrations.AddField( + model_name='giftcertificate', + name='cover', + field=models.CharField(blank=True, default='', max_length=255), + ), + ] diff --git a/apps/payment/migrations/0028_add_gift_certificates.py b/apps/payment/migrations/0028_add_gift_certificates.py new file mode 100644 index 00000000..18c0ac4f --- /dev/null +++ b/apps/payment/migrations/0028_add_gift_certificates.py @@ -0,0 +1,21 @@ +# Generated by Django 2.0.6 on 2018-11-09 14:03 + +from django.db import migrations +from django.contrib.staticfiles.storage import staticfiles_storage + + +def add_gift_certificates(apps, schema_editor): + GiftCertificate = apps.get_model('payment', 'GiftCertificate') + for price in [1000, 2000, 3000, 5000, 10000]: + GiftCertificate.objects.create(price=price, + cover=staticfiles_storage.url('img/gift-certificates/%d.jpg' % price)) + +class Migration(migrations.Migration): + + dependencies = [ + ('payment', '0027_auto_20181109_1402'), + ] + + operations = [ + migrations.RunPython(add_gift_certificates), + ] diff --git a/apps/payment/models.py b/apps/payment/models.py index f7623038..413e8bf8 100644 --- a/apps/payment/models.py +++ b/apps/payment/models.py @@ -14,6 +14,7 @@ from django.core.validators import RegexValidator from django.utils.timezone import now from django.conf import settings +from apps.content.models import ImageObject from project.utils import weekdays_in_date_range from apps.course.models import Course @@ -314,6 +315,7 @@ class UserBonus(models.Model): class GiftCertificate(models.Model): price = models.DecimalField(max_digits=8, decimal_places=2, default=0) + cover = models.CharField(max_length=255, blank=True, default='') class Meta: ordering = ('price',) @@ -322,7 +324,6 @@ class GiftCertificate(models.Model): class UserGiftCertificate(models.Model): gift_certificate = models.ForeignKey(GiftCertificate, on_delete=models.CASCADE,) user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='gift_certificates') - recipient = models.EmailField() payment = models.ForeignKey(Payment, on_delete=models.SET_NULL, null=True) bonuses_sent = models.ForeignKey(UserBonus, on_delete=models.CASCADE, blank=True, null=True) diff --git a/apps/payment/templates/payment/gift_certificate_item.html b/apps/payment/templates/payment/gift_certificate_item.html index d642cf11..5f4a318e 100644 --- a/apps/payment/templates/payment/gift_certificate_item.html +++ b/apps/payment/templates/payment/gift_certificate_item.html @@ -3,7 +3,9 @@ {% load data_liked from data_liked %}
-
+
+ +
{% if user_gift_certificate and not user_gift_certificate.bonuses_sent %} diff --git a/web/src/img/gift-certificates/1000.jpg b/web/src/img/gift-certificates/1000.jpg new file mode 100644 index 00000000..9d682d7f Binary files /dev/null and b/web/src/img/gift-certificates/1000.jpg differ diff --git a/web/src/img/gift-certificates/10000.jpg b/web/src/img/gift-certificates/10000.jpg new file mode 100644 index 00000000..9695841d Binary files /dev/null and b/web/src/img/gift-certificates/10000.jpg differ diff --git a/web/src/img/gift-certificates/2000.jpg b/web/src/img/gift-certificates/2000.jpg new file mode 100644 index 00000000..ec0483ac Binary files /dev/null and b/web/src/img/gift-certificates/2000.jpg differ diff --git a/web/src/img/gift-certificates/3000.jpg b/web/src/img/gift-certificates/3000.jpg new file mode 100644 index 00000000..bb6f3970 Binary files /dev/null and b/web/src/img/gift-certificates/3000.jpg differ diff --git a/web/src/img/gift-certificates/5000.jpg b/web/src/img/gift-certificates/5000.jpg new file mode 100644 index 00000000..5bb83064 Binary files /dev/null and b/web/src/img/gift-certificates/5000.jpg differ diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass index 98e90895..3041bed7 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -4455,6 +4455,9 @@ a height: 200px +t margin-bottom: 10px + &__cover + object-fit: cover; + width: 100%; &__details display: flex margin-bottom: 10px diff --git a/web/webpack.config.js b/web/webpack.config.js index 7455fec9..8156ab03 100644 --- a/web/webpack.config.js +++ b/web/webpack.config.js @@ -14,6 +14,7 @@ module.exports = { sprite: glob('./src/icons/*.svg'), images: glob('./src/img/*.*'), imagesCertificates: glob('./src/img/user-certificates/*'), + imagesGiftCertificates: glob('./src/img/gift-certificates/*'), fonts: glob('./src/fonts/*') }, output: { @@ -85,7 +86,8 @@ module.exports = { }, { test: /\.(png|gif|jpg|svg)$/, - exclude: [path.resolve(__dirname, 'src/icons'), path.resolve(__dirname, 'src/img/user-certificates')], + exclude: [path.resolve(__dirname, 'src/icons'), path.resolve(__dirname, 'src/img/user-certificates'), + path.resolve(__dirname, 'src/img/gift-certificates')], loader: 'file-loader?name=[name].[ext]&outputPath=./img/' }, { @@ -93,6 +95,11 @@ module.exports = { include: path.resolve(__dirname, 'src/img/user-certificates'), loader: 'file-loader?name=[name].[ext]&outputPath=./img/user-certificates/' }, + { + test: /\.(png|jpg)$/, + include: path.resolve(__dirname, 'src/img/gift-certificates'), + loader: 'file-loader?name=[name].[ext]&outputPath=./img/gift-certificates/' + }, { test: /\.(ttf|otf|eot|woff(2)?)(\?[a-z0-9]+)?$/, loader: 'file-loader?name=[name].[ext]'