Beispiel #1
0
class Words_Style(models.Model):
    words = models.ForeignKey('Words', on_delete=models.CASCADE)
    #default color as rgba xxx,xxx,xxx append alpha from opacity when return
    color = models.CharField(default='0,0,0', blank=True, max_length=13)
    #if choosing to have a color increase then do so by x amount (int)
    color_r_int = models.IntegerField(default=0, blank=True)
    #red color is 0-255 max
    color_range_r = IntegerRangeField(
        default='(0, 255)',
        blank=True,
        validators=[RangeMinValueValidator(0),
                    RangeMaxValueValidator(255)])
    color_g_int = models.IntegerField(default=0, blank=True)
    color_range_g = IntegerRangeField(
        default='(0, 255)',
        blank=True,
        validators=[RangeMinValueValidator(0),
                    RangeMaxValueValidator(255)])
    color_b_int = models.IntegerField(default=0, blank=True)
    color_range_b = IntegerRangeField(
        default='(0, 255)',
        blank=True,
        validators=[RangeMinValueValidator(0),
                    RangeMaxValueValidator(255)])

    size = models.IntegerField(default=1, blank=True)
    size_range = IntegerRangeField(
        default='(1, 10)',
        blank=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(10)])
    style = models.CharField(max_length=8, default='', blank=True)
    marquee = models.BooleanField(default=False)
Beispiel #2
0
class Marquee_Style(models.Model):
    image = models.ForeignKey('Image',
                              on_delete=models.CASCADE,
                              blank=True,
                              null=True)
    words = models.ForeignKey('Words',
                              on_delete=models.CASCADE,
                              blank=True,
                              null=True)
    behavior = models.CharField(max_length=24, default="scroll")
    direction = models.CharField(max_length=18, default="left")
    scrollamount = models.IntegerField(default=1)
    scrollamount_range = IntegerRangeField(
        default='(1, 50)',
        blank=True,
        null=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(5)])
    scrolldelay = models.IntegerField(default=1)
    scrolldelay_range = IntegerRangeField(
        default='(1, 50)',
        blank=True,
        null=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(5)])
 def test_min(self):
     validator = RangeMinValueValidator(5)
     validator(NumericRange(10, 15))
     with self.assertRaises(exceptions.ValidationError) as cm:
         validator(NumericRange(0, 10))
     self.assertEqual(cm.exception.messages[0], 'Ensure that this range is completely greater than or equal to 5.')
     self.assertEqual(cm.exception.code, 'min_value')
Beispiel #4
0
 def test_min(self):
     validator = RangeMinValueValidator(5)
     validator(NumericRange(10, 15))
     msg = "Ensure that this range is completely greater than or equal to 5."
     with self.assertRaises(exceptions.ValidationError) as cm:
         validator(NumericRange(0, 10))
     self.assertEqual(cm.exception.messages[0], msg)
     self.assertEqual(cm.exception.code, "min_value")
     with self.assertRaisesMessage(exceptions.ValidationError, msg):
         validator(NumericRange(None, 10))  # an unbound range
Beispiel #5
0
class Image_Style(models.Model):
    image = models.ForeignKey('Image', on_delete=models.CASCADE)
    width = models.IntegerField(blank=True, default=0)
    width_range = IntegerRangeField(
        default='(1, 101)',
        blank=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(100)])
    height = models.IntegerField(blank=True, default=0)
    height_range = IntegerRangeField(
        default='(1,101)',
        blank=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(100)])
    brads_tl = models.IntegerField(blank=True, default=0)
    brads_tl_range = IntegerRangeField(
        default='(1,101)',
        blank=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(100)])
    brads_tr = models.IntegerField(blank=True, default=0)
    brads_tr_range = IntegerRangeField(
        default='(1,101)',
        blank=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(100)])
    brads_bl = models.IntegerField(blank=True, default=0)
    brads_bl_range = IntegerRangeField(
        default='(1,101)',
        blank=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(100)])
    brads_br = models.IntegerField(blank=True, default=0),
    brads_br_range = IntegerRangeField(
        default='(1,101)',
        blank=True,
        validators=[RangeMinValueValidator(1),
                    RangeMaxValueValidator(100)])
    opacity = models.FloatField(blank=True, default=1)
    opacity_range = FloatRangeField(
        default='(0.1, 1.1)',
        blank=True,
        validators=[RangeMinValueValidator(0.1),
                    RangeMaxValueValidator(1.1)])
    marquee = models.BooleanField(
        default=False
    )  #should look this up...? maybe set up a function to do so.and automatically tie it to the IRS.