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 MainsiteMiddleware(object): | |
def process_request(self, request): | |
from mainsite.urls import urlpatterns | |
current_path = request.META.get('PATH_INFO', '') | |
inside_mainsite = False | |
# loop over all the page of mainsite | |
for url in urlpatterns: | |
# check to see if there is a url match |
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 get_dimensions(self, width=None, height=None): | |
""" | |
Resize the /images/clients/raw image to whatever dimensions needed, caches the already created images | |
""" | |
# default dimentions | |
height = height or self.image.height | |
width = width or self.image.width | |
filename = str(self.image.path) | |
new_path = filename.replace('/raw/', '/{0}x{1}/'.format(width,height)) |
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.models.signals import post_syncdb | |
from django.contrib.auth import models as auth_models | |
def fix_db(sender, **kwargs): | |
from django.db import connection, transaction | |
cursor = connection.cursor() | |
# Data modifying operation - commit required | |
print '* Better the auth_user table' | |
cursor.execute("ALTER TABLE auth_user ALTER COLUMN username TYPE VARCHAR(255);") |
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
Day job: Java Engineer (Play! framework) | |
Favorite Python project: PIL (django 2nd favorite) | |
Favorite Conference: superconf (only one i've ever been to) | |
Python Experience Level: Average :/ |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Example 1</title> | |
<script type="text/javascript"> | |
function updateOrder(){ | |
var items = document.getElementById("items"); | |
var itemLabels = document.getElementById("label_items"); | |
var total = 0; | |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Example 2</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js" type="text/javascript" charset="ISO-8859-1"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$("#name,#phone,#items").live("change", function(){ | |
var items = $("#items"); | |
var itemLabels = $("#label_items"); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Example 3.a</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js" type="text/javascript" charset="ISO-8859-1"></script> | |
<script src="https://raw.github.com/jquery/jquery-tmpl/master/jquery.tmpl.min.js" type="text/javascript"></script> | |
<script src="http://github.com/downloads/SteveSanderson/knockout/knockout-1.2.1.js" type="text/javascript" charset="ISO-8859-1"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
var viewController = { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Example 3.b</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js" type="text/javascript" charset="ISO-8859-1"></script> | |
<script src="https://raw.github.com/jquery/jquery-tmpl/master/jquery.tmpl.min.js" type="text/javascript"></script> | |
<script src="http://github.com/downloads/SteveSanderson/knockout/knockout-1.2.1.js" type="text/javascript" charset="ISO-8859-1"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
// controller |
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
update: function(options){ | |
options = options || {}; | |
var collection = this, success = options.success; | |
options.success = function(resp, status, xhr){ | |
var changed = false; | |
var collectionIds = []; // store the ids as we add them | |
var toDelete = []; // store all the models to remove | |
var onChange = function() { |
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
.... | |
RUN pip install .... django ... | |
# Fixes bug that is being thrown by postgres interacting with ldap (see http://stackoverflow.com/questions/38740631/need-to-pre-import-module-to-avoid-error) | |
RUN echo -e "--- /usr/local/lib/python2.7/site-packages/django/apps/config.original.py\n+++ /usr/local/lib/python2.7/site-packages/django/apps/config.py\n@@ -104,6 +104,7 @@\n else:\n try:\n # If this works, the app module specifies an app config class.\n+ if entry == 'django.contrib.postgres': import ldap\n entry = module.default_app_config\n except AttributeError:\n # Otherwise, it simply uses the default app config class." > /tmp/config.py.patch | |
RUN cd /usr/local/lib/python2.7/site-packages/django/apps/ && patch config.py /tmp/config.py.patch | |
... |
OlderNewer