This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Front Side: | |
Oscar - Bad-ass e-commerce for ninjas | |
Back side: | |
Oscar is a new e-commerce framework for generating electric synergy between your development rockstars and your marketing weasels | |
Features? No features, just endless possibilities: | |
* A fully recursive stack-driven, reverse-proxying domain generator | |
* Strict adherance to sandwich-driven development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import re | |
from xml.dom.minidom import parseString | |
def format_xml(xml_str): | |
xml_str = re.sub(r'\s*\n\s*', '', xml_str) | |
ugly = parseString(xml_str).toprettyxml(indent=' ') | |
regex = re.compile(r'>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Ledger(models.Model): | |
# There can only be one 'Labour' and 'Shop' ledger but lots of 'Budget' | |
# ledgers. | |
LABOUR, BUDGET, SHOP = 'Labour', 'Budget', 'Shop' | |
LEDGER_CHOICES = ( | |
(LABOUR, LABOUR), | |
(BUDGET, BUDGET), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
class WeekdayOpeningPeriod(models.Model): | |
store = models.ForeignKey('stores.Store', related_name='opening_periods') | |
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY = range(7) | |
weekday_choices = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Notification(models.Model): | |
recipient = models.ForeignKey('auth.User', related_name='notifications') | |
# HTML is allowed in this field as it can contain links | |
text = models.CharField(max_length=255) | |
# Some projects may want to categorise their notifications. You may want | |
# to use this field to show a different icons next to the notification. | |
category = models.CharField(max_length=255, null=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Notification(models.Model): | |
sender = models.ForeignKey('auth.User', null=True) | |
recipient = models.ForeignKey('auth.User', related_name='notifications') | |
subject = models.CharField(max_length=255) | |
body = models.TextField() | |
# Some projects may want to categorise their notifications. You may want | |
# to use this field to show a different icons next to the notification. | |
category = models.CharField(max_length=255, null=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import celery | |
@celery.task | |
def fetch(): | |
""" | |
Download files from FTP server | |
This tasks could be trigger by a cronjob to start the processing pipeline. | |
When file(s) downloaded successfully, create a set of partner_prepare jobs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import chain | |
from django.core.management.base import BaseCommand | |
from . import tasks | |
class Command(BaseCommand): | |
def handle(self, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
from django.http import HttpResponse | |
from django.contrib.auth import authenticate | |
from django.conf import settings | |
def view_or_basicauth(view, request, *args, **kwargs): | |
# Check for valid basic auth header | |
if 'HTTP_AUTHORIZATION' in request.META: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Easier port forwarding - usage: | |
# | |
# $ portforward project-app1 5432 | |
# | |
# where 'project-app1' is an alias from ~/.ssh/config and 5432 is the remote | |
# port that you want to forward to. | |
function portforward() { | |
HOST=$1 | |
REMOTE_PORT=$2 | |
# Pick a random port and check it is free |