示例#1
0
 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)
示例#2
0
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,
示例#3
0
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,
示例#4
0
class CommonInfoTwo(models.Model):
    name = models.CharField(max_length=100)
    position = OrderedField()

    class Meta:
        abstract = True
示例#5
0
class UnitTwo(models.Model):
    name = models.CharField(max_length=100)
    position = OrderedField(parent_link_name='unittwo_ptr')
示例#6
0
class UnitTwo(models.Model):
    name = models.CharField(max_length=100)
    position = OrderedField()
示例#7
0
    class TestExceptionClass(models.Model):
        rank = OrderedField()
        group = models.IntegerField()

        class Meta:
            unique_together = ("rank", "group")
示例#8
0
class PersonTwo(models.Model):
    name = models.CharField(max_length=100)
    description = models.CharField(max_length=100)
    position = OrderedField()