Skip to content

Instantly share code, notes, and snippets.

View jsma's full-sized avatar

John-Scott Atlakson jsma

View GitHub Profile
@jsma
jsma / default.html
Created August 27, 2016 07:03
cmsplugin_filer_image template override
{% load thumbnail filer_tags filer_image_tags %}{% spaceless %}
<figure {% if instance.image %}id="image_plugin_{{ instance.image.id }}"{% endif %}>
{% if link %}<a href="{{ link }}"{% if instance.target_blank %} target="_blank"{% endif %}>{% endif %}
{% if instance.image %}
{% if instance.use_original_image %}
<img class="img-responsive{% if instance.alignment %} {{ instance.alignment }}{% endif %}" alt="{% if instance.alt %}{{ instance.alt }}{% endif %}" src="{{ instance.image.url }}"{% if instance.width %} width="{{ instance.width }}"{% endif %}{% if instance.height %} height="{{ instance.height }}"{% endif %}{% if instance.caption %} title="{{ instance.caption }}"{% endif %} />
{% else %}
{% thumbnail instance.image size crop=opts.crop upscale=opts.upscale subject_location=opts.subject_location as thumbnail %}
<img class="img-responsive{% if instance.alignment %} {{ instance.alignment }}{% endif %}" alt="{% if instance.alt %}{{ instance.alt }}{% endif %}" src="{{ thumbnail
@jsma
jsma / gist:d36f8c90e032295ab7c9
Last active August 29, 2015 14:06
Custom user (email field as username)
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser, PermissionsMixin
from django.core.mail import send_mail
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
class UserManager(BaseUserManager):
@classmethod
def normalize_email(cls, email):
@jsma
jsma / models.py
Created June 10, 2011 13:45
Satchmo: apply discount to each product, not an even split
"""
This model should be in an app that is loaded after Satchmo's apps so the class method override is applied last.
This is not an ideal approach but is better than monkey-patching Satchmo's source.
"""
from decimal import Decimal
from product.models import Discount
from product import signals as product_signals
from satchmo_store.shop.models import OrderItem
@jsma
jsma / django-cms inherit plugin form
Created January 18, 2011 21:49
This updates the ModelForm to use the InheritPagePlaceholder model rather than Link
diff --git a/cms/plugins/inherit/forms.py b/cms/plugins/inherit/forms.py
index a847f9a..b454d28 100644
--- a/cms/plugins/inherit/forms.py
+++ b/cms/plugins/inherit/forms.py
@@ -1,6 +1,6 @@
from django.forms.models import ModelForm
from django.utils.translation import ugettext_lazy as _
-from cms.plugins.link.models import Link
+from cms.plugins.inherit.models import InheritPagePlaceholder
from django import forms