├── .gitignore ├── NOTES.md ├── README.md ├── accounts ├── __init__.py ├── admin.py ├── apps.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_auto_20180603_2029.py │ ├── 0003_auto_20180603_2029.py │ ├── 0004_userstripe.py │ ├── 0005_auto_20180606_0601.py │ ├── 0006_auto_20180606_0617.py │ └── __init__.py ├── models.py ├── tests.py ├── urls.py └── views.py ├── cart ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py ├── db.sqlite3 ├── manage.py ├── products ├── __init__.py ├── admin.py ├── apps.py ├── migrations │ ├── 0001_initial.py │ └── __init__.py ├── models.py ├── templates │ └── products │ │ └── product_list.html ├── tests.py ├── urls.py └── views.py ├── requirements.txt ├── shopping_cart ├── __init__.py ├── admin.py ├── apps.py ├── extras.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_auto_20180531_0944.py │ ├── 0003_auto_20180603_2020.py │ ├── 0004_transaction.py │ ├── 0005_auto_20180609_1016.py │ └── __init__.py ├── models.py ├── templates │ └── shopping_cart │ │ ├── checkout.html │ │ ├── order_summary.html │ │ ├── purchase_success.html │ │ └── stripe_default_form.html ├── templatetags │ └── cart_template_tag.py ├── tests.py ├── urls.py └── views.py ├── static ├── admin │ ├── css │ │ ├── base.css │ │ ├── changelists.css │ │ ├── dashboard.css │ │ ├── fonts.css │ │ ├── forms.css │ │ ├── login.css │ │ ├── rtl.css │ │ └── widgets.css │ ├── fonts │ │ ├── LICENSE.txt │ │ ├── README.txt │ │ ├── Roboto-Bold-webfont.woff │ │ ├── Roboto-Light-webfont.woff │ │ └── Roboto-Regular-webfont.woff │ ├── img │ │ ├── LICENSE │ │ ├── README.txt │ │ ├── calendar-icons.svg │ │ ├── gis │ │ │ ├── move_vertex_off.svg │ │ │ └── move_vertex_on.svg │ │ ├── icon-addlink.svg │ │ ├── icon-alert.svg │ │ ├── icon-calendar.svg │ │ ├── icon-changelink.svg │ │ ├── icon-clock.svg │ │ ├── icon-deletelink.svg │ │ ├── icon-no.svg │ │ ├── icon-unknown-alt.svg │ │ ├── icon-unknown.svg │ │ ├── icon-yes.svg │ │ ├── inline-delete.svg │ │ ├── search.svg │ │ ├── selector-icons.svg │ │ ├── sorting-icons.svg │ │ ├── tooltag-add.svg │ │ └── tooltag-arrowright.svg │ └── js │ │ ├── SelectBox.js │ │ ├── SelectFilter2.js │ │ ├── actions.js │ │ ├── actions.min.js │ │ ├── admin │ │ ├── DateTimeShortcuts.js │ │ └── RelatedObjectLookups.js │ │ ├── calendar.js │ │ ├── cancel.js │ │ ├── change_form.js │ │ ├── collapse.js │ │ ├── collapse.min.js │ │ ├── core.js │ │ ├── inlines.js │ │ ├── inlines.min.js │ │ ├── jquery.init.js │ │ ├── popup_response.js │ │ ├── prepopulate.js │ │ ├── prepopulate.min.js │ │ ├── prepopulate_init.js │ │ ├── timeparse.js │ │ ├── urlify.js │ │ └── vendor │ │ ├── jquery │ │ ├── LICENSE-JQUERY.txt │ │ ├── jquery.js │ │ └── jquery.min.js │ │ └── xregexp │ │ ├── LICENSE-XREGEXP.txt │ │ ├── xregexp.js │ │ └── xregexp.min.js ├── css │ └── checkout.css ├── images │ └── cart.png └── js │ └── checkout.js ├── static_root ├── css │ └── checkout.css ├── images │ └── cart.png └── js │ └── checkout.js └── templates ├── advanced payment form ├── base.css ├── checkout.html ├── example-4.js ├── example4.css └── index.js ├── base.html ├── messages.html └── profile.html /.gitignore: -------------------------------------------------------------------------------- 1 | env 2 | *.pyc -------------------------------------------------------------------------------- /NOTES.md: -------------------------------------------------------------------------------- 1 | # How to add an object to a manytomany field 2 | https://docs.djangoproject.com/en/2.0/topics/db/examples/many_to_many/ 3 | 4 | # How to add *many* objects to a manytomany field 5 | https://stackoverflow.com/questions/4959499/how-to-add-multiple-objects-to-manytomany-relationship-at-once-in-django 6 | 7 | # Accepting payments with Stripe 8 | https://stripe.com/docs/quickstart 9 | 10 | # Styling forms 11 | https://stripe.com/docs/stripe-js/elements/migrating 12 | 13 | # Example credit card form 14 | https://stripe.com/docs/stripe-js/elements/quickstart 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |

3 | 4 | JustDjango 5 | 6 |

7 |

8 | The Definitive Django Learning Platform. 9 |

10 |

11 | 12 | ### *** Deprecation Warning *** 13 | 14 | This project is over two years old and is outdated. For e-commerce functionality we recommend taking a look at [this repository](https://github.com/justdjango/django-simple-ecommerce) 15 | 16 | # Django Shopping Cart 17 | 18 | A basic shopping cart for digital products using Stripe payments. 19 | 20 | *To Start*: Create a stripe account and put your stripe publishable key and secret key inside `settings.py` as well as your publishable key inside `checkout.js` in the static folder. Follow the tutorial here for working with the shopping cart: https://youtu.be/6aQanCJZx04. Follow this tutorial to see how to setup payments with Braintree: 21 | 22 | The password for the admin user is `matt1234`. 23 | 24 |

25 | 26 |

