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 compressor.filters import CompilerFilter | |
class CoffeeCompilerFinder(staticfiles.finders.AppDirectoriesFinder): | |
""" | |
A quick hacked up staticfiles-finder that will automatically recompile .coffee files to .js and serve the .js file | |
It will respond to a request for /foo/bar/baz.js and if the coffee-file with the same name in that same dir is newer then | |
then js-file requested then the js-file will be recompiled. | |
I did this to not have to manually recompile my scripts or use the watcher and still be compatible with require.js | |
without have to change the code once i deploy with compiled js-files. it depends on django-compressor at the moment | |
but if you dont use that its just a small class to lift out from it. |
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
# Allow additional attributes to be saved without be saved through tinyMCE and Mezzanine | |
# Create a file name defaults.py inside any django app | |
# Mezzanine will then automatically pick up this file | |
from mezzanine.conf import register_setting | |
register_setting( | |
name="RICHTEXT_ALLOWED_TAGS", | |
append=True, | |
default=("iframe", "embed", "object"), |
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.views.generic.edit import ProcessFormView | |
class ContactView(ProcessFormView): | |
form_class = ContactForm | |
template_name = 'contact.html' | |
success_url = '/thanks/' | |
def form_valid(self, form): | |
send_contact_message(form.cleaned_data['email'], | |
form.cleaned_data['message']) |
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
/** | |
* Mobiscroll setup with swedish translation | |
* Formats date like [day date shortMonth] [hour] [minute] | |
*/ | |
$(document).ready(function(){ | |
(function ($) { | |
$.scroller.i18n.sv = $.extend($.scroller.i18n.sv, { | |
setText: 'Klar', | |
cancelText: 'Avbryt' |
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
---- starting ---- | |
#!/bin/bash | |
python ./manage.py run_gunicorn -b 0.0.0.0:8001 -p /tmp/gunicorn.pid --daemon --access-logfile /var/log/gunicorn.log | |
echo "Server started, \n using PID /tmp/gunicorn.pid" | |
----- stopping ---- | |
#!/bin/bash | |
kill `cat /tmp/gunicorn.pid` |
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
try: | |
WebDriverWait(self.browser, 10).until( | |
lambda driver : self.assertEqual( | |
"1", driver.browser.find_element_by_xpath("//*[@id='cart-amount']").text) | |
) | |
except Exception as e: | |
print e |
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
for k in `git branch -r | perl -pe 's/^..(.*?)( ->.*)?$/\1/'`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r | |
# http://stackoverflow.com/questions/2514172/listing-each-branch-and-its-last-revisions-date-in-git |
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
<?xml version="1.0" ?> | |
<AccessRequest xml:lang='en-US'> | |
<AccessLicenceNumber>secret</AccessLicenceNumber> | |
<UserId>secret</UserId> | |
<Password>secret</Password> | |
</AccessRequest> | |
<?xml version="1.0" ?> | |
<RatingServiceSelectionRequest> | |
<Request> |
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
SHIPPING_SERVICES = ( | |
('11', 'Standard'), | |
('07', 'Worldwide Express'), | |
('54', 'Worldwide Express Plus'), | |
('08', 'Worldwide Expedited'), | |
('65', 'Saver. Required for Rating and Ignored for Shopping'), | |
) | |
SHIPPING_SERVICES_LOOKUP = dict(SHIPPING_SERVICES) | |
# 07 - Worldwide Express |
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 add_to_cart(product): | |
resp = self.client.post(reverse('add_to_cart_view', {'product' : product.pk} | |
return resp | |
def test_add_to_cart(): | |
# add all products to cart | |
for product in Product.objects.all(): | |
resp = add_to_cart(product) | |
self.assertEqual(resp.status_code, 302) |
OlderNewer