]> git.parisson.com Git - diggersdigest.git/commitdiff
link Record and Product, add first paypal tools and config
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 1 Sep 2015 16:09:21 +0000 (18:09 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 1 Sep 2015 16:09:21 +0000 (18:09 +0200)
diggersdigest/diggersdigest/local_settings.py
diggersdigest/diggersdigest/migrations/shop/0002_order_callback_uuid.py [new file with mode: 0644]
diggersdigest/diggersdigest/settings.py
diggersdigest/records/admin.py
diggersdigest/records/migrations/0002_auto_20150831_1518.py [new file with mode: 0644]
diggersdigest/records/models.py
diggersdigest/records_shop/admin.py
requirements.txt

index 56482b6be1ae9127693b71371175bd2ef4587b9d..14f5870d89e88838ac0da5d3edf741dae6eee86b 100644 (file)
@@ -10,7 +10,7 @@ DATABASES = {
         'ENGINE': 'django.db.backends.mysql',
         'NAME': 'diggersdigest',
         'USER': 'digger',
-        'PASSWORD': 'admin', 
+        'PASSWORD': 'admin',
         'HOST': 'db',
         'PORT': 3306,
     }
@@ -54,6 +54,71 @@ FILEBROWSER_SELECT_FORMATS = {
     'audio': ['Audio'],
 }
 
+
+#########
+# Shop
+#########
+
+# Add Migration Module path see : https://github.com/stephenmcd/mezzanine/blob/master/docs/model-customization.rst#field-injection-caveats
+MIGRATION_MODULES = {
+    "shop": "diggersdigest.migrations.shop",
+}
+
+# USE or EXTEND the custom callback-uuid form
+SHOP_CHECKOUT_FORM_CLASS = 'payments.multipayments.forms.base.CallbackUUIDOrderForm'
+
+# Add the callback_uuid field to orders. This field is helpful for identifying
+# orders being checked out.
+EXTRA_MODEL_FIELDS = (
+# ...
+(
+"cartridge.shop.models.Order.callback_uuid",
+"django.db.models.CharField",
+(),
+{"blank" : False, "max_length" : 36},
+),
+# ...
+)
+
+PRIMARY_PAYMENT_PROCESSOR_IN_USE = True
+
+SECONDARY_PAYMENT_PROCESSORS = (
+# ...
+('paypal', {
+'name' : 'Pay With Pay-Pal',
+'form' : 'payments.multipayments.forms.paypal.PaypalSubmissionForm'
+}),
+# ...
+)
+
+# Currency type.
+PAYPAL_CURRENCY = "EUR"
+
+# Business account email. Sandbox emails look like this.
+PAYPAL_BUSINESS = 'pellerin@parisson.com'
+PAYPAL_RECEIVER_EMAIL = PAYPAL_BUSINESS
+
+# Use this to enable https on return URLs. This is strongly recommended! (Except for sandbox)
+PAYPAL_RETURN_WITH_HTTPS = False
+
+# Function that returns args for `reverse`.
+# URL is sent to PayPal as the for returning to a 'complete' landing page.
+PAYPAL_RETURN_URL = lambda cart, uuid, order_form: ('shop_complete', None, None)
+
+# Function that returns args for `reverse`.
+# URL is sent to PayPal as the URL to callback to for PayPal IPN.
+# Set to None if you do not wish to use IPN.
+PAYPAL_IPN_URL = lambda cart, uuid, order_form: ('my_paypal_ipn', None, {'uuid' : uuid})
+
+# URL the secondary-payment-form is submitted to
+# Dev example
+PAYPAL_SUBMIT_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr'
+# Prod example
+PAYPAL_SUBMIT_URL = 'https://www.paypal.com/cgi-bin/webscr'
+
+# For real use set to False
+PAYPAL_TEST = True
+
 ###################
 # DEPLOY SETTINGS #
 ###################
diff --git a/diggersdigest/diggersdigest/migrations/shop/0002_order_callback_uuid.py b/diggersdigest/diggersdigest/migrations/shop/0002_order_callback_uuid.py
new file mode 100644 (file)
index 0000000..34c9955
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('shop', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='order',
+            name='callback_uuid',
+            field=models.CharField(default=0, max_length=36),
+            preserve_default=False,
+        ),
+    ]
index dc5878267087d00ae2092fa1b50e2fea00f9ed62..bd088db9b00e12f88c094463ab265cceb4f6ead4 100644 (file)
@@ -177,10 +177,11 @@ USE_TZ = True
 
 # Language code for this installation. All choices can be found here:
 # http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = "en"
+LANGUAGE_CODE = "fr"
 
 # Supported languages
 LANGUAGES = (
+    ('fr', _('French')),
     ('en', _('English')),
 )
 
@@ -196,7 +197,7 @@ SITE_ID = 1
 
 # If you set this to False, Django will make some optimizations so as not
 # to load the internationalization machinery.
-USE_I18N = False
+USE_I18N = True
 
 AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
 
@@ -297,6 +298,8 @@ INSTALLED_APPS = (
     # "mezzanine.mobile",
     "records",
     "records_shop",
+    "payments.multipayments",
+    'paypal.standard.ipn',
 )
 
 # List of processors used by RequestContext to populate the context.
@@ -313,6 +316,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     "django.core.context_processors.tz",
     "mezzanine.conf.context_processors.settings",
     "mezzanine.pages.context_processors.page",
+    "payments.multipayments.context_processors.settings",
 )
 
 # List of middleware classes to use. Order is important; in the request phase,