27 | 28 | --- 29 | 30 |
31 | 32 | Other places you can find us:
33 | 34 | YouTube 35 | Twitter 36 | 37 |
38 | -------------------------------------------------------------------------------- /accounts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/accounts/__init__.py -------------------------------------------------------------------------------- /accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | from .models import Profile 5 | 6 | admin.site.register(Profile) 7 | 8 | -------------------------------------------------------------------------------- /accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountsConfig(AppConfig): 5 | name = 'accounts' 6 | -------------------------------------------------------------------------------- /accounts/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.8 on 2018-05-31 09:37 3 | from __future__ import unicode_literals 4 | 5 | from django.conf import settings 6 | from django.db import migrations, models 7 | import django.db.models.deletion 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | initial = True 13 | 14 | dependencies = [ 15 | ('products', '__first__'), 16 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 17 | ] 18 | 19 | operations = [ 20 | migrations.CreateModel( 21 | name='Profile', 22 | fields=[ 23 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 24 | ('ebooks', models.ManyToManyField(to='products.Product')), 25 | ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 26 | ], 27 | ), 28 | ] 29 | -------------------------------------------------------------------------------- /accounts/migrations/0002_auto_20180603_2029.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.6 on 2018-06-03 20:29 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accounts', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='profile', 15 | name='ebooks', 16 | field=models.ManyToManyField(null=True, to='products.Product'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /accounts/migrations/0003_auto_20180603_2029.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.6 on 2018-06-03 20:29 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accounts', '0002_auto_20180603_2029'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='profile', 15 | name='ebooks', 16 | field=models.ManyToManyField(blank=True, to='products.Product'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /accounts/migrations/0004_userstripe.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.6 on 2018-06-05 21:08 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 12 | ('accounts', '0003_auto_20180603_2029'), 13 | ] 14 | 15 | operations = [ 16 | migrations.CreateModel( 17 | name='userStripe', 18 | fields=[ 19 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 20 | ('stripe_id', models.CharField(blank=True, max_length=200, null=True)), 21 | ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /accounts/migrations/0005_auto_20180606_0601.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.6 on 2018-06-06 06:01 2 | 3 | from django.conf import settings 4 | from django.db import migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 11 | ('accounts', '0004_userstripe'), 12 | ] 13 | 14 | operations = [ 15 | migrations.RenameModel( 16 | old_name='userStripe', 17 | new_name='StripeAccount', 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /accounts/migrations/0006_auto_20180606_0617.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.6 on 2018-06-06 06:17 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accounts', '0005_auto_20180606_0601'), 10 | ] 11 | 12 | operations = [ 13 | migrations.RemoveField( 14 | model_name='stripeaccount', 15 | name='user', 16 | ), 17 | migrations.AddField( 18 | model_name='profile', 19 | name='stripe_id', 20 | field=models.CharField(blank=True, max_length=200, null=True), 21 | ), 22 | migrations.DeleteModel( 23 | name='StripeAccount', 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /accounts/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/accounts/migrations/__init__.py -------------------------------------------------------------------------------- /accounts/models.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | from django.db import models 3 | from django.db.models.signals import post_save 4 | 5 | from products.models import Product 6 | 7 | import stripe 8 | 9 | stripe.api_key = settings.STRIPE_SECRET_KEY 10 | 11 | 12 | class Profile(models.Model): 13 | user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) 14 | ebooks = models.ManyToManyField(Product, blank=True) 15 | stripe_id = models.CharField(max_length=200, null=True, blank=True) 16 | 17 | def __str__(self): 18 | return self.user.username 19 | 20 | 21 | def post_save_profile_create(sender, instance, created, *args, **kwargs): 22 | user_profile, created = Profile.objects.get_or_create(user=instance) 23 | 24 | if user_profile.stripe_id is None or user_profile.stripe_id == '': 25 | new_stripe_id = stripe.Customer.create(email=instance.email) 26 | user_profile.stripe_id = new_stripe_id['id'] 27 | user_profile.save() 28 | 29 | 30 | post_save.connect(post_save_profile_create, sender=settings.AUTH_USER_MODEL) 31 | -------------------------------------------------------------------------------- /accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /accounts/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | 3 | from .views import my_profile 4 | 5 | app_name = 'accounts' 6 | 7 | urlpatterns = [ 8 | url(r'^profile/$', my_profile, name='my_profile') 9 | ] 10 | 11 | -------------------------------------------------------------------------------- /accounts/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404 2 | 3 | from shopping_cart.models import Order 4 | from .models import Profile 5 | 6 | 7 | def my_profile(request): 8 | my_user_profile = Profile.objects.filter(user=request.user).first() 9 | my_orders = Order.objects.filter(is_ordered=True, owner=my_user_profile) 10 | context = { 11 | 'my_orders': my_orders 12 | } 13 | 14 | return render(request, "profile.html", context) -------------------------------------------------------------------------------- /cart/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/cart/__init__.py -------------------------------------------------------------------------------- /cart/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 4 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 5 | 6 | 7 | # Quick-start development settings - unsuitable for production 8 | # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ 9 | 10 | # SECURITY WARNING: keep the secret key used in production secret! 11 | SECRET_KEY = ')o-g4bbm7sh%e$jjrn*$v1f)m^-2l8ok!m+(0@2-^+&1s0*dwz' 12 | 13 | # SECURITY WARNING: don't run with debug turned on in production! 14 | DEBUG = True 15 | 16 | ALLOWED_HOSTS = [] 17 | 18 | SEND_GRID_API_KEY = '' 19 | EMAIL_HOST = 'smtp.sendgrid.net' 20 | EMAIL_HOST_USER = '' 21 | EMAIL_HOST_PASSWORD = '' 22 | EMAIL_PORT = 587 23 | EMAIL_USE_TLS = True 24 | DEFAULT_FROM_EMAIL = '' 25 | ACCOUNT_EMAIL_SUBJECT_PREFIX = '' 26 | EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' 27 | 28 | # Application definition 29 | 30 | INSTALLED_APPS = [ 31 | 'django.contrib.admin', 32 | 'django.contrib.auth', 33 | 'django.contrib.contenttypes', 34 | 'django.contrib.sessions', 35 | 'django.contrib.messages', 36 | 'django.contrib.staticfiles', 37 | 38 | 'django.contrib.sites', # added for allauth 39 | 'allauth', 40 | 'allauth.account', 41 | 'allauth.socialaccount', 42 | 'stripe', 43 | 44 | 'accounts', 45 | 'products', 46 | 'shopping_cart' 47 | ] 48 | 49 | MIDDLEWARE = [ 50 | 'django.middleware.security.SecurityMiddleware', 51 | 'django.contrib.sessions.middleware.SessionMiddleware', 52 | 'django.middleware.common.CommonMiddleware', 53 | 'django.middleware.csrf.CsrfViewMiddleware', 54 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 55 | 'django.contrib.messages.middleware.MessageMiddleware', 56 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 57 | ] 58 | 59 | ROOT_URLCONF = 'cart.urls' 60 | 61 | TEMPLATES = [ 62 | { 63 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 64 | 'DIRS': [os.path.join(BASE_DIR, 'templates')] 65 | , 66 | 'APP_DIRS': True, 67 | 'OPTIONS': { 68 | 'context_processors': [ 69 | 'django.template.context_processors.debug', 70 | 'django.template.context_processors.request', 71 | 'django.contrib.auth.context_processors.auth', 72 | 'django.contrib.messages.context_processors.messages', 73 | ], 74 | }, 75 | }, 76 | ] 77 | 78 | WSGI_APPLICATION = 'cart.wsgi.application' 79 | 80 | 81 | # Database 82 | # https://docs.djangoproject.com/en/1.11/ref/settings/#databases 83 | 84 | DATABASES = { 85 | 'default': { 86 | 'ENGINE': 'django.db.backends.sqlite3', 87 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 88 | } 89 | } 90 | 91 | 92 | # Password validation 93 | # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators 94 | 95 | AUTH_PASSWORD_VALIDATORS = [ 96 | { 97 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 98 | }, 99 | { 100 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 101 | }, 102 | { 103 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 104 | }, 105 | { 106 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 107 | }, 108 | ] 109 | 110 | 111 | # Internationalization 112 | # https://docs.djangoproject.com/en/1.11/topics/i18n/ 113 | 114 | LANGUAGE_CODE = 'en-us' 115 | 116 | TIME_ZONE = 'UTC' 117 | 118 | USE_I18N = True 119 | 120 | USE_L10N = True 121 | 122 | USE_TZ = True 123 | 124 | 125 | # Static files (CSS, JavaScript, Images) 126 | # https://docs.djangoproject.com/en/1.11/howto/static-files/ 127 | 128 | STATIC_URL = '/static/' 129 | 130 | STATICFILES_DIRS = [ 131 | os.path.join(BASE_DIR, 'static_root'), 132 | ] 133 | 134 | VENV_PATH = os.path.dirname(BASE_DIR) 135 | 136 | STATIC_ROOT = os.path.join(BASE_DIR, 'static/') 137 | 138 | MEDIA_URL = '/media/' 139 | 140 | MEDIA_ROOT = os.path.join(VENV_PATH, 'media_root') 141 | 142 | 143 | # Stripe and Braintree Settings 144 | 145 | if DEBUG: 146 | # test keys 147 | STRIPE_PUBLISHABLE_KEY = '' 148 | STRIPE_SECRET_KEY = '' 149 | BT_ENVIRONMENT='sandbox' 150 | BT_MERCHANT_ID='YOUR BT_MERCHANT_ID' 151 | BT_PUBLIC_KEY='YOUR BT_PUBLIC_KEY' 152 | BT_PRIVATE_KEY='YOUR BT_PRIVATE_KEY' 153 | else: 154 | # live keys 155 | STRIPE_PUBLISHABLE_KEY = 'YOUR STRIPE LIVE PUB KEY' 156 | STRIPE_SECRET_KEY = 'YOUR STRIPE LIVE SECRET KEY' 157 | 158 | 159 | # Django AllAuth Settings 160 | 161 | AUTHENTICATION_BACKENDS = ( 162 | 'django.contrib.auth.backends.ModelBackend', 163 | 'allauth.account.auth_backends.AuthenticationBackend', 164 | ) 165 | 166 | SITE_ID = 1 167 | 168 | LOGIN_REDIRECT_URL = '/products' 169 | -------------------------------------------------------------------------------- /cart/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | from django.conf.urls import url, include 3 | from django.conf.urls.static import static 4 | from django.contrib import admin 5 | 6 | urlpatterns = [ 7 | url(r'^admin/', admin.site.urls), 8 | url(r'^profiles/', include('accounts.urls', namespace='accounts')), 9 | url(r'^products/', include('products.urls', namespace='products')), 10 | url(r'^cart/', include('shopping_cart.urls', namespace='shopping_cart')), 11 | url(r'^accounts/', include('allauth.urls')) 12 | ] 13 | 14 | if settings.DEBUG: 15 | urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) 16 | urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 17 | -------------------------------------------------------------------------------- /cart/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for cart project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cart.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/db.sqlite3 -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cart.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /products/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/products/__init__.py -------------------------------------------------------------------------------- /products/admin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.contrib import admin 5 | 6 | from .models import Product 7 | 8 | admin.site.register(Product) -------------------------------------------------------------------------------- /products/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.apps import AppConfig 5 | 6 | 7 | class ProductsConfig(AppConfig): 8 | name = 'products' 9 | -------------------------------------------------------------------------------- /products/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.8 on 2018-05-31 09:37 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | ] 14 | 15 | operations = [ 16 | migrations.CreateModel( 17 | name='Product', 18 | fields=[ 19 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 20 | ('name', models.CharField(max_length=120)), 21 | ('price', models.IntegerField()), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /products/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/products/migrations/__init__.py -------------------------------------------------------------------------------- /products/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models 5 | 6 | 7 | class Product(models.Model): 8 | name = models.CharField(max_length=120) 9 | price = models.IntegerField() 10 | 11 | def __str__(self): 12 | return self.name 13 | 14 | -------------------------------------------------------------------------------- /products/templates/products/product_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 | {{ message }} 5 |
6 | {% for object in object_list %} 7 |
8 |

{{ object.name }}

9 |

Price: ${{ object.price }}

10 | {% if object in user.profile.ebooks.all %} 11 | 12 | You own this 13 | {% elif object in current_order_products %} 14 | Go to Cart 15 | {% else %} 16 | Add to Cart 17 | {% endif %} 18 |
19 | {% endfor %} 20 |
21 | {% endblock content %} -------------------------------------------------------------------------------- /products/tests.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.test import TestCase 5 | 6 | # Create your tests here. 7 | -------------------------------------------------------------------------------- /products/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | 3 | from .views import product_list 4 | 5 | app_name = 'products' 6 | 7 | urlpatterns = [ 8 | url(r'^', product_list, name='product-list') 9 | ] 10 | -------------------------------------------------------------------------------- /products/views.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | from django.contrib.auth.decorators import login_required 3 | from django.shortcuts import render 4 | from shopping_cart.models import Order 5 | from .models import Product 6 | 7 | @login_required 8 | def product_list(request): 9 | object_list = Product.objects.all() 10 | filtered_orders = Order.objects.filter(owner=request.user.profile, is_ordered=False) 11 | current_order_products = [] 12 | if filtered_orders.exists(): 13 | user_order = filtered_orders[0] 14 | user_order_items = user_order.items.all() 15 | current_order_products = [product.product for product in user_order_items] 16 | 17 | context = { 18 | 'object_list': object_list, 19 | 'current_order_products': current_order_products 20 | } 21 | 22 | return render(request, "products/product_list.html", context) -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | braintree==3.53.0 2 | certifi==2018.4.16 3 | chardet==3.0.4 4 | defusedxml==0.5.0 5 | Django==2.2 6 | django-allauth==0.36.0 7 | idna==2.7 8 | oauthlib==2.1.0 9 | python3-openid==3.1.0 10 | pytz==2018.4 11 | requests==2.21.0 12 | requests-oauthlib==1.0.0 13 | sqlparse==0.3.0 14 | stripe==1.82.1 15 | urllib3==1.24.2 16 | -------------------------------------------------------------------------------- /shopping_cart/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/shopping_cart/__init__.py -------------------------------------------------------------------------------- /shopping_cart/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from .models import OrderItem, Order, Transaction 4 | 5 | admin.site.register(OrderItem) 6 | admin.site.register(Order) 7 | admin.site.register(Transaction) 8 | -------------------------------------------------------------------------------- /shopping_cart/apps.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.apps import AppConfig 4 | 5 | 6 | class ShoppingCartConfig(AppConfig): 7 | name = 'shopping_cart' 8 | -------------------------------------------------------------------------------- /shopping_cart/extras.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | import random 3 | import string 4 | from datetime import date 5 | import datetime 6 | import braintree 7 | from shopping_cart.models import OrderItem 8 | 9 | def generate_order_id(): 10 | date_str = date.today().strftime('%Y%m%d')[2:] + str(datetime.datetime.now().second) 11 | rand_str = "".join([random.choice(string.digits) for count in range(3)]) 12 | return date_str + rand_str 13 | 14 | gateway = braintree.BraintreeGateway( 15 | braintree.Configuration( 16 | environment=settings.BT_ENVIRONMENT, 17 | merchant_id=settings.BT_MERCHANT_ID, 18 | public_key=settings.BT_PUBLIC_KEY, 19 | private_key=settings.BT_PRIVATE_KEY 20 | ) 21 | ) 22 | 23 | def generate_client_token(): 24 | return gateway.client_token.generate() 25 | 26 | def transact(options): 27 | return gateway.transaction.sale(options) 28 | 29 | def find_transaction(id): 30 | return gateway.transaction.find(id) 31 | -------------------------------------------------------------------------------- /shopping_cart/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.8 on 2018-05-31 09:37 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | import django.db.models.deletion 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | initial = True 12 | 13 | dependencies = [ 14 | ('accounts', '0001_initial'), 15 | ('products', '0001_initial'), 16 | ] 17 | 18 | operations = [ 19 | migrations.CreateModel( 20 | name='Order', 21 | fields=[ 22 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 23 | ('ref_code', models.CharField(max_length=15)), 24 | ('is_ordered', models.BooleanField(default=False)), 25 | ('date_ordered', models.DateTimeField(auto_now=True)), 26 | ('VAT', models.FloatField(default=0.0)), 27 | ('voucher_applied', models.FloatField(default=0.0)), 28 | ], 29 | ), 30 | migrations.CreateModel( 31 | name='OrderItem', 32 | fields=[ 33 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 34 | ('is_ordered', models.BooleanField(default=False)), 35 | ('date_added', models.DateTimeField(auto_now=True)), 36 | ('date_ordered', models.DateTimeField(null=True)), 37 | ('product', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='products.Product')), 38 | ], 39 | ), 40 | migrations.CreateModel( 41 | name='Payment', 42 | fields=[ 43 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 44 | ('ref_code', models.CharField(max_length=15)), 45 | ('date_paid', models.DateTimeField(auto_now=True)), 46 | ('amount', models.FloatField(default=0.0)), 47 | ('gateway', models.CharField(max_length=50)), 48 | ('token', models.CharField(max_length=200)), 49 | ], 50 | ), 51 | migrations.CreateModel( 52 | name='PaymentMethod', 53 | fields=[ 54 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 55 | ('name', models.CharField(max_length=50)), 56 | ('icon_name', models.CharField(max_length=50)), 57 | ('is_active', models.BooleanField(default=False)), 58 | ('view_name', models.CharField(max_length=100)), 59 | ], 60 | ), 61 | migrations.AddField( 62 | model_name='order', 63 | name='items', 64 | field=models.ManyToManyField(to='shopping_cart.OrderItem'), 65 | ), 66 | migrations.AddField( 67 | model_name='order', 68 | name='owner', 69 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.Profile'), 70 | ), 71 | ] 72 | -------------------------------------------------------------------------------- /shopping_cart/migrations/0002_auto_20180531_0944.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.8 on 2018-05-31 09:44 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('shopping_cart', '0001_initial'), 12 | ] 13 | 14 | operations = [ 15 | migrations.RemoveField( 16 | model_name='order', 17 | name='VAT', 18 | ), 19 | migrations.RemoveField( 20 | model_name='order', 21 | name='voucher_applied', 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /shopping_cart/migrations/0003_auto_20180603_2020.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.6 on 2018-06-03 20:20 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('shopping_cart', '0002_auto_20180531_0944'), 11 | ] 12 | 13 | operations = [ 14 | migrations.DeleteModel( 15 | name='Payment', 16 | ), 17 | migrations.DeleteModel( 18 | name='PaymentMethod', 19 | ), 20 | migrations.AlterField( 21 | model_name='order', 22 | name='owner', 23 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='accounts.Profile'), 24 | ), 25 | migrations.AlterField( 26 | model_name='orderitem', 27 | name='product', 28 | field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, to='products.Product'), 29 | ), 30 | ] 31 | -------------------------------------------------------------------------------- /shopping_cart/migrations/0004_transaction.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11 on 2018-06-09 10:09 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | import django.db.models.deletion 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('accounts', '0006_auto_20180606_0617'), 13 | ('shopping_cart', '0003_auto_20180603_2020'), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Transaction', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('transaction_id', models.CharField(max_length=120)), 22 | ('order_id', models.CharField(max_length=120)), 23 | ('amount', models.DecimalField(decimal_places=2, max_digits=100)), 24 | ('success', models.BooleanField(default=True)), 25 | ('timestamp', models.DateTimeField(auto_now_add=True)), 26 | ('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.Profile')), 27 | ], 28 | options={ 29 | 'ordering': ['-timestamp'], 30 | }, 31 | ), 32 | ] 33 | -------------------------------------------------------------------------------- /shopping_cart/migrations/0005_auto_20180609_1016.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11 on 2018-06-09 10:16 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('shopping_cart', '0004_transaction'), 12 | ] 13 | 14 | operations = [ 15 | migrations.RenameField( 16 | model_name='transaction', 17 | old_name='transaction_id', 18 | new_name='token', 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /shopping_cart/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/shopping_cart/migrations/__init__.py -------------------------------------------------------------------------------- /shopping_cart/models.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.db import models 4 | 5 | from accounts.models import Profile 6 | from products.models import Product 7 | 8 | 9 | class OrderItem(models.Model): 10 | product = models.OneToOneField(Product, on_delete=models.SET_NULL, null=True) 11 | is_ordered = models.BooleanField(default=False) 12 | date_added = models.DateTimeField(auto_now=True) 13 | date_ordered = models.DateTimeField(null=True) 14 | 15 | def __str__(self): 16 | return self.product.name 17 | 18 | 19 | class Order(models.Model): 20 | ref_code = models.CharField(max_length=15) 21 | owner = models.ForeignKey(Profile, on_delete=models.SET_NULL, null=True) 22 | is_ordered = models.BooleanField(default=False) 23 | items = models.ManyToManyField(OrderItem) 24 | date_ordered = models.DateTimeField(auto_now=True) 25 | 26 | def get_cart_items(self): 27 | return self.items.all() 28 | 29 | def get_cart_total(self): 30 | return sum([item.product.price for item in self.items.all()]) 31 | 32 | def __str__(self): 33 | return '{0} - {1}'.format(self.owner, self.ref_code) 34 | 35 | 36 | class Transaction(models.Model): 37 | profile = models.ForeignKey(Profile, on_delete=models.CASCADE) 38 | token = models.CharField(max_length=120) 39 | order_id = models.CharField(max_length=120) 40 | amount = models.DecimalField(max_digits=100, decimal_places=2) 41 | success = models.BooleanField(default=True) 42 | timestamp = models.DateTimeField(auto_now_add=True, auto_now=False) 43 | 44 | def __str__(self): 45 | return self.order_id 46 | 47 | class Meta: 48 | ordering = ['-timestamp'] 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /shopping_cart/templates/shopping_cart/checkout.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | Checkout 7 | 8 | 9 | 22 | 23 | 24 | 25 | {% include 'messages.html' %} 26 |
27 |
28 |
29 |
30 |
31 | 32 |
33 |
Enter Voucher Code Below
If multiple, separate each with comma
34 | 35 |
36 |
37 | {% csrf_token %} 38 | 39 | 40 |
41 | 42 | 43 | 44 |
45 |
46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | 58 | 59 | 60 | 61 | {% endfor %} 62 | 63 | 64 | 65 | 66 | 67 | 68 |

Order Summary

56 | {% for item in order.get_cart_items %} 57 |
{{ item }}${{ item.product.price }}
Order Total ${{ order.get_cart_total }}
69 | 70 |
71 |
72 |
73 | 74 | 75 |
76 | 77 | 78 | 79 | 80 | 81 |
82 | {% csrf_token %} 83 |
84 |
85 |

Checkout with Braintree

86 |
87 |

Checkout with Stripe

88 |
89 | 92 |
93 | 94 | 95 | 96 |
97 | 98 |
99 |
100 | 101 |
102 | 103 |
104 | 105 | 106 | 107 |
108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 142 | 143 | 144 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /shopping_cart/templates/shopping_cart/order_summary.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | {% for item in order.get_cart_items %} 14 | 15 | 16 | 24 | 25 | 26 | {% empty %} 27 | 28 | 29 | 30 | {% endfor %} 31 | 32 | {% if order.get_cart_total != None %} 33 | 36 | 37 | 40 | {% endif %} 41 | 42 | 43 | 48 | 53 | 54 |
no.ItemPrice
{{ forloop.counter }} 17 | {{ item.product.name }} 18 | 19 | 20 | 21 | 22 | 23 | {{ item.product.price }}
You have not added any items yet.
34 | Order Total: 35 | 38 | ${{ order.get_cart_total }} 39 |
44 | 45 | {% if order %}Continue Shopping{% else %}Add Items to Cart {% endif %} 46 | 47 | 49 | {% if order.get_cart_items %} 50 | Proceed To Checkout 51 | {% endif %} 52 |
55 | 56 |
57 |
58 | {% endblock %} 59 | 60 | {% block scripts %} 61 | {{ block.super }} 62 | 67 | {% endblock scripts %} 68 | -------------------------------------------------------------------------------- /shopping_cart/templates/shopping_cart/purchase_success.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |

Thank you for your purchase!

5 | Head back home 6 | {% endblock content %} -------------------------------------------------------------------------------- /shopping_cart/templates/shopping_cart/stripe_default_form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /shopping_cart/templatetags/cart_template_tag.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | from shopping_cart.models import Order 3 | 4 | register = template.Library() 5 | 6 | 7 | @register.filter 8 | def cart_item_count(user): 9 | if user.is_authenticated: 10 | return Order.objects.filter(owner__user=user, is_ordered=False)[0].items.count() 11 | return 0 12 | -------------------------------------------------------------------------------- /shopping_cart/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /shopping_cart/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | 3 | from .views import ( 4 | add_to_cart, 5 | delete_from_cart, 6 | order_details, 7 | checkout, 8 | update_transaction_records, 9 | success 10 | ) 11 | 12 | app_name = 'shopping_cart' 13 | 14 | urlpatterns = [ 15 | url(r'^add-to-cart/(?P[-\w]+)/$', add_to_cart, name="add_to_cart"), 16 | url(r'^order-summary/$', order_details, name="order_summary"), 17 | url(r'^success/$', success, name='purchase_success'), 18 | url(r'^item/delete/(?P[-\w]+)/$', delete_from_cart, name='delete_item'), 19 | url(r'^checkout/$', checkout, name='checkout'), 20 | url(r'^update-transaction/(?P[-\w]+)/$', update_transaction_records, 21 | name='update_records') 22 | ] -------------------------------------------------------------------------------- /shopping_cart/views.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | from django.contrib import messages 3 | from django.contrib.auth.decorators import login_required 4 | from django.urls import reverse 5 | from django.shortcuts import render, redirect, get_object_or_404 6 | 7 | from accounts.models import Profile 8 | from products.models import Product 9 | 10 | from shopping_cart.extras import generate_order_id, transact, generate_client_token 11 | from shopping_cart.models import OrderItem, Order, Transaction 12 | 13 | import datetime 14 | import stripe 15 | 16 | stripe.api_key = settings.STRIPE_SECRET_KEY 17 | 18 | 19 | def get_user_pending_order(request): 20 | # get order for the correct user 21 | user_profile = get_object_or_404(Profile, user=request.user) 22 | order = Order.objects.filter(owner=user_profile, is_ordered=False) 23 | if order.exists(): 24 | # get the only order in the list of filtered orders 25 | return order[0] 26 | return 0 27 | 28 | 29 | @login_required() 30 | def add_to_cart(request, **kwargs): 31 | # get the user profile 32 | user_profile = get_object_or_404(Profile, user=request.user) 33 | # filter products by id 34 | product = Product.objects.filter(id=kwargs.get('item_id', "")).first() 35 | # check if the user already owns this product 36 | if product in request.user.profile.ebooks.all(): 37 | messages.info(request, 'You already own this ebook') 38 | return redirect(reverse('products:product-list')) 39 | # create orderItem of the selected product 40 | order_item, status = OrderItem.objects.get_or_create(product=product) 41 | # create order associated with the user 42 | user_order, status = Order.objects.get_or_create(owner=user_profile, is_ordered=False) 43 | user_order.items.add(order_item) 44 | if status: 45 | # generate a reference code 46 | user_order.ref_code = generate_order_id() 47 | user_order.save() 48 | 49 | # show confirmation message and redirect back to the same page 50 | messages.info(request, "item added to cart") 51 | return redirect(reverse('products:product-list')) 52 | 53 | 54 | @login_required() 55 | def delete_from_cart(request, item_id): 56 | item_to_delete = OrderItem.objects.filter(pk=item_id) 57 | if item_to_delete.exists(): 58 | item_to_delete[0].delete() 59 | messages.info(request, "Item has been deleted") 60 | return redirect(reverse('shopping_cart:order_summary')) 61 | 62 | 63 | @login_required() 64 | def order_details(request, **kwargs): 65 | existing_order = get_user_pending_order(request) 66 | context = { 67 | 'order': existing_order 68 | } 69 | return render(request, 'shopping_cart/order_summary.html', context) 70 | 71 | 72 | @login_required() 73 | def checkout(request, **kwargs): 74 | client_token = generate_client_token() 75 | existing_order = get_user_pending_order(request) 76 | publishKey = settings.STRIPE_PUBLISHABLE_KEY 77 | if request.method == 'POST': 78 | token = request.POST.get('stripeToken', False) 79 | if token: 80 | try: 81 | charge = stripe.Charge.create( 82 | amount=100*existing_order.get_cart_total(), 83 | currency='usd', 84 | description='Example charge', 85 | source=token, 86 | ) 87 | 88 | return redirect(reverse('shopping_cart:update_records', 89 | kwargs={ 90 | 'token': token 91 | }) 92 | ) 93 | except stripe.CardError as e: 94 | message.info(request, "Your card has been declined.") 95 | else: 96 | result = transact({ 97 | 'amount': existing_order.get_cart_total(), 98 | 'payment_method_nonce': request.POST['payment_method_nonce'], 99 | 'options': { 100 | "submit_for_settlement": True 101 | } 102 | }) 103 | 104 | if result.is_success or result.transaction: 105 | return redirect(reverse('shopping_cart:update_records', 106 | kwargs={ 107 | 'token': result.transaction.id 108 | }) 109 | ) 110 | else: 111 | for x in result.errors.deep_errors: 112 | messages.info(request, x) 113 | return redirect(reverse('shopping_cart:checkout')) 114 | 115 | context = { 116 | 'order': existing_order, 117 | 'client_token': client_token, 118 | 'STRIPE_PUBLISHABLE_KEY': publishKey 119 | } 120 | 121 | return render(request, 'shopping_cart/checkout.html', context) 122 | 123 | 124 | @login_required() 125 | def update_transaction_records(request, token): 126 | # get the order being processed 127 | order_to_purchase = get_user_pending_order(request) 128 | 129 | # update the placed order 130 | order_to_purchase.is_ordered=True 131 | order_to_purchase.date_ordered=datetime.datetime.now() 132 | order_to_purchase.save() 133 | 134 | # get all items in the order - generates a queryset 135 | order_items = order_to_purchase.items.all() 136 | 137 | # update order items 138 | order_items.update(is_ordered=True, date_ordered=datetime.datetime.now()) 139 | 140 | # Add products to user profile 141 | user_profile = get_object_or_404(Profile, user=request.user) 142 | # get the products from the items 143 | order_products = [item.product for item in order_items] 144 | user_profile.ebooks.add(*order_products) 145 | user_profile.save() 146 | 147 | 148 | # create a transaction 149 | transaction = Transaction(profile=request.user.profile, 150 | token=token, 151 | order_id=order_to_purchase.id, 152 | amount=order_to_purchase.get_cart_total(), 153 | success=True) 154 | # save the transcation (otherwise doesn't exist) 155 | transaction.save() 156 | 157 | 158 | # send an email to the customer 159 | # look at tutorial on how to send emails with sendgrid 160 | messages.info(request, "Thank you! Your purchase was successful!") 161 | return redirect(reverse('accounts:my_profile')) 162 | 163 | 164 | def success(request, **kwargs): 165 | # a view signifying the transcation was successful 166 | return render(request, 'shopping_cart/purchase_success.html', {}) 167 | -------------------------------------------------------------------------------- /static/admin/css/changelists.css: -------------------------------------------------------------------------------- 1 | /* CHANGELISTS */ 2 | 3 | #changelist { 4 | position: relative; 5 | width: 100%; 6 | } 7 | 8 | #changelist table { 9 | width: 100%; 10 | } 11 | 12 | .change-list .hiddenfields { display:none; } 13 | 14 | .change-list .filtered table { 15 | border-right: none; 16 | } 17 | 18 | .change-list .filtered { 19 | min-height: 400px; 20 | } 21 | 22 | .change-list .filtered .results, .change-list .filtered .paginator, 23 | .filtered #toolbar, .filtered div.xfull { 24 | margin-right: 280px; 25 | width: auto; 26 | } 27 | 28 | .change-list .filtered table tbody th { 29 | padding-right: 1em; 30 | } 31 | 32 | #changelist-form .results { 33 | overflow-x: auto; 34 | } 35 | 36 | #changelist .toplinks { 37 | border-bottom: 1px solid #ddd; 38 | } 39 | 40 | #changelist .paginator { 41 | color: #666; 42 | border-bottom: 1px solid #eee; 43 | background: #fff; 44 | overflow: hidden; 45 | } 46 | 47 | /* CHANGELIST TABLES */ 48 | 49 | #changelist table thead th { 50 | padding: 0; 51 | white-space: nowrap; 52 | vertical-align: middle; 53 | } 54 | 55 | #changelist table thead th.action-checkbox-column { 56 | width: 1.5em; 57 | text-align: center; 58 | } 59 | 60 | #changelist table tbody td.action-checkbox { 61 | text-align: center; 62 | } 63 | 64 | #changelist table tfoot { 65 | color: #666; 66 | } 67 | 68 | /* TOOLBAR */ 69 | 70 | #changelist #toolbar { 71 | padding: 8px 10px; 72 | margin-bottom: 15px; 73 | border-top: 1px solid #eee; 74 | border-bottom: 1px solid #eee; 75 | background: #f8f8f8; 76 | color: #666; 77 | } 78 | 79 | #changelist #toolbar form input { 80 | border-radius: 4px; 81 | font-size: 14px; 82 | padding: 5px; 83 | color: #333; 84 | } 85 | 86 | #changelist #toolbar form #searchbar { 87 | height: 19px; 88 | border: 1px solid #ccc; 89 | padding: 2px 5px; 90 | margin: 0; 91 | vertical-align: top; 92 | font-size: 13px; 93 | } 94 | 95 | #changelist #toolbar form #searchbar:focus { 96 | border-color: #999; 97 | } 98 | 99 | #changelist #toolbar form input[type="submit"] { 100 | border: 1px solid #ccc; 101 | padding: 2px 10px; 102 | margin: 0; 103 | vertical-align: middle; 104 | background: #fff; 105 | box-shadow: 0 -15px 20px -10px rgba(0, 0, 0, 0.15) inset; 106 | cursor: pointer; 107 | color: #333; 108 | } 109 | 110 | #changelist #toolbar form input[type="submit"]:focus, 111 | #changelist #toolbar form input[type="submit"]:hover { 112 | border-color: #999; 113 | } 114 | 115 | #changelist #changelist-search img { 116 | vertical-align: middle; 117 | margin-right: 4px; 118 | } 119 | 120 | /* FILTER COLUMN */ 121 | 122 | #changelist-filter { 123 | position: absolute; 124 | top: 0; 125 | right: 0; 126 | z-index: 1000; 127 | width: 240px; 128 | background: #f8f8f8; 129 | border-left: none; 130 | margin: 0; 131 | } 132 | 133 | #changelist-filter h2 { 134 | font-size: 14px; 135 | text-transform: uppercase; 136 | letter-spacing: 0.5px; 137 | padding: 5px 15px; 138 | margin-bottom: 12px; 139 | border-bottom: none; 140 | } 141 | 142 | #changelist-filter h3 { 143 | font-weight: 400; 144 | font-size: 14px; 145 | padding: 0 15px; 146 | margin-bottom: 10px; 147 | } 148 | 149 | #changelist-filter ul { 150 | margin: 5px 0; 151 | padding: 0 15px 15px; 152 | border-bottom: 1px solid #eaeaea; 153 | } 154 | 155 | #changelist-filter ul:last-child { 156 | border-bottom: none; 157 | padding-bottom: none; 158 | } 159 | 160 | #changelist-filter li { 161 | list-style-type: none; 162 | margin-left: 0; 163 | padding-left: 0; 164 | } 165 | 166 | #changelist-filter a { 167 | display: block; 168 | color: #999; 169 | text-overflow: ellipsis; 170 | overflow-x: hidden; 171 | } 172 | 173 | #changelist-filter li.selected { 174 | border-left: 5px solid #eaeaea; 175 | padding-left: 10px; 176 | margin-left: -15px; 177 | } 178 | 179 | #changelist-filter li.selected a { 180 | color: #5b80b2; 181 | } 182 | 183 | #changelist-filter a:focus, #changelist-filter a:hover, 184 | #changelist-filter li.selected a:focus, 185 | #changelist-filter li.selected a:hover { 186 | color: #036; 187 | } 188 | 189 | /* DATE DRILLDOWN */ 190 | 191 | .change-list ul.toplinks { 192 | display: block; 193 | float: left; 194 | padding: 0; 195 | margin: 0; 196 | width: 100%; 197 | } 198 | 199 | .change-list ul.toplinks li { 200 | padding: 3px 6px; 201 | font-weight: bold; 202 | list-style-type: none; 203 | display: inline-block; 204 | } 205 | 206 | .change-list ul.toplinks .date-back a { 207 | color: #999; 208 | } 209 | 210 | .change-list ul.toplinks .date-back a:focus, 211 | .change-list ul.toplinks .date-back a:hover { 212 | color: #036; 213 | } 214 | 215 | /* PAGINATOR */ 216 | 217 | .paginator { 218 | font-size: 13px; 219 | padding-top: 10px; 220 | padding-bottom: 10px; 221 | line-height: 22px; 222 | margin: 0; 223 | border-top: 1px solid #ddd; 224 | } 225 | 226 | .paginator a:link, .paginator a:visited { 227 | padding: 2px 6px; 228 | background: #79aec8; 229 | text-decoration: none; 230 | color: #fff; 231 | } 232 | 233 | .paginator a.showall { 234 | padding: 0; 235 | border: none; 236 | background: none; 237 | color: #5b80b2; 238 | } 239 | 240 | .paginator a.showall:focus, .paginator a.showall:hover { 241 | background: none; 242 | color: #036; 243 | } 244 | 245 | .paginator .end { 246 | margin-right: 6px; 247 | } 248 | 249 | .paginator .this-page { 250 | padding: 2px 6px; 251 | font-weight: bold; 252 | font-size: 13px; 253 | vertical-align: top; 254 | } 255 | 256 | .paginator a:focus, .paginator a:hover { 257 | color: white; 258 | background: #036; 259 | } 260 | 261 | /* ACTIONS */ 262 | 263 | .filtered .actions { 264 | margin-right: 280px; 265 | border-right: none; 266 | } 267 | 268 | #changelist table input { 269 | margin: 0; 270 | vertical-align: baseline; 271 | } 272 | 273 | #changelist table tbody tr.selected { 274 | background-color: #FFFFCC; 275 | } 276 | 277 | #changelist .actions { 278 | padding: 10px; 279 | background: #fff; 280 | border-top: none; 281 | border-bottom: none; 282 | line-height: 24px; 283 | color: #999; 284 | } 285 | 286 | #changelist .actions.selected { 287 | background: #fffccf; 288 | border-top: 1px solid #fffee8; 289 | border-bottom: 1px solid #edecd6; 290 | } 291 | 292 | #changelist .actions span.all, 293 | #changelist .actions span.action-counter, 294 | #changelist .actions span.clear, 295 | #changelist .actions span.question { 296 | font-size: 13px; 297 | margin: 0 0.5em; 298 | display: none; 299 | } 300 | 301 | #changelist .actions:last-child { 302 | border-bottom: none; 303 | } 304 | 305 | #changelist .actions select { 306 | vertical-align: top; 307 | height: 24px; 308 | background: none; 309 | color: #000; 310 | border: 1px solid #ccc; 311 | border-radius: 4px; 312 | font-size: 14px; 313 | padding: 0 0 0 4px; 314 | margin: 0; 315 | margin-left: 10px; 316 | } 317 | 318 | #changelist .actions select:focus { 319 | border-color: #999; 320 | } 321 | 322 | #changelist .actions label { 323 | display: inline-block; 324 | vertical-align: middle; 325 | font-size: 13px; 326 | } 327 | 328 | #changelist .actions .button { 329 | font-size: 13px; 330 | border: 1px solid #ccc; 331 | border-radius: 4px; 332 | background: #fff; 333 | box-shadow: 0 -15px 20px -10px rgba(0, 0, 0, 0.15) inset; 334 | cursor: pointer; 335 | height: 24px; 336 | line-height: 1; 337 | padding: 4px 8px; 338 | margin: 0; 339 | color: #333; 340 | } 341 | 342 | #changelist .actions .button:focus, #changelist .actions .button:hover { 343 | border-color: #999; 344 | } 345 | -------------------------------------------------------------------------------- /static/admin/css/dashboard.css: -------------------------------------------------------------------------------- 1 | /* DASHBOARD */ 2 | 3 | .dashboard .module table th { 4 | width: 100%; 5 | } 6 | 7 | .dashboard .module table td { 8 | white-space: nowrap; 9 | } 10 | 11 | .dashboard .module table td a { 12 | display: block; 13 | padding-right: .6em; 14 | } 15 | 16 | /* RECENT ACTIONS MODULE */ 17 | 18 | .module ul.actionlist { 19 | margin-left: 0; 20 | } 21 | 22 | ul.actionlist li { 23 | list-style-type: none; 24 | overflow: hidden; 25 | text-overflow: ellipsis; 26 | -o-text-overflow: ellipsis; 27 | } 28 | -------------------------------------------------------------------------------- /static/admin/css/fonts.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Roboto'; 3 | src: url('../fonts/Roboto-Bold-webfont.woff'); 4 | font-weight: 700; 5 | font-style: normal; 6 | } 7 | 8 | @font-face { 9 | font-family: 'Roboto'; 10 | src: url('../fonts/Roboto-Regular-webfont.woff'); 11 | font-weight: 400; 12 | font-style: normal; 13 | } 14 | 15 | @font-face { 16 | font-family: 'Roboto'; 17 | src: url('../fonts/Roboto-Light-webfont.woff'); 18 | font-weight: 300; 19 | font-style: normal; 20 | } 21 | -------------------------------------------------------------------------------- /static/admin/css/forms.css: -------------------------------------------------------------------------------- 1 | @import url('widgets.css'); 2 | 3 | /* FORM ROWS */ 4 | 5 | .form-row { 6 | overflow: hidden; 7 | padding: 10px; 8 | font-size: 13px; 9 | border-bottom: 1px solid #eee; 10 | } 11 | 12 | .form-row img, .form-row input { 13 | vertical-align: middle; 14 | } 15 | 16 | .form-row label input[type="checkbox"] { 17 | margin-top: 0; 18 | vertical-align: 0; 19 | } 20 | 21 | form .form-row p { 22 | padding-left: 0; 23 | } 24 | 25 | .hidden { 26 | display: none; 27 | } 28 | 29 | /* FORM LABELS */ 30 | 31 | label { 32 | font-weight: normal; 33 | color: #666; 34 | font-size: 13px; 35 | } 36 | 37 | .required label, label.required { 38 | font-weight: bold; 39 | color: #333; 40 | } 41 | 42 | /* RADIO BUTTONS */ 43 | 44 | form ul.radiolist li { 45 | list-style-type: none; 46 | } 47 | 48 | form ul.radiolist label { 49 | float: none; 50 | display: inline; 51 | } 52 | 53 | form ul.radiolist input[type="radio"] { 54 | margin: -2px 4px 0 0; 55 | padding: 0; 56 | } 57 | 58 | form ul.inline { 59 | margin-left: 0; 60 | padding: 0; 61 | } 62 | 63 | form ul.inline li { 64 | float: left; 65 | padding-right: 7px; 66 | } 67 | 68 | /* ALIGNED FIELDSETS */ 69 | 70 | .aligned label { 71 | display: block; 72 | padding: 4px 10px 0 0; 73 | float: left; 74 | width: 160px; 75 | word-wrap: break-word; 76 | line-height: 1; 77 | } 78 | 79 | .aligned label:not(.vCheckboxLabel):after { 80 | content: ''; 81 | display: inline-block; 82 | vertical-align: middle; 83 | height: 26px; 84 | } 85 | 86 | .aligned label + p, .aligned label + div.help, .aligned label + div.readonly { 87 | padding: 6px 0; 88 | margin-top: 0; 89 | margin-bottom: 0; 90 | margin-left: 170px; 91 | } 92 | 93 | .aligned ul label { 94 | display: inline; 95 | float: none; 96 | width: auto; 97 | } 98 | 99 | .aligned .form-row input { 100 | margin-bottom: 0; 101 | } 102 | 103 | .colMS .aligned .vLargeTextField, .colMS .aligned .vXMLLargeTextField { 104 | width: 350px; 105 | } 106 | 107 | form .aligned ul { 108 | margin-left: 160px; 109 | padding-left: 10px; 110 | } 111 | 112 | form .aligned ul.radiolist { 113 | display: inline-block; 114 | margin: 0; 115 | padding: 0; 116 | } 117 | 118 | form .aligned p.help, 119 | form .aligned div.help { 120 | clear: left; 121 | margin-top: 0; 122 | margin-left: 160px; 123 | padding-left: 10px; 124 | } 125 | 126 | form .aligned label + p.help, 127 | form .aligned label + div.help { 128 | margin-left: 0; 129 | padding-left: 0; 130 | } 131 | 132 | form .aligned p.help:last-child, 133 | form .aligned div.help:last-child { 134 | margin-bottom: 0; 135 | padding-bottom: 0; 136 | } 137 | 138 | form .aligned input + p.help, 139 | form .aligned textarea + p.help, 140 | form .aligned select + p.help, 141 | form .aligned input + div.help, 142 | form .aligned textarea + div.help, 143 | form .aligned select + div.help { 144 | margin-left: 160px; 145 | padding-left: 10px; 146 | } 147 | 148 | form .aligned ul li { 149 | list-style: none; 150 | } 151 | 152 | form .aligned table p { 153 | margin-left: 0; 154 | padding-left: 0; 155 | } 156 | 157 | .aligned .vCheckboxLabel { 158 | float: none; 159 | width: auto; 160 | display: inline-block; 161 | vertical-align: -3px; 162 | padding: 0 0 5px 5px; 163 | } 164 | 165 | .aligned .vCheckboxLabel + p.help, 166 | .aligned .vCheckboxLabel + div.help { 167 | margin-top: -4px; 168 | } 169 | 170 | .colM .aligned .vLargeTextField, .colM .aligned .vXMLLargeTextField { 171 | width: 610px; 172 | } 173 | 174 | .checkbox-row p.help, 175 | .checkbox-row div.help { 176 | margin-left: 0; 177 | padding-left: 0; 178 | } 179 | 180 | fieldset .field-box { 181 | float: left; 182 | margin-right: 20px; 183 | } 184 | 185 | /* WIDE FIELDSETS */ 186 | 187 | .wide label { 188 | width: 200px; 189 | } 190 | 191 | form .wide p, 192 | form .wide input + p.help, 193 | form .wide input + div.help { 194 | margin-left: 200px; 195 | } 196 | 197 | form .wide p.help, 198 | form .wide div.help { 199 | padding-left: 38px; 200 | } 201 | 202 | form div.help ul { 203 | padding-left: 0; 204 | margin-left: 0; 205 | } 206 | 207 | .colM fieldset.wide .vLargeTextField, .colM fieldset.wide .vXMLLargeTextField { 208 | width: 450px; 209 | } 210 | 211 | /* COLLAPSED FIELDSETS */ 212 | 213 | fieldset.collapsed * { 214 | display: none; 215 | } 216 | 217 | fieldset.collapsed h2, fieldset.collapsed { 218 | display: block; 219 | } 220 | 221 | fieldset.collapsed { 222 | border: 1px solid #eee; 223 | border-radius: 4px; 224 | overflow: hidden; 225 | } 226 | 227 | fieldset.collapsed h2 { 228 | background: #f8f8f8; 229 | color: #666; 230 | } 231 | 232 | fieldset .collapse-toggle { 233 | color: #fff; 234 | } 235 | 236 | fieldset.collapsed .collapse-toggle { 237 | background: transparent; 238 | display: inline; 239 | color: #447e9b; 240 | } 241 | 242 | /* MONOSPACE TEXTAREAS */ 243 | 244 | fieldset.monospace textarea { 245 | font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace; 246 | } 247 | 248 | /* SUBMIT ROW */ 249 | 250 | .submit-row { 251 | padding: 12px 14px; 252 | margin: 0 0 20px; 253 | background: #f8f8f8; 254 | border: 1px solid #eee; 255 | border-radius: 4px; 256 | text-align: right; 257 | overflow: hidden; 258 | } 259 | 260 | body.popup .submit-row { 261 | overflow: auto; 262 | } 263 | 264 | .submit-row input { 265 | height: 35px; 266 | line-height: 15px; 267 | margin: 0 0 0 5px; 268 | } 269 | 270 | .submit-row input.default { 271 | margin: 0 0 0 8px; 272 | text-transform: uppercase; 273 | } 274 | 275 | .submit-row p { 276 | margin: 0.3em; 277 | } 278 | 279 | .submit-row p.deletelink-box { 280 | float: left; 281 | margin: 0; 282 | } 283 | 284 | .submit-row a.deletelink { 285 | display: block; 286 | background: #ba2121; 287 | border-radius: 4px; 288 | padding: 10px 15px; 289 | height: 15px; 290 | line-height: 15px; 291 | color: #fff; 292 | } 293 | 294 | .submit-row a.deletelink:focus, 295 | .submit-row a.deletelink:hover, 296 | .submit-row a.deletelink:active { 297 | background: #a41515; 298 | } 299 | 300 | /* CUSTOM FORM FIELDS */ 301 | 302 | .vSelectMultipleField { 303 | vertical-align: top; 304 | } 305 | 306 | .vCheckboxField { 307 | border: none; 308 | } 309 | 310 | .vDateField, .vTimeField { 311 | margin-right: 2px; 312 | margin-bottom: 4px; 313 | } 314 | 315 | .vDateField { 316 | min-width: 6.85em; 317 | } 318 | 319 | .vTimeField { 320 | min-width: 4.7em; 321 | } 322 | 323 | .vURLField { 324 | width: 30em; 325 | } 326 | 327 | .vLargeTextField, .vXMLLargeTextField { 328 | width: 48em; 329 | } 330 | 331 | .flatpages-flatpage #id_content { 332 | height: 40.2em; 333 | } 334 | 335 | .module table .vPositiveSmallIntegerField { 336 | width: 2.2em; 337 | } 338 | 339 | .vTextField { 340 | width: 20em; 341 | } 342 | 343 | .vIntegerField { 344 | width: 5em; 345 | } 346 | 347 | .vBigIntegerField { 348 | width: 10em; 349 | } 350 | 351 | .vForeignKeyRawIdAdminField { 352 | width: 5em; 353 | } 354 | 355 | /* INLINES */ 356 | 357 | .inline-group { 358 | padding: 0; 359 | margin: 0 0 30px; 360 | } 361 | 362 | .inline-group thead th { 363 | padding: 8px 10px; 364 | } 365 | 366 | .inline-group .aligned label { 367 | width: 160px; 368 | } 369 | 370 | .inline-related { 371 | position: relative; 372 | } 373 | 374 | .inline-related h3 { 375 | margin: 0; 376 | color: #666; 377 | padding: 5px; 378 | font-size: 13px; 379 | background: #f8f8f8; 380 | border-top: 1px solid #eee; 381 | border-bottom: 1px solid #eee; 382 | } 383 | 384 | .inline-related h3 span.delete { 385 | float: right; 386 | } 387 | 388 | .inline-related h3 span.delete label { 389 | margin-left: 2px; 390 | font-size: 11px; 391 | } 392 | 393 | .inline-related fieldset { 394 | margin: 0; 395 | background: #fff; 396 | border: none; 397 | width: 100%; 398 | } 399 | 400 | .inline-related fieldset.module h3 { 401 | margin: 0; 402 | padding: 2px 5px 3px 5px; 403 | font-size: 11px; 404 | text-align: left; 405 | font-weight: bold; 406 | background: #bcd; 407 | color: #fff; 408 | } 409 | 410 | .inline-group .tabular fieldset.module { 411 | border: none; 412 | } 413 | 414 | .inline-related.tabular fieldset.module table { 415 | width: 100%; 416 | } 417 | 418 | .last-related fieldset { 419 | border: none; 420 | } 421 | 422 | .inline-group .tabular tr.has_original td { 423 | padding-top: 2em; 424 | } 425 | 426 | .inline-group .tabular tr td.original { 427 | padding: 2px 0 0 0; 428 | width: 0; 429 | _position: relative; 430 | } 431 | 432 | .inline-group .tabular th.original { 433 | width: 0px; 434 | padding: 0; 435 | } 436 | 437 | .inline-group .tabular td.original p { 438 | position: absolute; 439 | left: 0; 440 | height: 1.1em; 441 | padding: 2px 9px; 442 | overflow: hidden; 443 | font-size: 9px; 444 | font-weight: bold; 445 | color: #666; 446 | _width: 700px; 447 | } 448 | 449 | .inline-group ul.tools { 450 | padding: 0; 451 | margin: 0; 452 | list-style: none; 453 | } 454 | 455 | .inline-group ul.tools li { 456 | display: inline; 457 | padding: 0 5px; 458 | } 459 | 460 | .inline-group div.add-row, 461 | .inline-group .tabular tr.add-row td { 462 | color: #666; 463 | background: #f8f8f8; 464 | padding: 8px 10px; 465 | border-bottom: 1px solid #eee; 466 | } 467 | 468 | .inline-group .tabular tr.add-row td { 469 | padding: 8px 10px; 470 | border-bottom: 1px solid #eee; 471 | } 472 | 473 | .inline-group ul.tools a.add, 474 | .inline-group div.add-row a, 475 | .inline-group .tabular tr.add-row td a { 476 | background: url(../img/icon-addlink.svg) 0 1px no-repeat; 477 | padding-left: 16px; 478 | font-size: 12px; 479 | } 480 | 481 | .empty-form { 482 | display: none; 483 | } 484 | 485 | /* RELATED FIELD ADD ONE / LOOKUP */ 486 | 487 | .add-another, .related-lookup { 488 | margin-left: 5px; 489 | display: inline-block; 490 | vertical-align: middle; 491 | background-repeat: no-repeat; 492 | background-size: 14px; 493 | } 494 | 495 | .add-another { 496 | width: 16px; 497 | height: 16px; 498 | background-image: url(../img/icon-addlink.svg); 499 | } 500 | 501 | .related-lookup { 502 | width: 16px; 503 | height: 16px; 504 | background-image: url(../img/search.svg); 505 | } 506 | 507 | form .related-widget-wrapper ul { 508 | display: inline-block; 509 | margin-left: 0; 510 | padding-left: 0; 511 | } 512 | 513 | .clearable-file-input input { 514 | margin-top: 0; 515 | } 516 | -------------------------------------------------------------------------------- /static/admin/css/login.css: -------------------------------------------------------------------------------- 1 | /* LOGIN FORM */ 2 | 3 | body.login { 4 | background: #f8f8f8; 5 | } 6 | 7 | .login #header { 8 | height: auto; 9 | padding: 5px 16px; 10 | } 11 | 12 | .login #header h1 { 13 | font-size: 18px; 14 | } 15 | 16 | .login #header h1 a { 17 | color: #fff; 18 | } 19 | 20 | .login #content { 21 | padding: 20px 20px 0; 22 | } 23 | 24 | .login #container { 25 | background: #fff; 26 | border: 1px solid #eaeaea; 27 | border-radius: 4px; 28 | overflow: hidden; 29 | width: 28em; 30 | min-width: 300px; 31 | margin: 100px auto; 32 | } 33 | 34 | .login #content-main { 35 | width: 100%; 36 | } 37 | 38 | .login .form-row { 39 | padding: 4px 0; 40 | float: left; 41 | width: 100%; 42 | border-bottom: none; 43 | } 44 | 45 | .login .form-row label { 46 | padding-right: 0.5em; 47 | line-height: 2em; 48 | font-size: 1em; 49 | clear: both; 50 | color: #333; 51 | } 52 | 53 | .login .form-row #id_username, .login .form-row #id_password { 54 | clear: both; 55 | padding: 8px; 56 | width: 100%; 57 | -webkit-box-sizing: border-box; 58 | -moz-box-sizing: border-box; 59 | box-sizing: border-box; 60 | } 61 | 62 | .login span.help { 63 | font-size: 10px; 64 | display: block; 65 | } 66 | 67 | .login .submit-row { 68 | clear: both; 69 | padding: 1em 0 0 9.4em; 70 | margin: 0; 71 | border: none; 72 | background: none; 73 | text-align: left; 74 | } 75 | 76 | .login .password-reset-link { 77 | text-align: center; 78 | } 79 | -------------------------------------------------------------------------------- /static/admin/css/rtl.css: -------------------------------------------------------------------------------- 1 | body { 2 | direction: rtl; 3 | } 4 | 5 | /* LOGIN */ 6 | 7 | .login .form-row { 8 | float: right; 9 | } 10 | 11 | .login .form-row label { 12 | float: right; 13 | padding-left: 0.5em; 14 | padding-right: 0; 15 | text-align: left; 16 | } 17 | 18 | .login .submit-row { 19 | clear: both; 20 | padding: 1em 9.4em 0 0; 21 | } 22 | 23 | /* GLOBAL */ 24 | 25 | th { 26 | text-align: right; 27 | } 28 | 29 | .module h2, .module caption { 30 | text-align: right; 31 | } 32 | 33 | .module ul, .module ol { 34 | margin-left: 0; 35 | margin-right: 1.5em; 36 | } 37 | 38 | .addlink, .changelink { 39 | padding-left: 0; 40 | padding-right: 16px; 41 | background-position: 100% 1px; 42 | } 43 | 44 | .deletelink { 45 | padding-left: 0; 46 | padding-right: 16px; 47 | background-position: 100% 1px; 48 | } 49 | 50 | .object-tools { 51 | float: left; 52 | } 53 | 54 | thead th:first-child, 55 | tfoot td:first-child { 56 | border-left: none; 57 | } 58 | 59 | /* LAYOUT */ 60 | 61 | #user-tools { 62 | right: auto; 63 | left: 0; 64 | text-align: left; 65 | } 66 | 67 | div.breadcrumbs { 68 | text-align: right; 69 | } 70 | 71 | #content-main { 72 | float: right; 73 | } 74 | 75 | #content-related { 76 | float: left; 77 | margin-left: -300px; 78 | margin-right: auto; 79 | } 80 | 81 | .colMS { 82 | margin-left: 300px; 83 | margin-right: 0; 84 | } 85 | 86 | /* SORTABLE TABLES */ 87 | 88 | table thead th.sorted .sortoptions { 89 | float: left; 90 | } 91 | 92 | thead th.sorted .text { 93 | padding-right: 0; 94 | padding-left: 42px; 95 | } 96 | 97 | /* dashboard styles */ 98 | 99 | .dashboard .module table td a { 100 | padding-left: .6em; 101 | padding-right: 16px; 102 | } 103 | 104 | /* changelists styles */ 105 | 106 | .change-list .filtered table { 107 | border-left: none; 108 | border-right: 0px none; 109 | } 110 | 111 | #changelist-filter { 112 | right: auto; 113 | left: 0; 114 | border-left: none; 115 | border-right: none; 116 | } 117 | 118 | .change-list .filtered .results, .change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull { 119 | margin-right: 0; 120 | margin-left: 280px; 121 | } 122 | 123 | #changelist-filter li.selected { 124 | border-left: none; 125 | padding-left: 10px; 126 | margin-left: 0; 127 | border-right: 5px solid #eaeaea; 128 | padding-right: 10px; 129 | margin-right: -15px; 130 | } 131 | 132 | .filtered .actions { 133 | margin-left: 280px; 134 | margin-right: 0; 135 | } 136 | 137 | #changelist table tbody td:first-child, #changelist table tbody th:first-child { 138 | border-right: none; 139 | border-left: none; 140 | } 141 | 142 | /* FORMS */ 143 | 144 | .aligned label { 145 | padding: 0 0 3px 1em; 146 | float: right; 147 | } 148 | 149 | .submit-row { 150 | text-align: left 151 | } 152 | 153 | .submit-row p.deletelink-box { 154 | float: right; 155 | } 156 | 157 | .submit-row input.default { 158 | margin-left: 0; 159 | } 160 | 161 | .vDateField, .vTimeField { 162 | margin-left: 2px; 163 | } 164 | 165 | .aligned .form-row input { 166 | margin-left: 5px; 167 | } 168 | 169 | form .aligned p.help, form .aligned div.help { 170 | clear: right; 171 | } 172 | 173 | form ul.inline li { 174 | float: right; 175 | padding-right: 0; 176 | padding-left: 7px; 177 | } 178 | 179 | input[type=submit].default, .submit-row input.default { 180 | float: left; 181 | } 182 | 183 | fieldset .field-box { 184 | float: right; 185 | margin-left: 20px; 186 | margin-right: 0; 187 | } 188 | 189 | .errorlist li { 190 | background-position: 100% 12px; 191 | padding: 0; 192 | } 193 | 194 | .errornote { 195 | background-position: 100% 12px; 196 | padding: 10px 12px; 197 | } 198 | 199 | /* WIDGETS */ 200 | 201 | .calendarnav-previous { 202 | top: 0; 203 | left: auto; 204 | right: 10px; 205 | } 206 | 207 | .calendarnav-next { 208 | top: 0; 209 | right: auto; 210 | left: 10px; 211 | } 212 | 213 | .calendar caption, .calendarbox h2 { 214 | text-align: center; 215 | } 216 | 217 | .selector { 218 | float: right; 219 | } 220 | 221 | .selector .selector-filter { 222 | text-align: right; 223 | } 224 | 225 | .inline-deletelink { 226 | float: left; 227 | } 228 | 229 | form .form-row p.datetime { 230 | overflow: hidden; 231 | } 232 | 233 | .related-widget-wrapper { 234 | float: right; 235 | } 236 | 237 | /* MISC */ 238 | 239 | .inline-related h2, .inline-group h2 { 240 | text-align: right 241 | } 242 | 243 | .inline-related h3 span.delete { 244 | padding-right: 20px; 245 | padding-left: inherit; 246 | left: 10px; 247 | right: inherit; 248 | float:left; 249 | } 250 | 251 | .inline-related h3 span.delete label { 252 | margin-left: inherit; 253 | margin-right: 2px; 254 | } 255 | 256 | /* IE7 specific bug fixes */ 257 | 258 | div.colM { 259 | position: relative; 260 | } 261 | 262 | .submit-row input { 263 | float: left; 264 | } 265 | -------------------------------------------------------------------------------- /static/admin/fonts/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /static/admin/fonts/README.txt: -------------------------------------------------------------------------------- 1 | Roboto webfont source: https://www.google.com/fonts/specimen/Roboto 2 | Weights used in this project: Light (300), Regular (400), Bold (700) 3 | -------------------------------------------------------------------------------- /static/admin/fonts/Roboto-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/static/admin/fonts/Roboto-Bold-webfont.woff -------------------------------------------------------------------------------- /static/admin/fonts/Roboto-Light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/static/admin/fonts/Roboto-Light-webfont.woff -------------------------------------------------------------------------------- /static/admin/fonts/Roboto-Regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/static/admin/fonts/Roboto-Regular-webfont.woff -------------------------------------------------------------------------------- /static/admin/img/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Code Charm Ltd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /static/admin/img/README.txt: -------------------------------------------------------------------------------- 1 | All icons are taken from Font Awesome (http://fontawesome.io/) project. 2 | The Font Awesome font is licensed under the SIL OFL 1.1: 3 | - http://scripts.sil.org/OFL 4 | 5 | SVG icons source: https://github.com/encharm/Font-Awesome-SVG-PNG 6 | Font-Awesome-SVG-PNG is licensed under the MIT license (see file license 7 | in current folder). 8 | -------------------------------------------------------------------------------- /static/admin/img/calendar-icons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /static/admin/img/gis/move_vertex_off.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/admin/img/gis/move_vertex_on.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/admin/img/icon-addlink.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/icon-alert.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/icon-calendar.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /static/admin/img/icon-changelink.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/icon-clock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /static/admin/img/icon-deletelink.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/icon-no.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/icon-unknown-alt.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/icon-unknown.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/icon-yes.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/inline-delete.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/selector-icons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /static/admin/img/sorting-icons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /static/admin/img/tooltag-add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/img/tooltag-arrowright.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/admin/js/SelectBox.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | 'use strict'; 3 | var SelectBox = { 4 | cache: {}, 5 | init: function(id) { 6 | var box = document.getElementById(id); 7 | var node; 8 | SelectBox.cache[id] = []; 9 | var cache = SelectBox.cache[id]; 10 | var boxOptions = box.options; 11 | var boxOptionsLength = boxOptions.length; 12 | for (var i = 0, j = boxOptionsLength; i < j; i++) { 13 | node = boxOptions[i]; 14 | cache.push({value: node.value, text: node.text, displayed: 1}); 15 | } 16 | }, 17 | redisplay: function(id) { 18 | // Repopulate HTML select box from cache 19 | var box = document.getElementById(id); 20 | var node; 21 | $(box).empty(); // clear all options 22 | var new_options = box.outerHTML.slice(0, -9); // grab just the opening tag 23 | var cache = SelectBox.cache[id]; 24 | for (var i = 0, j = cache.length; i < j; i++) { 25 | node = cache[i]; 26 | if (node.displayed) { 27 | var new_option = new Option(node.text, node.value, false, false); 28 | // Shows a tooltip when hovering over the option 29 | new_option.setAttribute("title", node.text); 30 | new_options += new_option.outerHTML; 31 | } 32 | } 33 | new_options += ''; 34 | box.outerHTML = new_options; 35 | }, 36 | filter: function(id, text) { 37 | // Redisplay the HTML select box, displaying only the choices containing ALL 38 | // the words in text. (It's an AND search.) 39 | var tokens = text.toLowerCase().split(/\s+/); 40 | var node, token; 41 | var cache = SelectBox.cache[id]; 42 | for (var i = 0, j = cache.length; i < j; i++) { 43 | node = cache[i]; 44 | node.displayed = 1; 45 | var node_text = node.text.toLowerCase(); 46 | var numTokens = tokens.length; 47 | for (var k = 0; k < numTokens; k++) { 48 | token = tokens[k]; 49 | if (node_text.indexOf(token) === -1) { 50 | node.displayed = 0; 51 | break; // Once the first token isn't found we're done 52 | } 53 | } 54 | } 55 | SelectBox.redisplay(id); 56 | }, 57 | delete_from_cache: function(id, value) { 58 | var node, delete_index = null; 59 | var cache = SelectBox.cache[id]; 60 | for (var i = 0, j = cache.length; i < j; i++) { 61 | node = cache[i]; 62 | if (node.value === value) { 63 | delete_index = i; 64 | break; 65 | } 66 | } 67 | cache.splice(delete_index, 1); 68 | }, 69 | add_to_cache: function(id, option) { 70 | SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1}); 71 | }, 72 | cache_contains: function(id, value) { 73 | // Check if an item is contained in the cache 74 | var node; 75 | var cache = SelectBox.cache[id]; 76 | for (var i = 0, j = cache.length; i < j; i++) { 77 | node = cache[i]; 78 | if (node.value === value) { 79 | return true; 80 | } 81 | } 82 | return false; 83 | }, 84 | move: function(from, to) { 85 | var from_box = document.getElementById(from); 86 | var option; 87 | var boxOptions = from_box.options; 88 | var boxOptionsLength = boxOptions.length; 89 | for (var i = 0, j = boxOptionsLength; i < j; i++) { 90 | option = boxOptions[i]; 91 | var option_value = option.value; 92 | if (option.selected && SelectBox.cache_contains(from, option_value)) { 93 | SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1}); 94 | SelectBox.delete_from_cache(from, option_value); 95 | } 96 | } 97 | SelectBox.redisplay(from); 98 | SelectBox.redisplay(to); 99 | }, 100 | move_all: function(from, to) { 101 | var from_box = document.getElementById(from); 102 | var option; 103 | var boxOptions = from_box.options; 104 | var boxOptionsLength = boxOptions.length; 105 | for (var i = 0, j = boxOptionsLength; i < j; i++) { 106 | option = boxOptions[i]; 107 | var option_value = option.value; 108 | if (SelectBox.cache_contains(from, option_value)) { 109 | SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1}); 110 | SelectBox.delete_from_cache(from, option_value); 111 | } 112 | } 113 | SelectBox.redisplay(from); 114 | SelectBox.redisplay(to); 115 | }, 116 | sort: function(id) { 117 | SelectBox.cache[id].sort(function(a, b) { 118 | a = a.text.toLowerCase(); 119 | b = b.text.toLowerCase(); 120 | try { 121 | if (a > b) { 122 | return 1; 123 | } 124 | if (a < b) { 125 | return -1; 126 | } 127 | } 128 | catch (e) { 129 | // silently fail on IE 'unknown' exception 130 | } 131 | return 0; 132 | } ); 133 | }, 134 | select_all: function(id) { 135 | var box = document.getElementById(id); 136 | var boxOptions = box.options; 137 | var boxOptionsLength = boxOptions.length; 138 | for (var i = 0; i < boxOptionsLength; i++) { 139 | boxOptions[i].selected = 'selected'; 140 | } 141 | } 142 | }; 143 | window.SelectBox = SelectBox; 144 | })(django.jQuery); 145 | -------------------------------------------------------------------------------- /static/admin/js/actions.js: -------------------------------------------------------------------------------- 1 | /*global gettext, interpolate, ngettext*/ 2 | (function($) { 3 | 'use strict'; 4 | var lastChecked; 5 | 6 | $.fn.actions = function(opts) { 7 | var options = $.extend({}, $.fn.actions.defaults, opts); 8 | var actionCheckboxes = $(this); 9 | var list_editable_changed = false; 10 | var showQuestion = function() { 11 | $(options.acrossClears).hide(); 12 | $(options.acrossQuestions).show(); 13 | $(options.allContainer).hide(); 14 | }, 15 | showClear = function() { 16 | $(options.acrossClears).show(); 17 | $(options.acrossQuestions).hide(); 18 | $(options.actionContainer).toggleClass(options.selectedClass); 19 | $(options.allContainer).show(); 20 | $(options.counterContainer).hide(); 21 | }, 22 | reset = function() { 23 | $(options.acrossClears).hide(); 24 | $(options.acrossQuestions).hide(); 25 | $(options.allContainer).hide(); 26 | $(options.counterContainer).show(); 27 | }, 28 | clearAcross = function() { 29 | reset(); 30 | $(options.acrossInput).val(0); 31 | $(options.actionContainer).removeClass(options.selectedClass); 32 | }, 33 | checker = function(checked) { 34 | if (checked) { 35 | showQuestion(); 36 | } else { 37 | reset(); 38 | } 39 | $(actionCheckboxes).prop("checked", checked) 40 | .parent().parent().toggleClass(options.selectedClass, checked); 41 | }, 42 | updateCounter = function() { 43 | var sel = $(actionCheckboxes).filter(":checked").length; 44 | // data-actions-icnt is defined in the generated HTML 45 | // and contains the total amount of objects in the queryset 46 | var actions_icnt = $('.action-counter').data('actionsIcnt'); 47 | $(options.counterContainer).html(interpolate( 48 | ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), { 49 | sel: sel, 50 | cnt: actions_icnt 51 | }, true)); 52 | $(options.allToggle).prop("checked", function() { 53 | var value; 54 | if (sel === actionCheckboxes.length) { 55 | value = true; 56 | showQuestion(); 57 | } else { 58 | value = false; 59 | clearAcross(); 60 | } 61 | return value; 62 | }); 63 | }; 64 | // Show counter by default 65 | $(options.counterContainer).show(); 66 | // Check state of checkboxes and reinit state if needed 67 | $(this).filter(":checked").each(function(i) { 68 | $(this).parent().parent().toggleClass(options.selectedClass); 69 | updateCounter(); 70 | if ($(options.acrossInput).val() === 1) { 71 | showClear(); 72 | } 73 | }); 74 | $(options.allToggle).show().click(function() { 75 | checker($(this).prop("checked")); 76 | updateCounter(); 77 | }); 78 | $("a", options.acrossQuestions).click(function(event) { 79 | event.preventDefault(); 80 | $(options.acrossInput).val(1); 81 | showClear(); 82 | }); 83 | $("a", options.acrossClears).click(function(event) { 84 | event.preventDefault(); 85 | $(options.allToggle).prop("checked", false); 86 | clearAcross(); 87 | checker(0); 88 | updateCounter(); 89 | }); 90 | lastChecked = null; 91 | $(actionCheckboxes).click(function(event) { 92 | if (!event) { event = window.event; } 93 | var target = event.target ? event.target : event.srcElement; 94 | if (lastChecked && $.data(lastChecked) !== $.data(target) && event.shiftKey === true) { 95 | var inrange = false; 96 | $(lastChecked).prop("checked", target.checked) 97 | .parent().parent().toggleClass(options.selectedClass, target.checked); 98 | $(actionCheckboxes).each(function() { 99 | if ($.data(this) === $.data(lastChecked) || $.data(this) === $.data(target)) { 100 | inrange = (inrange) ? false : true; 101 | } 102 | if (inrange) { 103 | $(this).prop("checked", target.checked) 104 | .parent().parent().toggleClass(options.selectedClass, target.checked); 105 | } 106 | }); 107 | } 108 | $(target).parent().parent().toggleClass(options.selectedClass, target.checked); 109 | lastChecked = target; 110 | updateCounter(); 111 | }); 112 | $('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() { 113 | list_editable_changed = true; 114 | }); 115 | $('form#changelist-form button[name="index"]').click(function(event) { 116 | if (list_editable_changed) { 117 | return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost.")); 118 | } 119 | }); 120 | $('form#changelist-form input[name="_save"]').click(function(event) { 121 | var action_changed = false; 122 | $('select option:selected', options.actionContainer).each(function() { 123 | if ($(this).val()) { 124 | action_changed = true; 125 | } 126 | }); 127 | if (action_changed) { 128 | if (list_editable_changed) { 129 | return confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")); 130 | } else { 131 | return confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button.")); 132 | } 133 | } 134 | }); 135 | }; 136 | /* Setup plugin defaults */ 137 | $.fn.actions.defaults = { 138 | actionContainer: "div.actions", 139 | counterContainer: "span.action-counter", 140 | allContainer: "div.actions span.all", 141 | acrossInput: "div.actions input.select-across", 142 | acrossQuestions: "div.actions span.question", 143 | acrossClears: "div.actions span.clear", 144 | allToggle: "#action-toggle", 145 | selectedClass: "selected" 146 | }; 147 | $(document).ready(function() { 148 | var $actionsEls = $('tr input.action-select'); 149 | if ($actionsEls.length > 0) { 150 | $actionsEls.actions(); 151 | } 152 | }); 153 | })(django.jQuery); 154 | -------------------------------------------------------------------------------- /static/admin/js/actions.min.js: -------------------------------------------------------------------------------- 1 | (function(a){var f;a.fn.actions=function(e){var b=a.extend({},a.fn.actions.defaults,e),g=a(this),k=!1,l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()},m=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},n=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},p=function(){n(); 2 | a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},q=function(c){c?l():n();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length,d=a(".action-counter").data("actionsIcnt");a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:d},!0));a(b.allToggle).prop("checked",function(){var a;c===g.length?(a=!0,l()):(a=!1,p());return a})};a(b.counterContainer).show(); 3 | a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);h();1===a(b.acrossInput).val()&&m()});a(b.allToggle).show().click(function(){q(a(this).prop("checked"));h()});a("a",b.acrossQuestions).click(function(c){c.preventDefault();a(b.acrossInput).val(1);m()});a("a",b.acrossClears).click(function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);p();q(0);h()});f=null;a(g).click(function(c){c||(c=window.event);var d=c.target?c.target:c.srcElement;if(f&& 4 | a.data(f)!==a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(g).each(function(){if(a.data(this)===a.data(f)||a.data(this)===a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").find("td:gt(0) :input").change(function(){k=!0});a('form#changelist-form button[name="index"]').click(function(a){if(k)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))}); 5 | a('form#changelist-form input[name="_save"]').click(function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return k?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})}; 6 | a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"};a(document).ready(function(){var e=a("tr input.action-select");0' + gettext("Show") + 11 | ')'); 12 | } 13 | }); 14 | // Add toggle to anchor tag 15 | $("fieldset.collapse a.collapse-toggle").click(function(ev) { 16 | if ($(this).closest("fieldset").hasClass("collapsed")) { 17 | // Show 18 | $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]); 19 | } else { 20 | // Hide 21 | $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]); 22 | } 23 | return false; 24 | }); 25 | }); 26 | })(django.jQuery); 27 | -------------------------------------------------------------------------------- /static/admin/js/collapse.min.js: -------------------------------------------------------------------------------- 1 | (function(a){a(document).ready(function(){a("fieldset.collapse").each(function(b,c){0===a(c).find("div.errors").length&&a(c).addClass("collapsed").find("h2").first().append(' ('+gettext("Show")+")")});a("fieldset.collapse a.collapse-toggle").click(function(b){a(this).closest("fieldset").hasClass("collapsed")?a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset",[a(this).attr("id")]):a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", 2 | [a(this).attr("id")]);return!1})})})(django.jQuery); 3 | -------------------------------------------------------------------------------- /static/admin/js/core.js: -------------------------------------------------------------------------------- 1 | // Core javascript helper functions 2 | 3 | // basic browser identification & version 4 | var isOpera = (navigator.userAgent.indexOf("Opera") >= 0) && parseFloat(navigator.appVersion); 5 | var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]); 6 | 7 | // Cross-browser event handlers. 8 | function addEvent(obj, evType, fn) { 9 | 'use strict'; 10 | if (obj.addEventListener) { 11 | obj.addEventListener(evType, fn, false); 12 | return true; 13 | } else if (obj.attachEvent) { 14 | var r = obj.attachEvent("on" + evType, fn); 15 | return r; 16 | } else { 17 | return false; 18 | } 19 | } 20 | 21 | function removeEvent(obj, evType, fn) { 22 | 'use strict'; 23 | if (obj.removeEventListener) { 24 | obj.removeEventListener(evType, fn, false); 25 | return true; 26 | } else if (obj.detachEvent) { 27 | obj.detachEvent("on" + evType, fn); 28 | return true; 29 | } else { 30 | return false; 31 | } 32 | } 33 | 34 | function cancelEventPropagation(e) { 35 | 'use strict'; 36 | if (!e) { 37 | e = window.event; 38 | } 39 | e.cancelBubble = true; 40 | if (e.stopPropagation) { 41 | e.stopPropagation(); 42 | } 43 | } 44 | 45 | // quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]); 46 | function quickElement() { 47 | 'use strict'; 48 | var obj = document.createElement(arguments[0]); 49 | if (arguments[2]) { 50 | var textNode = document.createTextNode(arguments[2]); 51 | obj.appendChild(textNode); 52 | } 53 | var len = arguments.length; 54 | for (var i = 3; i < len; i += 2) { 55 | obj.setAttribute(arguments[i], arguments[i + 1]); 56 | } 57 | arguments[1].appendChild(obj); 58 | return obj; 59 | } 60 | 61 | // "a" is reference to an object 62 | function removeChildren(a) { 63 | 'use strict'; 64 | while (a.hasChildNodes()) { 65 | a.removeChild(a.lastChild); 66 | } 67 | } 68 | 69 | // ---------------------------------------------------------------------------- 70 | // Find-position functions by PPK 71 | // See http://www.quirksmode.org/js/findpos.html 72 | // ---------------------------------------------------------------------------- 73 | function findPosX(obj) { 74 | 'use strict'; 75 | var curleft = 0; 76 | if (obj.offsetParent) { 77 | while (obj.offsetParent) { 78 | curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft); 79 | obj = obj.offsetParent; 80 | } 81 | // IE offsetParent does not include the top-level 82 | if (isIE && obj.parentElement) { 83 | curleft += obj.offsetLeft - obj.scrollLeft; 84 | } 85 | } else if (obj.x) { 86 | curleft += obj.x; 87 | } 88 | return curleft; 89 | } 90 | 91 | function findPosY(obj) { 92 | 'use strict'; 93 | var curtop = 0; 94 | if (obj.offsetParent) { 95 | while (obj.offsetParent) { 96 | curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop); 97 | obj = obj.offsetParent; 98 | } 99 | // IE offsetParent does not include the top-level 100 | if (isIE && obj.parentElement) { 101 | curtop += obj.offsetTop - obj.scrollTop; 102 | } 103 | } else if (obj.y) { 104 | curtop += obj.y; 105 | } 106 | return curtop; 107 | } 108 | 109 | //----------------------------------------------------------------------------- 110 | // Date object extensions 111 | // ---------------------------------------------------------------------------- 112 | (function() { 113 | 'use strict'; 114 | Date.prototype.getTwelveHours = function() { 115 | var hours = this.getHours(); 116 | if (hours === 0) { 117 | return 12; 118 | } 119 | else { 120 | return hours <= 12 ? hours : hours - 12; 121 | } 122 | }; 123 | 124 | Date.prototype.getTwoDigitMonth = function() { 125 | return (this.getMonth() < 9) ? '0' + (this.getMonth() + 1) : (this.getMonth() + 1); 126 | }; 127 | 128 | Date.prototype.getTwoDigitDate = function() { 129 | return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate(); 130 | }; 131 | 132 | Date.prototype.getTwoDigitTwelveHour = function() { 133 | return (this.getTwelveHours() < 10) ? '0' + this.getTwelveHours() : this.getTwelveHours(); 134 | }; 135 | 136 | Date.prototype.getTwoDigitHour = function() { 137 | return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours(); 138 | }; 139 | 140 | Date.prototype.getTwoDigitMinute = function() { 141 | return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes(); 142 | }; 143 | 144 | Date.prototype.getTwoDigitSecond = function() { 145 | return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds(); 146 | }; 147 | 148 | Date.prototype.getHourMinute = function() { 149 | return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute(); 150 | }; 151 | 152 | Date.prototype.getHourMinuteSecond = function() { 153 | return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond(); 154 | }; 155 | 156 | Date.prototype.getFullMonthName = function() { 157 | return typeof window.CalendarNamespace === "undefined" 158 | ? this.getTwoDigitMonth() 159 | : window.CalendarNamespace.monthsOfYear[this.getMonth()]; 160 | }; 161 | 162 | Date.prototype.strftime = function(format) { 163 | var fields = { 164 | B: this.getFullMonthName(), 165 | c: this.toString(), 166 | d: this.getTwoDigitDate(), 167 | H: this.getTwoDigitHour(), 168 | I: this.getTwoDigitTwelveHour(), 169 | m: this.getTwoDigitMonth(), 170 | M: this.getTwoDigitMinute(), 171 | p: (this.getHours() >= 12) ? 'PM' : 'AM', 172 | S: this.getTwoDigitSecond(), 173 | w: '0' + this.getDay(), 174 | x: this.toLocaleDateString(), 175 | X: this.toLocaleTimeString(), 176 | y: ('' + this.getFullYear()).substr(2, 4), 177 | Y: '' + this.getFullYear(), 178 | '%': '%' 179 | }; 180 | var result = '', i = 0; 181 | while (i < format.length) { 182 | if (format.charAt(i) === '%') { 183 | result = result + fields[format.charAt(i + 1)]; 184 | ++i; 185 | } 186 | else { 187 | result = result + format.charAt(i); 188 | } 189 | ++i; 190 | } 191 | return result; 192 | }; 193 | 194 | // ---------------------------------------------------------------------------- 195 | // String object extensions 196 | // ---------------------------------------------------------------------------- 197 | String.prototype.pad_left = function(pad_length, pad_string) { 198 | var new_string = this; 199 | for (var i = 0; new_string.length < pad_length; i++) { 200 | new_string = pad_string + new_string; 201 | } 202 | return new_string; 203 | }; 204 | 205 | String.prototype.strptime = function(format) { 206 | var split_format = format.split(/[.\-/]/); 207 | var date = this.split(/[.\-/]/); 208 | var i = 0; 209 | var day, month, year; 210 | while (i < split_format.length) { 211 | switch (split_format[i]) { 212 | case "%d": 213 | day = date[i]; 214 | break; 215 | case "%m": 216 | month = date[i] - 1; 217 | break; 218 | case "%Y": 219 | year = date[i]; 220 | break; 221 | case "%y": 222 | year = date[i]; 223 | break; 224 | } 225 | ++i; 226 | } 227 | // Create Date object from UTC since the parsed value is supposed to be 228 | // in UTC, not local time. Also, the calendar uses UTC functions for 229 | // date extraction. 230 | return new Date(Date.UTC(year, month, day)); 231 | }; 232 | 233 | })(); 234 | // ---------------------------------------------------------------------------- 235 | // Get the computed style for and element 236 | // ---------------------------------------------------------------------------- 237 | function getStyle(oElm, strCssRule) { 238 | 'use strict'; 239 | var strValue = ""; 240 | if(document.defaultView && document.defaultView.getComputedStyle) { 241 | strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); 242 | } 243 | else if(oElm.currentStyle) { 244 | strCssRule = strCssRule.replace(/\-(\w)/g, function(strMatch, p1) { 245 | return p1.toUpperCase(); 246 | }); 247 | strValue = oElm.currentStyle[strCssRule]; 248 | } 249 | return strValue; 250 | } 251 | -------------------------------------------------------------------------------- /static/admin/js/inlines.min.js: -------------------------------------------------------------------------------- 1 | (function(c){c.fn.formset=function(b){var a=c.extend({},c.fn.formset.defaults,b),d=c(this);b=d.parent();var k=function(a,g,l){var b=new RegExp("("+g+"-(\\d+|__prefix__))");g=g+"-"+l;c(a).prop("for")&&c(a).prop("for",c(a).prop("for").replace(b,g));a.id&&(a.id=a.id.replace(b,g));a.name&&(a.name=a.name.replace(b,g))},e=c("#id_"+a.prefix+"-TOTAL_FORMS").prop("autocomplete","off"),l=parseInt(e.val(),10),g=c("#id_"+a.prefix+"-MAX_NUM_FORMS").prop("autocomplete","off"),h=""===g.val()||0'+a.addText+""),m=b.find("tr:last a")):(d.filter(":last").after('"),m=d.filter(":last").next().find("a")));m.click(function(b){b.preventDefault();b=c("#"+a.prefix+"-empty"); 3 | var f=b.clone(!0);f.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+l);f.is("tr")?f.children(":last").append('"):f.is("ul")||f.is("ol")?f.append('
  • '+a.deleteText+"
  • "):f.children(":first").append(''+a.deleteText+"");f.find("*").each(function(){k(this,a.prefix,e.val())});f.insertBefore(c(b)); 4 | c(e).val(parseInt(e.val(),10)+1);l+=1;""!==g.val()&&0>=g.val()-e.val()&&m.parent().hide();f.find("a."+a.deleteCssClass).click(function(b){b.preventDefault();f.remove();--l;a.removed&&a.removed(f);c(document).trigger("formset:removed",[f,a.prefix]);b=c("."+a.formCssClass);c("#id_"+a.prefix+"-TOTAL_FORMS").val(b.length);(""===g.val()||0 0) { 26 | values.push(field.val()); 27 | } 28 | }); 29 | prepopulatedField.val(URLify(values.join(' '), maxLength, allowUnicode)); 30 | }; 31 | 32 | prepopulatedField.data('_changed', false); 33 | prepopulatedField.change(function() { 34 | prepopulatedField.data('_changed', true); 35 | }); 36 | 37 | if (!prepopulatedField.val()) { 38 | $(dependencies.join(',')).keyup(populate).change(populate).focus(populate); 39 | } 40 | }); 41 | }; 42 | })(django.jQuery); 43 | -------------------------------------------------------------------------------- /static/admin/js/prepopulate.min.js: -------------------------------------------------------------------------------- 1 | (function(c){c.fn.prepopulate=function(e,f,g){return this.each(function(){var a=c(this),b=function(){if(!a.data("_changed")){var b=[];c.each(e,function(a,d){d=c(d);0 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /static/css/checkout.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | height: 100%; 3 | background-color: #f7f8f9; 4 | color: #6b7c93; 5 | } 6 | 7 | *, label { 8 | font-family: "Helvetica Neue", Helvetica, sans-serif; 9 | font-size: 16px; 10 | font-variant: normal; 11 | padding: 0; 12 | margin: 0; 13 | -webkit-font-smoothing: antialiased; 14 | } 15 | 16 | button { 17 | border: none; 18 | border-radius: 4px; 19 | outline: none; 20 | text-decoration: none; 21 | color: #fff; 22 | background: #32325d; 23 | white-space: nowrap; 24 | display: inline-block; 25 | height: 40px; 26 | line-height: 40px; 27 | padding: 0 14px; 28 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08); 29 | border-radius: 4px; 30 | font-size: 15px; 31 | font-weight: 600; 32 | letter-spacing: 0.025em; 33 | text-decoration: none; 34 | -webkit-transition: all 150ms ease; 35 | transition: all 150ms ease; 36 | float: left; 37 | margin-left: 12px; 38 | margin-top: 28px; 39 | } 40 | 41 | button:hover { 42 | transform: translateY(-1px); 43 | box-shadow: 0 7px 14px rgba(50, 50, 93, .10), 0 3px 6px rgba(0, 0, 0, .08); 44 | background-color: #43458b; 45 | } 46 | 47 | form { 48 | padding: 30px; 49 | height: 120px; 50 | } 51 | 52 | label { 53 | font-weight: 500; 54 | font-size: 14px; 55 | display: block; 56 | margin-bottom: 8px; 57 | } 58 | 59 | #card-errors { 60 | height: 20px; 61 | padding: 4px 0; 62 | color: #fa755a; 63 | } 64 | 65 | .form-row { 66 | width: 70%; 67 | float: left; 68 | } 69 | 70 | .token { 71 | color: #32325d; 72 | font-family: 'Source Code Pro', monospace; 73 | font-weight: 500; 74 | } 75 | 76 | .wrapper { 77 | width: 670px; 78 | margin: 0 auto; 79 | height: 100%; 80 | } 81 | 82 | #stripe-token-handler { 83 | position: absolute; 84 | top: 0; 85 | left: 25%; 86 | right: 25%; 87 | padding: 20px 30px; 88 | border-radius: 0 0 4px 4px; 89 | box-sizing: border-box; 90 | box-shadow: 0 50px 100px rgba(50, 50, 93, 0.1), 91 | 0 15px 35px rgba(50, 50, 93, 0.15), 92 | 0 5px 15px rgba(0, 0, 0, 0.1); 93 | -webkit-transition: all 500ms ease-in-out; 94 | transition: all 500ms ease-in-out; 95 | transform: translateY(0); 96 | opacity: 1; 97 | background-color: white; 98 | } 99 | 100 | #stripe-token-handler.is-hidden { 101 | opacity: 0; 102 | transform: translateY(-80px); 103 | } 104 | 105 | /** 106 | * The CSS shown here will not be introduced in the Quickstart guide, but shows 107 | * how you can use CSS to style your Element's container. 108 | */ 109 | .StripeElement { 110 | background-color: white; 111 | height: 40px; 112 | padding: 10px 12px; 113 | border-radius: 4px; 114 | border: 1px solid transparent; 115 | box-shadow: 0 1px 3px 0 #e6ebf1; 116 | -webkit-transition: box-shadow 150ms ease; 117 | transition: box-shadow 150ms ease; 118 | } 119 | 120 | .StripeElement--focus { 121 | box-shadow: 0 1px 3px 0 #cfd7df; 122 | } 123 | 124 | .StripeElement--invalid { 125 | border-color: #fa755a; 126 | } 127 | 128 | .StripeElement--webkit-autofill { 129 | background-color: #fefde5 !important; 130 | } -------------------------------------------------------------------------------- /static/images/cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/static/images/cart.png -------------------------------------------------------------------------------- /static/js/checkout.js: -------------------------------------------------------------------------------- 1 | // Create a Stripe client. 2 | 3 | var stripe = Stripe(''); 4 | 5 | // Create an instance of Elements. 6 | var elements = stripe.elements(); 7 | 8 | // Custom styling can be passed to options when creating an Element. 9 | // (Note that this demo uses a wider set of styles than the guide below.) 10 | var style = { 11 | base: { 12 | color: '#32325d', 13 | lineHeight: '18px', 14 | fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 15 | fontSmoothing: 'antialiased', 16 | fontSize: '16px', 17 | '::placeholder': { 18 | color: '#aab7c4' 19 | } 20 | }, 21 | invalid: { 22 | color: '#fa755a', 23 | iconColor: '#fa755a' 24 | } 25 | }; 26 | 27 | // Create an instance of the card Element. 28 | var card = elements.create('card', {style: style}); 29 | 30 | // Add an instance of the card Element into the `card-element`
    . 31 | card.mount('#card-element'); 32 | 33 | // Handle real-time validation errors from the card Element. 34 | card.addEventListener('change', function(event) { 35 | var displayError = document.getElementById('card-errors'); 36 | if (event.error) { 37 | displayError.textContent = event.error.message; 38 | } else { 39 | displayError.textContent = ''; 40 | } 41 | }); 42 | 43 | // Handle form submission. 44 | var form = document.getElementById('payment-form'); 45 | form.addEventListener('submit', function(event) { 46 | event.preventDefault(); 47 | 48 | stripe.createToken(card).then(function(result) { 49 | if (result.error) { 50 | // Inform the user if there was an error. 51 | var errorElement = document.getElementById('card-errors'); 52 | errorElement.textContent = result.error.message; 53 | } else { 54 | // Send the token to your server. 55 | stripeTokenHandler(result.token); 56 | } 57 | }); 58 | 59 | }); 60 | 61 | var successElement = document.getElementById('stripe-token-handler'); 62 | document.querySelector('.wrapper').addEventListener('click', function() { 63 | successElement.className = 'is-hidden'; 64 | }); 65 | 66 | function stripeTokenHandler(token) { 67 | successElement.className = ''; 68 | successElement.querySelector('.token').textContent = token.id; 69 | // Insert the token ID into the form so it gets submitted to the server 70 | var form = document.getElementById('payment-form'); 71 | var hiddenInput = document.createElement('input'); 72 | hiddenInput.setAttribute('type', 'hidden'); 73 | hiddenInput.setAttribute('name', 'stripeToken'); 74 | hiddenInput.setAttribute('value', token.id); 75 | form.appendChild(hiddenInput); 76 | 77 | // Submit the form 78 | form.submit(); 79 | } 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /static_root/css/checkout.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | height: 100%; 3 | background-color: #f7f8f9; 4 | color: #6b7c93; 5 | } 6 | 7 | *, label { 8 | font-family: "Helvetica Neue", Helvetica, sans-serif; 9 | font-size: 16px; 10 | font-variant: normal; 11 | padding: 0; 12 | margin: 0; 13 | -webkit-font-smoothing: antialiased; 14 | } 15 | 16 | button { 17 | border: none; 18 | border-radius: 4px; 19 | outline: none; 20 | text-decoration: none; 21 | color: #fff; 22 | background: #32325d; 23 | white-space: nowrap; 24 | display: inline-block; 25 | height: 40px; 26 | line-height: 40px; 27 | padding: 0 14px; 28 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08); 29 | border-radius: 4px; 30 | font-size: 15px; 31 | font-weight: 600; 32 | letter-spacing: 0.025em; 33 | text-decoration: none; 34 | -webkit-transition: all 150ms ease; 35 | transition: all 150ms ease; 36 | float: left; 37 | margin-left: 12px; 38 | margin-top: 28px; 39 | } 40 | 41 | button:hover { 42 | transform: translateY(-1px); 43 | box-shadow: 0 7px 14px rgba(50, 50, 93, .10), 0 3px 6px rgba(0, 0, 0, .08); 44 | background-color: #43458b; 45 | } 46 | 47 | form { 48 | padding: 30px; 49 | height: 120px; 50 | } 51 | 52 | label { 53 | font-weight: 500; 54 | font-size: 14px; 55 | display: block; 56 | margin-bottom: 8px; 57 | } 58 | 59 | #card-errors { 60 | height: 20px; 61 | padding: 4px 0; 62 | color: #fa755a; 63 | } 64 | 65 | .form-row { 66 | width: 70%; 67 | float: left; 68 | } 69 | 70 | .token { 71 | color: #32325d; 72 | font-family: 'Source Code Pro', monospace; 73 | font-weight: 500; 74 | } 75 | 76 | .wrapper { 77 | width: 670px; 78 | margin: 0 auto; 79 | height: 100%; 80 | } 81 | 82 | #stripe-token-handler { 83 | position: absolute; 84 | top: 0; 85 | left: 25%; 86 | right: 25%; 87 | padding: 20px 30px; 88 | border-radius: 0 0 4px 4px; 89 | box-sizing: border-box; 90 | box-shadow: 0 50px 100px rgba(50, 50, 93, 0.1), 91 | 0 15px 35px rgba(50, 50, 93, 0.15), 92 | 0 5px 15px rgba(0, 0, 0, 0.1); 93 | -webkit-transition: all 500ms ease-in-out; 94 | transition: all 500ms ease-in-out; 95 | transform: translateY(0); 96 | opacity: 1; 97 | background-color: white; 98 | } 99 | 100 | #stripe-token-handler.is-hidden { 101 | opacity: 0; 102 | transform: translateY(-80px); 103 | } 104 | 105 | /** 106 | * The CSS shown here will not be introduced in the Quickstart guide, but shows 107 | * how you can use CSS to style your Element's container. 108 | */ 109 | .StripeElement { 110 | background-color: white; 111 | height: 40px; 112 | padding: 10px 12px; 113 | border-radius: 4px; 114 | border: 1px solid transparent; 115 | box-shadow: 0 1px 3px 0 #e6ebf1; 116 | -webkit-transition: box-shadow 150ms ease; 117 | transition: box-shadow 150ms ease; 118 | } 119 | 120 | .StripeElement--focus { 121 | box-shadow: 0 1px 3px 0 #cfd7df; 122 | } 123 | 124 | .StripeElement--invalid { 125 | border-color: #fa755a; 126 | } 127 | 128 | .StripeElement--webkit-autofill { 129 | background-color: #fefde5 !important; 130 | } -------------------------------------------------------------------------------- /static_root/images/cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdjango/Shopping_cart/c0f8a2f2270436d2d83ee66682100e4279e53ae3/static_root/images/cart.png -------------------------------------------------------------------------------- /static_root/js/checkout.js: -------------------------------------------------------------------------------- 1 | // Create a Stripe client. 2 | 3 | var stripe = Stripe(''); 4 | 5 | // Create an instance of Elements. 6 | var elements = stripe.elements(); 7 | 8 | // Custom styling can be passed to options when creating an Element. 9 | // (Note that this demo uses a wider set of styles than the guide below.) 10 | var style = { 11 | base: { 12 | color: '#32325d', 13 | lineHeight: '18px', 14 | fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 15 | fontSmoothing: 'antialiased', 16 | fontSize: '16px', 17 | '::placeholder': { 18 | color: '#aab7c4' 19 | } 20 | }, 21 | invalid: { 22 | color: '#fa755a', 23 | iconColor: '#fa755a' 24 | } 25 | }; 26 | 27 | // Create an instance of the card Element. 28 | var card = elements.create('card', {style: style}); 29 | 30 | // Add an instance of the card Element into the `card-element`
    . 31 | card.mount('#card-element'); 32 | 33 | // Handle real-time validation errors from the card Element. 34 | card.addEventListener('change', function(event) { 35 | var displayError = document.getElementById('card-errors'); 36 | if (event.error) { 37 | displayError.textContent = event.error.message; 38 | } else { 39 | displayError.textContent = ''; 40 | } 41 | }); 42 | 43 | // Handle form submission. 44 | var form = document.getElementById('payment-form'); 45 | form.addEventListener('submit', function(event) { 46 | event.preventDefault(); 47 | 48 | stripe.createToken(card).then(function(result) { 49 | if (result.error) { 50 | // Inform the user if there was an error. 51 | var errorElement = document.getElementById('card-errors'); 52 | errorElement.textContent = result.error.message; 53 | } else { 54 | // Send the token to your server. 55 | stripeTokenHandler(result.token); 56 | } 57 | }); 58 | }); 59 | 60 | var successElement = document.getElementById('stripe-token-handler'); 61 | document.querySelector('.wrapper').addEventListener('click', function() { 62 | successElement.className = 'is-hidden'; 63 | }); 64 | 65 | function stripeTokenHandler(token) { 66 | successElement.className = ''; 67 | successElement.querySelector('.token').textContent = token.id; 68 | // Insert the token ID into the form so it gets submitted to the server 69 | var form = document.getElementById('payment-form'); 70 | var hiddenInput = document.createElement('input'); 71 | hiddenInput.setAttribute('type', 'hidden'); 72 | hiddenInput.setAttribute('name', 'stripeToken'); 73 | hiddenInput.setAttribute('value', token.id); 74 | form.appendChild(hiddenInput); 75 | 76 | // Submit the form 77 | form.submit(); 78 | } -------------------------------------------------------------------------------- /templates/advanced payment form/checkout.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load static %} 3 | 4 | {% block head %} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 24 | {% endblock head %} 25 | 26 | {% block content %} 27 | 28 | 29 |
    30 |
    31 |
    32 |
    33 | 34 |
    35 |
    Enter Voucher Code Below
    If multiple, separate each with comma
    36 | 37 |
    38 |
    39 | {% csrf_token %} 40 | 41 | 42 |
    43 | 44 | 45 | 46 |
    47 |
    48 |
    49 |
    50 |
    51 |
    52 | 53 | 54 | 55 | 56 | 57 | 60 | 61 | 62 | 63 | {% endfor %} 64 | 65 | 66 | 67 | 68 | 69 | 70 |

    Order Summary

    58 | {% for item in order.get_cart_items %} 59 |
    {{ item }}R {{ item.product.price }}
    Order Total R {{ order.get_cart_total }}
    71 | 72 |
    73 |
    74 |
    75 | 76 | 77 |
    78 |
    79 | 80 |
    81 | 82 | 83 |
    84 |
    85 |
    86 | 87 |
    88 |
    89 | Pay with card 90 | Or enter card details 91 |
    92 |
    93 | 94 |
    95 |
    96 | 101 |
    102 |
    103 |
    104 | 105 | 106 | 107 | 108 |
    109 |

    Payment successful

    110 |

    Thanks for trying Stripe Elements. No money was charged, but we generated a token: tok_189gMN2eZvKYlo2CwTBv9KKh

    111 | 112 | 113 | 114 | 115 | 116 |
    117 | 118 |
    119 | 120 |
    121 | 122 |
    123 |
    124 | 125 | 126 | 127 | 128 | 138 | 139 | {% endblock content %} 140 | 141 | -------------------------------------------------------------------------------- /templates/advanced payment form/example-4.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | "use strict"; 3 | 4 | var elements = stripe.elements({ 5 | fonts: [ 6 | { 7 | cssSrc: "https://rsms.me/inter/inter-ui.css" 8 | } 9 | ], 10 | // Stripe's examples are localized to specific languages, but if 11 | // you wish to have Elements automatically detect your user's locale, 12 | // use `locale: 'auto'` instead. 13 | locale: window.__exampleLocale 14 | }); 15 | 16 | /** 17 | * Card Element 18 | */ 19 | var card = elements.create("card", { 20 | style: { 21 | base: { 22 | color: "#32325D", 23 | fontWeight: 500, 24 | fontFamily: "Inter UI, Open Sans, Segoe UI, sans-serif", 25 | fontSize: "16px", 26 | fontSmoothing: "antialiased", 27 | 28 | "::placeholder": { 29 | color: "#CFD7DF" 30 | } 31 | }, 32 | invalid: { 33 | color: "#E25950" 34 | } 35 | } 36 | }); 37 | 38 | card.mount("#example4-card"); 39 | 40 | /** 41 | * Payment Request Element 42 | */ 43 | var paymentRequest = stripe.paymentRequest({ 44 | country: "US", 45 | currency: "usd", 46 | total: { 47 | amount: 2000, 48 | label: "Total" 49 | } 50 | }); 51 | paymentRequest.on("token", function(result) { 52 | var example = document.querySelector(".example4"); 53 | example.querySelector(".token").innerText = result.token.id; 54 | example.classList.add("submitted"); 55 | result.complete("success"); 56 | }); 57 | 58 | var paymentRequestElement = elements.create("paymentRequestButton", { 59 | paymentRequest: paymentRequest, 60 | style: { 61 | paymentRequestButton: { 62 | type: "donate" 63 | } 64 | } 65 | }); 66 | 67 | paymentRequest.canMakePayment().then(function(result) { 68 | if (result) { 69 | document.querySelector(".example4 .card-only").style.display = "none"; 70 | document.querySelector( 71 | ".example4 .payment-request-available" 72 | ).style.display = 73 | "block"; 74 | paymentRequestElement.mount("#example4-paymentRequest"); 75 | } 76 | }); 77 | 78 | registerElements([card, paymentRequestElement], "example4"); 79 | })(); -------------------------------------------------------------------------------- /templates/advanced payment form/example4.css: -------------------------------------------------------------------------------- 1 | .example.example4 { 2 | background-color: #f6f9fc; 3 | } 4 | 5 | .example.example4 * { 6 | font-family: Inter UI, Open Sans, Segoe UI, sans-serif; 7 | font-size: 16px; 8 | font-weight: 500; 9 | } 10 | 11 | .example.example4 form { 12 | max-width: 496px !important; 13 | padding: 0 15px; 14 | } 15 | 16 | .example.example4 form > * + * { 17 | margin-top: 20px; 18 | } 19 | 20 | .example.example4 .container { 21 | background-color: #fff; 22 | box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08); 23 | border-radius: 4px; 24 | padding: 3px; 25 | } 26 | 27 | .example.example4 fieldset { 28 | border-style: none; 29 | padding: 5px; 30 | margin-left: -5px; 31 | margin-right: -5px; 32 | background: rgba(18, 91, 152, 0.05); 33 | border-radius: 8px; 34 | } 35 | 36 | .example.example4 fieldset legend { 37 | float: left; 38 | width: 100%; 39 | text-align: center; 40 | font-size: 13px; 41 | color: #8898aa; 42 | padding: 3px 10px 7px; 43 | } 44 | 45 | .example.example4 .card-only { 46 | display: block; 47 | } 48 | .example.example4 .payment-request-available { 49 | display: none; 50 | } 51 | 52 | .example.example4 fieldset legend + * { 53 | clear: both; 54 | } 55 | 56 | .example.example4 input, .example.example4 button { 57 | -webkit-appearance: none; 58 | -moz-appearance: none; 59 | appearance: none; 60 | outline: none; 61 | border-style: none; 62 | color: #fff; 63 | } 64 | 65 | .example.example4 input:-webkit-autofill { 66 | transition: background-color 100000000s; 67 | -webkit-animation: 1ms void-animation-out; 68 | } 69 | 70 | .example.example4 #example4-card { 71 | padding: 10px; 72 | margin-bottom: 2px; 73 | } 74 | 75 | .example.example4 input { 76 | -webkit-animation: 1ms void-animation-out; 77 | } 78 | 79 | .example.example4 input::-webkit-input-placeholder { 80 | color: #9bacc8; 81 | } 82 | 83 | .example.example4 input::-moz-placeholder { 84 | color: #9bacc8; 85 | } 86 | 87 | .example.example4 input:-ms-input-placeholder { 88 | color: #9bacc8; 89 | } 90 | 91 | .example.example4 button { 92 | display: block; 93 | width: 100%; 94 | height: 37px; 95 | background-color: #d782d9; 96 | border-radius: 2px; 97 | color: #fff; 98 | cursor: pointer; 99 | } 100 | 101 | .example.example4 button:active { 102 | background-color: #b76ac4; 103 | } 104 | 105 | .example.example4 .error svg .base { 106 | fill: #e25950; 107 | } 108 | 109 | .example.example4 .error svg .glyph { 110 | fill: #f6f9fc; 111 | } 112 | 113 | .example.example4 .error .message { 114 | color: #e25950; 115 | } 116 | 117 | .example.example4 .success .icon .border { 118 | stroke: #ffc7ee; 119 | } 120 | 121 | .example.example4 .success .icon .checkmark { 122 | stroke: #d782d9; 123 | } 124 | 125 | .example.example4 .success .title { 126 | color: #32325d; 127 | } 128 | 129 | .example.example4 .success .message { 130 | color: #8898aa; 131 | } 132 | 133 | .example.example4 .success .reset path { 134 | fill: #d782d9; 135 | } 136 | -------------------------------------------------------------------------------- /templates/advanced payment form/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var stripe = Stripe('pk_test_Fjb4PojwxaqET2AftkftQSfp'); 4 | 5 | function registerElements(elements, exampleName) { 6 | var formClass = '.' + exampleName; 7 | var example = document.querySelector(formClass); 8 | 9 | var form = example.querySelector('form'); 10 | var resetButton = example.querySelector('a.reset'); 11 | var error = form.querySelector('.error'); 12 | var errorMessage = error.querySelector('.message'); 13 | 14 | function enableInputs() { 15 | Array.prototype.forEach.call( 16 | form.querySelectorAll( 17 | "input[type='text'], input[type='email'], input[type='tel']" 18 | ), 19 | function(input) { 20 | input.removeAttribute('disabled'); 21 | } 22 | ); 23 | } 24 | 25 | function disableInputs() { 26 | Array.prototype.forEach.call( 27 | form.querySelectorAll( 28 | "input[type='text'], input[type='email'], input[type='tel']" 29 | ), 30 | function(input) { 31 | input.setAttribute('disabled', 'true'); 32 | } 33 | ); 34 | } 35 | 36 | function triggerBrowserValidation() { 37 | // The only way to trigger HTML5 form validation UI is to fake a user submit 38 | // event. 39 | var submit = document.createElement('input'); 40 | submit.type = 'submit'; 41 | submit.style.display = 'none'; 42 | form.appendChild(submit); 43 | submit.click(); 44 | submit.remove(); 45 | } 46 | 47 | // Listen for errors from each Element, and show error messages in the UI. 48 | var savedErrors = {}; 49 | elements.forEach(function(element, idx) { 50 | element.on('change', function(event) { 51 | if (event.error) { 52 | error.classList.add('visible'); 53 | savedErrors[idx] = event.error.message; 54 | errorMessage.innerText = event.error.message; 55 | } else { 56 | savedErrors[idx] = null; 57 | 58 | // Loop over the saved errors and find the first one, if any. 59 | var nextError = Object.keys(savedErrors) 60 | .sort() 61 | .reduce(function(maybeFoundError, key) { 62 | return maybeFoundError || savedErrors[key]; 63 | }, null); 64 | 65 | if (nextError) { 66 | // Now that they've fixed the current error, show another one. 67 | errorMessage.innerText = nextError; 68 | } else { 69 | // The user fixed the last error; no more errors. 70 | error.classList.remove('visible'); 71 | } 72 | } 73 | }); 74 | }); 75 | 76 | // Listen on the form's 'submit' handler... 77 | form.addEventListener('submit', function(e) { 78 | e.preventDefault(); 79 | 80 | // Trigger HTML5 validation UI on the form if any of the inputs fail 81 | // validation. 82 | var plainInputsValid = true; 83 | Array.prototype.forEach.call(form.querySelectorAll('input'), function( 84 | input 85 | ) { 86 | if (input.checkValidity && !input.checkValidity()) { 87 | plainInputsValid = false; 88 | return; 89 | } 90 | }); 91 | if (!plainInputsValid) { 92 | triggerBrowserValidation(); 93 | return; 94 | } 95 | 96 | // Show a loading screen... 97 | example.classList.add('submitting'); 98 | 99 | // Disable all inputs. 100 | disableInputs(); 101 | 102 | // Gather additional customer data we may have collected in our form. 103 | var name = form.querySelector('#' + exampleName + '-name'); 104 | var address1 = form.querySelector('#' + exampleName + '-address'); 105 | var city = form.querySelector('#' + exampleName + '-city'); 106 | var state = form.querySelector('#' + exampleName + '-state'); 107 | var zip = form.querySelector('#' + exampleName + '-zip'); 108 | var additionalData = { 109 | name: name ? name.value : undefined, 110 | address_line1: address1 ? address1.value : undefined, 111 | address_city: city ? city.value : undefined, 112 | address_state: state ? state.value : undefined, 113 | address_zip: zip ? zip.value : undefined, 114 | }; 115 | 116 | // Use Stripe.js to create a token. We only need to pass in one Element 117 | // from the Element group in order to create a token. We can also pass 118 | // in the additional customer data we collected in our form. 119 | stripe.createToken(elements[0], additionalData).then(function(result) { 120 | // Stop loading! 121 | example.classList.remove('submitting'); 122 | 123 | if (result.token) { 124 | // If we received a token, show the token ID. 125 | example.querySelector('.token').innerText = result.token.id; 126 | example.classList.add('submitted'); 127 | } else { 128 | // Otherwise, un-disable inputs. 129 | enableInputs(); 130 | } 131 | }); 132 | }); 133 | 134 | resetButton.addEventListener('click', function(e) { 135 | e.preventDefault(); 136 | // Resetting the form (instead of setting the value to `''` for each input) 137 | // helps us clear webkit autofill styles. 138 | form.reset(); 139 | 140 | // Clear each Element. 141 | elements.forEach(function(element) { 142 | element.clear(); 143 | }); 144 | 145 | // Reset error state as well. 146 | error.classList.remove('visible'); 147 | 148 | // Resetting the form does not un-disable inputs, so we need to do it separately: 149 | enableInputs(); 150 | example.classList.remove('submitted'); 151 | }); 152 | } 153 | -------------------------------------------------------------------------------- /templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Cart 6 | 7 | 8 | 9 | {% block head %}{% endblock head %} 10 | {% block style %}{% endblock style %} 11 | 12 | 13 | 14 | {% include 'messages.html' %} 15 |
    16 | {% block content %}{% endblock content %} 17 |
    18 | 19 | 20 | 21 | 22 | {% block script %}{% endblock script %} 23 | 24 | -------------------------------------------------------------------------------- /templates/messages.html: -------------------------------------------------------------------------------- 1 | {% if messages %} 2 | 3 | 12 | 13 |
    14 | 15 |
      16 | {% for message in messages %} 17 | {% if "html_safe" in message.tags %}{{ message|safe }}{% else %}{{ message }}{% endif %} 18 | {% endfor %} 19 |
    20 | 21 |
    22 | {% endif %} -------------------------------------------------------------------------------- /templates/profile.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {% for order in my_orders %} 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | {% empty %} 25 | 26 | 27 | 28 | {% endfor %} 29 | 30 | 31 | 36 | 37 |
    Date OrderedReference CodeItemsPrice
    {{ order.date_ordered }}{{ order.ref_code }} 17 | {% for item in order.items.all %} 18 | {{ item.product.name }} 19 | {% endfor %} 20 | ${{ order.get_cart_total }}
    You have no orders.
    32 | 33 | {% if not order %}Continue Shopping{% else %}Add Items to Cart {% endif %} 34 | 35 |
    38 | 39 | {% endblock content %} --------------------------------------------------------------------------------