Skip to content

Commit

Permalink
Add Python runtime for Heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvshettty committed Nov 23, 2022
1 parent 78b4308 commit 20f13a0
Show file tree
Hide file tree
Showing 104 changed files with 11,751 additions and 11,741 deletions.
558 changes: 279 additions & 279 deletions .gitignore

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
============
Sandbox site
============

This site is deployed there:

https://latest.oscarcommerce.com
-------------------------------

This is a vanilla install of Oscar with as little customisation as possible to
get a basic site working. It's really intended for local development and QA.

It does have a few customisations:

* A profile model with a few fields, designed to test Oscar's account section
which should automatically allow the profile fields to be edited.

It is deployed automatically to: https://latest.oscarcommerce.com
============
Sandbox site
============

This site is deployed there:

https://latest.oscarcommerce.com
-------------------------------

This is a vanilla install of Oscar with as little customisation as possible to
get a basic site working. It's really intended for local development and QA.

It does have a few customisations:

* A profile model with a few fields, designed to test Oscar's account section
which should automatically allow the profile fields to be edited.

It is deployed automatically to: https://latest.oscarcommerce.com
50 changes: 25 additions & 25 deletions apps/offers.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
from oscar.apps.offer import models


class ChangesOwnerName(models.Benefit):

class Meta:
proxy = True
app_label = 'sandbox'

def apply(self, basket, condition, offer=None):
condition.consume_items(offer, basket, ())
return models.PostOrderAction(
"You will have your name changed to Barry!")

def apply_deferred(self, basket, order, application):
if basket.owner:
basket.owner.first_name = "Barry"
basket.owner.save()
return "Your name has been changed to Barry!"

@property
def description(self):
return "Changes owners name"

name = description
from oscar.apps.offer import models


class ChangesOwnerName(models.Benefit):

class Meta:
proxy = True
app_label = 'sandbox'

def apply(self, basket, condition, offer=None):
condition.consume_items(offer, basket, ())
return models.PostOrderAction(
"You will have your name changed to Barry!")

def apply_deferred(self, basket, order, application):
if basket.owner:
basket.owner.first_name = "Barry"
basket.owner.save()
return "Your name has been changed to Barry!"

@property
def description(self):
return "Changes owners name"

name = description
140 changes: 70 additions & 70 deletions apps/sitemaps.py
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.contrib.sitemaps import Sitemap
from django.urls import reverse
from django.utils.translation import get_language, activate
from oscar.core.loading import get_model

Product = get_model('catalogue', 'Product')
Category = get_model('catalogue', 'Category')


"""
A basic example what a sitemap could look like for a multi-language Oscar
instance.
Creates entries for the homepage, for each product and each category.
Repeats those for each enabled language.
"""


class I18nSitemap(Sitemap):
"""
A language-specific Sitemap class. Returns URLS for items for passed
language.
"""
def __init__(self, language):
self.language = language
self.original_language = get_language()

def get_obj_location(self, obj):
return obj.get_absolute_url()

def location(self, obj):
activate(self.language)
location = self.get_obj_location(obj)
activate(self.original_language)
return location


class StaticSitemap(I18nSitemap):

def items(self):
return ['home', ]

def get_obj_location(self, obj):
return reverse(obj)


class ProductSitemap(I18nSitemap):

def items(self):
return Product.objects.browsable()


class CategorySitemap(I18nSitemap):

def items(self):
return Category.objects.all()


language_neutral_sitemaps = {
'static': StaticSitemap,
'products': ProductSitemap,
'categories': CategorySitemap,
}

# Construct the sitemaps for every language
base_sitemaps = {}
for language, __ in settings.LANGUAGES:
for name, sitemap_class in language_neutral_sitemaps.items():
base_sitemaps['{0}-{1}'.format(name, language)] = sitemap_class(language)
# -*- coding: utf-8 -*-
from django.conf import settings
from django.contrib.sitemaps import Sitemap
from django.urls import reverse
from django.utils.translation import get_language, activate
from oscar.core.loading import get_model

Product = get_model('catalogue', 'Product')
Category = get_model('catalogue', 'Category')


"""
A basic example what a sitemap could look like for a multi-language Oscar
instance.
Creates entries for the homepage, for each product and each category.
Repeats those for each enabled language.
"""


class I18nSitemap(Sitemap):
"""
A language-specific Sitemap class. Returns URLS for items for passed
language.
"""
def __init__(self, language):
self.language = language
self.original_language = get_language()

def get_obj_location(self, obj):
return obj.get_absolute_url()

