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
""" | |
This fabric file makes setting up and deploying a django application much | |
easier, but it does make a few assumptions. Namely that you're using Git, | |
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have | |
Django installed on your local machine and SSH installed on both the local | |
machine and any servers you want to deploy to. | |
_note that I've used the name project_name throughout this example. Replace | |
this with whatever your project is called._ |
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
EXTRA_MODEL_FIELDS = ( | |
( | |
"cartridge.shop.models.Product.tic", | |
"CharField", | |
("Taxability Information Code",), | |
{"max_length":"5", "blank": True, "default":"00000", }, | |
), | |
) |
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 decimal import Decimal | |
from cartridge.shop.models import Order, SelectedProduct | |
def setup(self, request): | |
""" | |
Set order fields that are stored in the session, item_total, tax_total, | |
and total based on the given cart, and copy the cart items to the order. | |
Called in the final step of the checkout process prior to the payment |
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
$(function() { | |
// Create filter actions. | |
var checkbox = $('input[name=joins-leaves]') | |
$('label[for=joins-leaves]').toggle( function () { | |
$('.joins, .leaves').css({'display': 'none'}); | |
checkbox.prop('checked', true); | |
}, function () { | |
$(".joins, .leaves").css({'display': 'table-row'}); | |
checkbox.prop('checked', false); | |
}); |
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
Vagrant::Config.run do |config| | |
config.vm.box = "precise64" | |
config.vm.network :hostonly, "192.168.124.10" | |
end |
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
@task | |
@log_call | |
def download_media(): | |
media = 'media.tar.gz' | |
run("tar -czvf %s/%s -C %s/static/media/" % (env.proj_path, media, | |
env.proj_path)) | |
get('%s/%s' % (env.proj_path, media), media) | |
@task | |
@log_call |
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.contrib.auth.models import User | |
from django.db import models | |
from django.db.models.signals import post_save | |
from mezzanine.core.fields import RichTextField | |
from cartridge.shop.models import Product | |
from social_auth.signals import pre_update | |
from social_auth.backends.google import GoogleOAuth2Backend |
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 redis | |
import random | |
import pylibmc | |
import psycopg2 | |
import sys | |
from time import clock | |
r = redis.Redis(host='localhost', port=6379) |
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
def main(): | |
list_of_primes = [2] | |
while len(list_of_primes) < 1000: | |
if list_of_primes[-1] % 2 == 0: | |
value = list_of_primes[-1] + 1 | |
else: | |
value += 2 | |
is_prime = True | |
for i in list_of_primes: | |
if i > value * 0.5: |
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 copy import deepcopy | |
from django.contrib import admin | |
from mezzanine.pages.admin import PageAdmin | |
from mezzanine.pages.models import Page | |
fieldsets = deepcopy(PageAdmin.fieldsets) | |
fieldsets[0][1]["fields"].remove('in_menus') | |
fieldsets[0][1]["fields"].insert(0, '_order') | |
OlderNewer