@@ -349,10 +353,6 @@ MIDDLEWARE_CLASSES = (
 PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
 PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
 
-# Add Migration Module path see : https://github.com/stephenmcd/mezzanine/blob/master/docs/model-customization.rst#field-injection-caveats
-MIGRATION_MODULES = {
-    "shop": "diggersdigest.migrations.shop",
-}
 #########################
 # OPTIONAL APPLICATIONS #
 #########################
@@ -365,7 +365,7 @@ OPTIONAL_APPS = (
     PACKAGE_NAME_FILEBROWSER,
     PACKAGE_NAME_GRAPPELLI,
 )
-       
+
 ##################
 # LOCAL SETTINGS #
 ##################
index acf7368d6c92182eb60a33049d210d397b9778a8..14affef22ca2ae7ad22682a441ec7ffa1300be06 100644 (file)
@@ -15,7 +15,11 @@ from .models import Country
 from .models import Record
 from .models import Podcast
 from .models import ConditionGrading
-    
+
+class RecordInline(admin.StackedInline):
+    model = Record
+    extra = 0
+
 admin.site.register(Gallery)
 admin.site.register(Grading)
 admin.site.register(Link)
diff --git a/diggersdigest/records/migrations/0002_auto_20150831_1518.py b/diggersdigest/records/migrations/0002_auto_20150831_1518.py
new file mode 100644 (file)
index 0000000..206938f
--- /dev/null
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('shop', '0001_initial'),
+        ('records', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='record',
+            name='product',
+            field=models.ForeignKey(related_name='records', on_delete=django.db.models.deletion.SET_NULL, verbose_name='product', to='shop.Product', null=True),
+        ),
+        migrations.AlterField(
+            model_name='record',
+            name='performers',
+            field=models.ManyToManyField(related_name='records_performers', verbose_name='performers', to='records.Artist'),
+        ),
+    ]
index a2a4ef4e068ecb2716481dbc1f52b5890d926b4d..e85cc064401ff398944f4c14c9edd03046f69053 100644 (file)
@@ -11,6 +11,7 @@ from mezzanine.core.models import CONTENT_STATUS_DRAFT, CONTENT_STATUS_PUBLISHED
 from mezzanine.blog.models import BlogPost
 from mezzanine.utils.models import upload_to
 
+from cartridge.shop.models import Product, ProductVariation
 
 # Auto-generated Django models with manage.py inspectdb on the old database
 # You'll have to do the following manually to clean this up:
@@ -193,7 +194,7 @@ class ConditionGrading(models.Model):
 
     def __unicode__(self):
         return " = ".join([self.abbr, self.name])
-   
+
 class Record(models.Model):
     """
     Model for Record
@@ -212,9 +213,9 @@ class Record(models.Model):
         (ON_HOLD, 'On Hold'),
         (JUST_SOLD, 'Just Sold')
     )
-    title = models.CharField(max_length=128) 
+    title = models.CharField(max_length=128)
     artist = models.ForeignKey(Artist, verbose_name=_('artist'), related_name='records_artists', null=True, on_delete=models.SET_NULL)
-    performers = models.ManyToManyField(Artist, verbose_name=_('performer'), related_name='records_performers')
+    performers = models.ManyToManyField(Artist, verbose_name=_('performers'), related_name='records_performers')
     record_status = models.IntegerField(_('record status'), choices=NOVELTY_CHOICES, default=NEW)
     label = models.ForeignKey(Label, verbose_name=_('label'), related_name='records', null=True, on_delete=models.SET_NULL)
     release_date = models.DateField(_('release date'), null=True)
@@ -223,7 +224,7 @@ class Record(models.Model):
     #vinyl_state = models.ForeignKey(ConditionGrading, verbose_name=_('vinyl condition'), related_name='records_vinyl_condition', null=True, on_delete=models.SET_NULL)
     audio_file =  FileField(_("audio file"), max_length=1024, format="audio",
                         upload_to=upload_to("records.Record.audio", "audio/records"), null=True)
-
+    product = models.ForeignKey(Product, verbose_name=_('product'), related_name='records', null=True, on_delete=models.SET_NULL)
     def __unicode__(self):
         return " - ".join([self.artist.name, self.title])
 
index 5b32f4a54f4fec028fc088e0bf4d19b16203a69c..7b733a7064d613532194a39efac5cf87e35f2d2b 100644 (file)
@@ -1,6 +1,13 @@
 from django.contrib import admin
+from records.admin import RecordInline
+from cartridge.shop.models import Product, ProductVariation
+from cartridge.shop.admin import ProductAdmin, ProductImageAdmin, ProductVariationAdmin
 
 # Register your models here.
 from .models import RecordProduct
 
-admin.site.register(RecordProduct)
+class RecordProductAdmin(ProductAdmin):
+    inlines = [ProductImageAdmin, ProductVariationAdmin, RecordInline]
+
+admin.site.unregister(Product)
+admin.site.register(Product, RecordProductAdmin)
index 1b81a5bfd6a02b7f461ed906766248ea7f8f1391..2c2c8c5c6a7f5a7f36307f15887481362db196da 100644 (file)
@@ -1,3 +1,7 @@
 Django==1.8.3
 MySQL-python==1.2.5
 cartridge==0.10.0
+cartridge-payments==0.97.0
+django-paypal==0.2.5
+django-uuidfield==0.5.0
+django-newsletter==0.5.2