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.core.management.base import BaseCommand | |
from django.db.models import get_models, get_app | |
from django.contrib.auth.management import create_permissions | |
class Command(BaseCommand): | |
args = '<app app ...>' | |
help = 'Sync new permissions for specified apps with the database, or all apps if no args are specified' | |
def handle(self, *args, **options): |
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 os import path | |
from django.conf import settings | |
from django.http import Http404 | |
from django.views import static | |
class TryStatic: | |
def __init__(self): | |
self.root = settings.PUBLIC_ROOT | |
self.index_file = 'index.html' |
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.conf.urls import include, url | |
from django.conf import settings | |
from django.contrib import admin | |
urlpatterns = [ | |
url(r'^admin/doc/', include('django.contrib.admindocs.urls')), | |
url(r'^admin/', include(admin.site.urls)), | |
url(r'^accounts/', include('django.contrib.auth.urls')), | |
] |
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
""" | |
Formula para el calculo del Aporte Nacional Solidario Laboral | |
Esta es la explicación legal del calculo de la formula: | |
* 10% de la diferencia del total ganado solidario menos Bs. 35.000 de diferencia positiva | |
* 5% de la diferencia del total ganado solidario menos Bs. 25.000 de diferencia positiva | |
* 1% de la diferencia del total ganado solidario menos Bs. 13.000 de diferencia positiva | |
""" |
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
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. | |
Dual MIT/BSD license https://github.com/paulirish/matchMedia.js */ | |
window.matchMedia = window.matchMedia || (function( doc, undefined ) { | |
"use strict"; | |
var bool, | |
docElem = doc.documentElement, | |
refNode = docElem.firstElementChild || docElem.firstChild, | |
// fakeBody required for <FF4 when executed in <head> |
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
import os | |
import sys | |
reload(sys) | |
sys.setdefaultencoding("utf-8") | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "crowddeals.settings") | |
def touch_wsgistart_info(): | |
from mercurial import hg, ui | |
import time |
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 functools import wraps | |
from django.db import models | |
from django.core.exceptions import ValidationError | |
class ConstraintModel(models.Model): | |
class Meta: | |
abstract = True | |
def _fill_constraints_register(self): |
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
-- returns and update the next value for a named ticket. | |
CREATE OR REPLACE FUNCTION get_ticket(ticket_name varchar(50)) RETURNS INTEGER AS $$ | |
DECLARE | |
ticket INTEGER; -- | |
BEGIN | |
IF EXISTS (SELECT * FROM ticketing_ticket WHERE name = ticket_name FOR UPDATE) THEN | |
UPDATE ticketing_ticket SET currval = currval + incval | |
WHERE name = ticket_name RETURNING currval INTO ticket; -- | |
RETURN ticket; -- |
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
## Boot multiple live-cds from a USB | |
## | |
# First install grub on the usb, for example: | |
# | |
# $ sudo grub-install --no-floppy --force --root-directory=/media/E310-C779 /dev/sdc1 | |
# Get some of the isos you want to boot | |
# | |
# $ ls |
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.contrib.staticfiles.storage import CachedFilesMixin, StaticFilesStorage | |
from pipeline.storage import PipelineMixin | |
def coroutine(func): | |
def start(*args, **kwargs): | |
cr = func(*args, **kwargs) | |
cr.next() | |
return cr | |
return start |