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 Migration(SchemaMigration): | |
def forwards(self, orm): | |
# Adding field 'Publication.subclass' | |
db.add_column('publishing_publication', 'subclass', self.gf('django.db.models.fields.CharField')(default='Publication', max_length=48), keep_default=False) | |
for obj in orm.Publication.objects.all(): | |
obj.subclass = '{0}.{1}'.format( | |
obj._meta.app_label, obj.__class__.__name__) | |
obj.save() |
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.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
from django.core.validators import RegexValidator | |
from django.template.defaultfilters import slugify | |
from django_countries.fields import CountryField | |
from model_utils import Choices | |
from filebrowser.fields import FileBrowseField | |
try: | |
from south.modelsinspector import add_introspection_rules |
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 forwards(self, orm): | |
"Write your forwards methods here." | |
def set_real_type(obj): | |
obj.real_type = orm["contenttypes.ContentType"].objects.get_for_model(type(obj)) | |
obj.save() | |
# migrate existing objects | |
for obj in orm.Book.objects.all(): | |
set_real_type(obj) | |
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
# encoding: utf-8 | |
import datetime | |
from south.db import db | |
from south.v2 import DataMigration | |
from django.db import models | |
from django.utils.encoding import smart_unicode | |
class Migration(DataMigration): | |
def forwards(self, orm): |
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
>>> Person.objects.filter(visitor=False) | |
[] | |
>>> Person.objects.values('visitor') | |
[{'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, '...(remaining elements truncated)...'] | |
>>> Person.objects.all().filter(visitor=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
CREATE TABLE "people_person" ("picture" varchar(200), "first_name" varchar(64), "last_name" varchar(64), "description" text, "web_page" varchar(200), "visitor" bool NOT NULL DEFAULT False, "e_mail" varchar(75), "rank_id" integer, "current" bool, "public" bool, "mid_name" varchar(64), "id" integer PRIMARY KEY); |
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
sqlite> .schema people_person | |
CREATE TABLE "people_person" ("picture" varchar(200), "first_name" varchar(64), "last_name" varchar(64), "description" text, "web_page" varchar(200), "visitor" bool NOT NULL DEFAULT False, "e_mail" varchar(75), "rank_id" integer, "current" bool, "public" bool, "mid_name" varchar(64), "id" integer PRIMARY KEY); | |
sqlite> select 'production',visitor from people_person; | |
production|False | |
production|False | |
production|False | |
production|False | |
production|False | |
production|False | |
production|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
location /admin/ { | |
if ( $scheme == http ) { | |
rewrite ^ https://$host$uri permanent; | |
} | |
} |
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
#nginx.conf | |
user www-data; | |
worker_processes 1; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
use epoll; |
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
#! /bin/sh | |
# Quick and dirty check for BlackHole RAT (OSX/MusMinim-A) | |
# * http://www.sophos.com/security/analyses/viruses-and-spyware/osxmusminima.html | |
# | |
# USAGE: | |
# - Copy this file in your Desktop | |
# - Open Terminal.app | |
# - Run the following commands: | |
# - cd ~/Desktop | |
# - chmod +x blackholeratcheck.sh |
OlderNewer