def test_order_field_cant_be_unique(self): asserted = False # Ubgly, is there a asseetException??? try: field = OrderedField(unique=True) except TypeError: asserted = True self.assertTrue(asserted)
class Item(models.Model): list = models.ForeignKey('List', related_name='items', on_delete=models.CASCADE) name = models.CharField(max_length=100) order = OrderedCollectionField(collection=['list'], extra_field_updates={ 'order_changed_count': models.F("order_changed_count") + 1, }) order_changed_count = models.IntegerField(default=0) rank = OrderedField( extra_field_updates={ 'rank_changed_count': models.F("rank_changed_count") + 1 }) rank_changed_count = models.IntegerField(default=0) """__original_order = None def __init__(self, *args, **kwargs): super(Item, self).__init__(*args, **kwargs) self.__original_order = self.order""" def __unicode__(self): return str( self.name) + " (List: " + self.list.name + ", position: " + str( self.order) + ")" """def save(self, force_insert=False, force_update=False, using=None,
class HearthstoneRanking(models.Model): name = models.CharField(max_length=100) description = models.TextField() rank = OrderedField( extra_field_updates={ 'order_changed_count': models.F("order_changed_count") + 1, 'updated_by': get_loged_in_user }) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) updated_by = models.CharField(max_length=50) order_changed_count = models.IntegerField(default=0) """__original_rank = None def __init__(self, *args, **kwargs): super(HearthstoneRanking, self).__init__(*args, **kwargs) self.__original_rank = self.rank""" """def save(self, force_insert=False, force_update=False, using=None,
class CommonInfoTwo(models.Model): name = models.CharField(max_length=100) position = OrderedField() class Meta: abstract = True
class UnitTwo(models.Model): name = models.CharField(max_length=100) position = OrderedField(parent_link_name='unittwo_ptr')
class UnitTwo(models.Model): name = models.CharField(max_length=100) position = OrderedField()
class TestExceptionClass(models.Model): rank = OrderedField() group = models.IntegerField() class Meta: unique_together = ("rank", "group")
class PersonTwo(models.Model): name = models.CharField(max_length=100) description = models.CharField(max_length=100) position = OrderedField()