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
<script type="text/javascript"> | |
// function used to make AJAX calls | |
function ajaxFormCall(event, formObject, successFunction, errorFunction) { | |
var data = new FormData(formObject.get(0)); | |
event.preventDefault(); | |
$.ajax({ | |
data: data, | |
type: formObject.attr('method'), | |
url: formObject.attr('action'), | |
cache: 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
1. Add following to requirements (recommend pip freeze after install and putting version numbers in file - ie coverage==3.7.1): | |
model_mommy | |
django-nose | |
coverage | |
selenium | |
2. Add Django Nose to INSTALLED APPS: | |
INSTALLED_APPS = ( | |
... | |
'django_nose', |
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
### factories.py ### | |
from factory.django import DjangoModelFactory | |
from django.forms import ModelForm | |
from .models import Product, ProductQuerySet | |
class TestProduct(Product): |
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 assign-inputs($inputs, $pseudo: null) { | |
$list : (); | |
@each $input in $inputs { | |
$input: unquote($input); | |
$input: if($pseudo, $input + ":" + $pseudo, $input); | |
$list: append($list, $input, comma); | |
} | |
@return $list; |
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
# Inspiration from https://djangosnippets.org/snippets/116/ | |
from django import template | |
import datetime | |
register = template.Library() | |
def days_until(value): | |
""" |
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
""" | |
Usage: get_classes_from_html.py path/to/file.html | |
""" | |
def convert_html_to_string(html_file_path): | |
html_file = open(html_file_path, 'r') | |
return html_file.read() | |
def get_css_classes(html_string, attribute='class'): |
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
<!-- | |
See http://codepen.io/lightstrike/pen/tswme for demo | |
Example markup and inspiration from http://jsfiddle.net/KyleMit/cyCFS/ | |
--> | |
<p>Full Size:</p> | |
<div class="left-inner-addon "> | |
<i class="glyphicon glyphicon-user"></i> | |
<input type="text" | |
class="form-control" |
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
/* Adapting base Parsley CSS into SASS mixins - http://parsleyjs.org/src/parsley.css */ | |
/* | |
Use this mixin to define success and error classes | |
Default class names: parsley-success, parsley-error | |
*/ | |
@mixin parsleyValidated($name, $textColor, $bgColor, $borderColor) { | |
input.#{$name}, | |
select.#{$name}, | |
textarea.#{$name} { |
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_selector(*args): | |
return ''.join([a for a in args]) | |
def get_parsley_errors_data(parsley_attr, fields): | |
parsley_extras = dict() | |
for field in fields: | |
field_dict = {} | |
field_slug = slugify(field) | |
field_dict[parsley_attr] = get_selector( |
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 UserDetailAccessMixin(UserPassesTestMixin): | |
def test_func(self, user): | |
""" | |
Tests if user should be allowed access to DetailView if one of two conditions: | |
1. Has staff permissions | |
2. Is the customer associated with the object in a DetailView | |
""" | |
if user.is_staff: | |
return True | |
else: |
OlderNewer