def location(self, obj):
activate(self.language)
location = self.get_obj_location(obj)
activate(self.original_language)
return location


class StaticSitemap(I18nSitemap):

def items(self):
return ['home', ]

def get_obj_location(self, obj):
return reverse(obj)


class ProductSitemap(I18nSitemap):

def items(self):
return Product.objects.browsable()


class CategorySitemap(I18nSitemap):

def items(self):
return Category.objects.all()


language_neutral_sitemaps = {
'static': StaticSitemap,
'products': ProductSitemap,
'categories': CategorySitemap,
}

# Construct the sitemaps for every language
base_sitemaps = {}
for language, __ in settings.LANGUAGES:
for name, sitemap_class in language_neutral_sitemaps.items():
base_sitemaps['{0}-{1}'.format(name, language)] = sitemap_class(language)
136 changes: 68 additions & 68 deletions apps/user/models.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
"""
Sample user/profile models for testing. These aren't enabled by default in the
sandbox
"""

from django.contrib.auth.models import (
AbstractUser, BaseUserManager, AbstractBaseUser)
from django.db import models
from django.utils import timezone

from oscar.core import compat
from oscar.apps.customer import abstract_models


class Profile(models.Model):
"""
Dummy profile model used for testing
"""
user = models.OneToOneField(compat.AUTH_USER_MODEL, related_name="profile",
on_delete=models.CASCADE)
MALE, FEMALE = 'M', 'F'
choices = (
(MALE, 'Male'),
(FEMALE, 'Female'))
gender = models.CharField(max_length=1, choices=choices,
verbose_name='Gender')
age = models.PositiveIntegerField(verbose_name='Age')


# A simple extension of the core User model for Django 1.5+
class ExtendedUserModel(AbstractUser):
twitter_username = models.CharField(max_length=255, unique=True)


class CustomUserManager(BaseUserManager):

def create_user(self, email, password=None):
now = timezone.now()
email = BaseUserManager.normalize_email(email)
user = self.model(email=email, last_login=now)
user.set_password(password)
user.save(using=self._db)
return user

def create_superuser(self, email, password):
return self.create_user(email, password)

# A user model which doesn't extend AbstractUser
class CustomUserModel(AbstractBaseUser):
name = models.CharField(max_length=255, blank=True)
email = models.EmailField(unique=True)
twitter_username = models.CharField(max_length=255, unique=True)

USERNAME_FIELD = 'email'

objects = CustomUserManager()

def __str__(self):
return self.email

def get_full_name(self):
return self.name

get_short_name = get_full_name

# A simple extension of the core Oscar User model
class ExtendedOscarUserModel(abstract_models.AbstractUser):
twitter_username = models.CharField(max_length=255, unique=True)
"""
Sample user/profile models for testing. These aren't enabled by default in the
sandbox
"""

from django.contrib.auth.models import (
AbstractUser, BaseUserManager, AbstractBaseUser)
from django.db import models
from django.utils import timezone

from oscar.core import compat
from oscar.apps.customer import abstract_models


class Profile(models.Model):
"""
Dummy profile model used for testing
"""
user = models.OneToOneField(compat.AUTH_USER_MODEL, related_name="profile",
on_delete=models.CASCADE)
MALE, FEMALE = 'M', 'F'
choices = (
(MALE, 'Male'),
(FEMALE, 'Female'))
gender = models.CharField(max_length=1, choices=choices,
verbose_name='Gender')
age = models.PositiveIntegerField(verbose_name='Age')


# A simple extension of the core User model for Django 1.5+
class ExtendedUserModel(AbstractUser):
twitter_username = models.CharField(max_length=255, unique=True)


class CustomUserManager(BaseUserManager):

def create_user(self, email, password=None):
now = timezone.now()
email = BaseUserManager.normalize_email(email)
user = self.model(email=email, last_login=now)
user.set_password(password)
user.save(using=self._db)
return user

def create_superuser(self, email, password):
return self.create_user(email, password)

# A user model which doesn't extend AbstractUser
class CustomUserModel(AbstractBaseUser):
name = models.CharField(max_length=255, blank=True)
email = models.EmailField(unique=True)
twitter_username = models.CharField(max_length=255, unique=True)

USERNAME_FIELD = 'email'

objects = CustomUserManager()

def __str__(self):
return self.email

def get_full_name(self):
return self.name

get_short_name = get_full_name

# A simple extension of the core Oscar User model
class ExtendedOscarUserModel(abstract_models.AbstractUser):
twitter_username = models.CharField(max_length=255, unique=True)
Loading

0 comments on commit 20f13a0

Please sign in to comment.