def forwards(self, orm): alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' numconv = NumConv(len(alphabet), alphabet) for i, prodtype in enumerate( orm.ProductionType.objects.order_by('name')): key = numconv.int2str(i + 1) prodtype.path = '%s%s' % ('0' * (4 - len(key)), key) prodtype.depth = 1 prodtype.save()
def forwards(self, orm): alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' numconv = NumConv(len(alphabet), alphabet) for i, prodtype in enumerate(orm.ProductionType.objects.order_by('name')): key = numconv.int2str(i+1) prodtype.path = '%s%s' % ( '0' * (4 - len(key)), key) prodtype.depth = 1 prodtype.save()
from south.utils import datetime_utils as datetime from south.db import db from south.v2 import DataMigration from django.db import models from treebeard.numconv import NumConv STEPLEN = 4 ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' class MP_AddHandler(object): def __init__(self): self.stmts = [] NUM = NumConv(len(ALPHABET), ALPHABET) def _int2str(num): return NUM.int2str(num) def _str2int(num): return NUM.str2int(num) def _get_basepath(path, depth): """:returns: The base path of another path up to a given depth""" if path: return path[0:depth * STEPLEN] return ''
def numconv_obj(cls): if cls.numconv_obj_ is None: cls.numconv_obj_ = NumConv(len(cls.alphabet), cls.alphabet) return cls.numconv_obj_