From: Guillaume Pellerin Date: Tue, 1 Sep 2015 16:09:21 +0000 (+0200) Subject: link Record and Product, add first paypal tools and config X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=46b049240dfedd616432a807a82570e4fd3d8ff5;p=diggersdigest.git link Record and Product, add first paypal tools and config --- diff --git a/diggersdigest/diggersdigest/local_settings.py b/diggersdigest/diggersdigest/local_settings.py index 56482b6..14f5870 100644 --- a/diggersdigest/diggersdigest/local_settings.py +++ b/diggersdigest/diggersdigest/local_settings.py @@ -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 index 0000000..34c9955 --- /dev/null +++ b/diggersdigest/diggersdigest/migrations/shop/0002_order_callback_uuid.py @@ -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, + ), + ] diff --git a/diggersdigest/diggersdigest/settings.py b/diggersdigest/diggersdigest/settings.py index dc58782..bd088db 100644 --- a/diggersdigest/diggersdigest/settings.py +++ b/diggersdigest/diggersdigest/settings.py @@ -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 # ################## diff --git a/diggersdigest/records/admin.py b/diggersdigest/records/admin.py index acf7368..14affef 100644 --- a/diggersdigest/records/admin.py +++ b/diggersdigest/records/admin.py @@ -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 index 0000000..206938f --- /dev/null +++ b/diggersdigest/records/migrations/0002_auto_20150831_1518.py @@ -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'), + ), + ] diff --git a/diggersdigest/records/models.py b/diggersdigest/records/models.py index a2a4ef4..e85cc06 100644 --- a/diggersdigest/records/models.py +++ b/diggersdigest/records/models.py @@ -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]) diff --git a/diggersdigest/records_shop/admin.py b/diggersdigest/records_shop/admin.py index 5b32f4a..7b733a7 100644 --- a/diggersdigest/records_shop/admin.py +++ b/diggersdigest/records_shop/admin.py @@ -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) diff --git a/requirements.txt b/requirements.txt index 1b81a5b..2c2c8c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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