This file contains hidden or 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 collections import namedtuple | |
# Javascript scripts ----------------------------------------------------------------------------------------------- | |
SELECT_BY_VALUE = \ | |
''' | |
$(arguments[0]).val(arguments[1]); | |
$(arguments[0]).trigger('change'); | |
''' |
This file contains hidden or 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.forms.models import inlineformset_factory | |
from django.shortcuts import render | |
from django.http import HttpResponseRedirect | |
from django import forms | |
from crispy_forms.helper import FormHelper | |
# The forms --------------------------------------------------------------------------------------------------------- |
This file contains hidden or 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
# xlsxwriter Cheat Sheet | |
# | |
# xlsxwriter is an awesome package for writing Excel spreadsheets. It's got excellent documentation. And it's got | |
# way more functionality than I need. This cheat sheet contains the basic functionality that I use all the time. | |
# | |
# While it is possible to put formulas in the spreadsheet, I have had some problems with spreadsheets as email attachments | |
# when the spreadsheet has formulas and the email client is on mobile. | |
import xlsxwriter |
This file contains hidden or 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.forms.models import inlineformset_factory | |
from django.shortcuts import render | |
def container_with_items(request, container_id): | |
ItemFormSet = inlineformset_factory( | |
models.Container, models.Item, form=forms.InlineItemForm, fk_name='container', extra=1 | |
) | |
# Use this to layout the Item forms |
This file contains hidden or 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
# Gazetteer --------------------------------------------------------------------------------------------------------- | |
def load_deduped_output_for_gazetteer(filename): | |
""" | |
Parse data from dedupe into: | |
1. Canonical dataset (no dupes) | |
2. messy data - all the dupes | |
3. markPairs. | |
:return: |
This file contains hidden or 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
''' | |
I have a model for customer intake. One of the fields is for tracking how the customer heard about us. I do | |
not want an endless proliferation of values, so I would like to use a multi-select. The problem is I also want the | |
user to add new choices as needed. It turns out this is possible with the Select2 widget: | |
https://select2.github.io/examples.html#tokenizer - check out this link to see how to setup your javascript. | |
It turns out this is a little tricky to implement. Below is a mixin you can use with a form to handle the field. | |
Also, if you are using bootstrap, you will want: https://fk.github.io/select2-bootstrap-css/ |
This file contains hidden or 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.core.cache import cache | |
from django.core.urlresolvers import reverse | |
from django.contrib.staticfiles.testing import StaticLiveServerTestCase | |
from selenium import webdriver | |
from selenium.webdriver.support.select import Select | |
# DOES NOT WORK WITH selenium 2.5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
This file contains hidden or 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
""" | |
Mostly the Google quickstart.py code with the "freebusy" service running. | |
Also shows how to make datetimes using pytz. | |
Follow these instructions to get access credentials: | |
https://developers.google.com/google-apps/calendar/quickstart/python | |
""" |
This file contains hidden or 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
__author__ = 'chuck' | |
from urlparse import urlparse | |
from django.core.urlresolvers import reverse | |
from django.test import TestCase | |
from django.test.client import Client | |
from django.conf import settings | |
from django.contrib.auth.models import User, Group | |
from django.core.cache import cache |
This file contains hidden or 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 time import sleep | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.common.action_chains import ActionChains | |
class Chosen(object): | |
""" | |
For selenium testing of the jquery Chosen widget (v1.1.0 https://harvesthq.github.io/chosen/). |
NewerOlder