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
document.addEventListener('touchstart', function addtouchclass(e){ // first time user touches the screen | |
document.documentElement.classList.add('is-touch') // add "can-touch" class to document root using classList API | |
document.removeEventListener('touchstart', addtouchclass, false) // de-register touchstart event | |
}, false) |
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
// check: if we came frome our own site, just use history.back() | |
// as simple as it gets. | |
on_back_click: function(e) { | |
// this check could be further enhanced, but works quite well already. | |
if (document.referrer.indexOf(window.location.host) !== -1) { | |
e.preventDefault(); | |
history.back(); | |
} | |
} |
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 __future__ import unicode_literals | |
from aldryn_search.base import AldrynIndexBase | |
from django.template.loader import render_to_string | |
from haystack import indexes | |
from bodenschatz.models import Product | |
class ProductIndex(AldrynIndexBase, indexes.Indexable): |
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
# coding: utf-8 | |
from __future__ import unicode_literals | |
import re | |
from cms.models import CMSPlugin | |
from django.core.management.base import BaseCommand | |
class Command(BaseCommand): | |
""" |
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
var WhatEverPlugin = (function ($) { | |
'use strict'; | |
var $plugins; | |
// public api | |
var api = { | |
reset_all: reset_all, | |
reset_by_selector: reset_by_selector | |
}; |
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
def migrate_to_modeltranslation(queryset, fields): | |
""" | |
to be used in data migrations, for migrating nani/hvad to modeltranslation | |
:param queryset: | |
:param fields: | |
:return: | |
""" | |
if not queryset.count(): |
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 __future__ import unicode_literals | |
from django.conf import settings | |
class LanguageTabsMixin(object): | |
change_form_template = 'admin/modeltranslation/change_form.html' | |
def change_view(self, request, object_id, form_url='', extra_context=None): | |
context = extra_context or {} |
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
=> ./manage.py datamigration your_app rename_plugin_tables | |
def rename_tables(db, table_mapping, reverse=False): | |
""" | |
renames tables from source to destination name, if the source exists and the destination does | |
not exist yet. | |
""" | |
from django.db import connection | |
if reverse: |
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 aldryn_search.search_indexes import TitleIndex | |
from cms.models import CMSPlugin | |
from djangocms_misc.global_untranslated_placeholder.utils import get_untranslated_default_language | |
class UntranslatedTitleIndex(TitleIndex): | |
def get_plugin_queryset(self, language): | |
queryset = CMSPlugin.objects.filter( | |
language=get_untranslated_default_language() |
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
# add to your normal cms_plugins.py whateverplugin | |
class DemoPlugin(CMSPluginBase): | |
model = Demo | |
... | |
def get_plugin_urls(self): |