This repository has been archived by the owner on Nov 6, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from WhyNotHugo/multiple-items
Add support for multiple items per preference
- Loading branch information
Showing
8 changed files
with
292 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
Changelog | ||
========= | ||
|
||
v6.0.0 | ||
------ | ||
|
||
* Add support for multiple items per preference. | ||
|
||
v5.1.2 | ||
------ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
django_mercadopago/migrations/0019_split_preference_items.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('mp', '0018_payment_mpid_biginteger'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Item', | ||
fields=[ | ||
('id', | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name='ID', | ||
)), | ||
( | ||
'title', | ||
models.CharField( | ||
max_length=256, | ||
verbose_name='title', | ||
), | ||
), | ||
( | ||
'currency_id', | ||
models.CharField( | ||
default='ARS', | ||
max_length=3, | ||
verbose_name='currency id', | ||
), | ||
), | ||
( | ||
'description', | ||
models.CharField( | ||
max_length=256, | ||
verbose_name='description', | ||
), | ||
), | ||
( | ||
'quantity', | ||
models.PositiveSmallIntegerField(default=1), | ||
), | ||
( | ||
'unit_price', | ||
models.DecimalField(decimal_places=2, max_digits=9), | ||
), | ||
], | ||
options={ | ||
'verbose_name': 'item', | ||
'verbose_name_plural': 'items', | ||
}, | ||
), | ||
migrations.AlterField( | ||
model_name='preference', | ||
name='mp_id', | ||
field=models.CharField( | ||
help_text=( | ||
'The id MercadoPago has assigned for this Preference'), | ||
max_length=46, | ||
null=True, | ||
verbose_name='mercadopago id', | ||
), | ||
), | ||
migrations.AddField( | ||
model_name='item', | ||
name='preference', | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.PROTECT, | ||
related_name='items', | ||
to='mp.Preference', | ||
verbose_name='preference', | ||
), | ||
), | ||
] |
27 changes: 27 additions & 0 deletions
27
django_mercadopago/migrations/0020_move_preference_items.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django.db import migrations | ||
|
||
|
||
def move_item_data(apps, schema_editor): | ||
"""Move Item data from Preference into the new model.""" | ||
Preference = apps.get_model('mp', 'Preference') | ||
Item = apps.get_model('mp', 'Item') | ||
|
||
for preference in Preference.objects.all(): | ||
Item.objects.create( | ||
preference=preference, | ||
title=preference.title, | ||
description=preference.description, | ||
quantity=preference.quantity, | ||
unit_price=preference.price, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('mp', '0019_split_preference_items'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(move_item_data), | ||
] |
25 changes: 25 additions & 0 deletions
25
django_mercadopago/migrations/0021_remove_preference_item_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 2.1.5 on 2019-03-11 16:28 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('mp', '0020_move_preference_items'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='preference', | ||
name='price', | ||
), | ||
migrations.RemoveField( | ||
model_name='preference', | ||
name='quantity', | ||
), | ||
migrations.RemoveField( | ||
model_name='preference', | ||
name='title', | ||
), | ||
] |
Oops, something went wrong.