Skip to content

Instantly share code, notes, and snippets.

@seb-thomas
Created March 28, 2013 13:46
Show Gist options
  • Save seb-thomas/5263224 to your computer and use it in GitHub Desktop.
Save seb-thomas/5263224 to your computer and use it in GitHub Desktop.
class Box(BaseModel):
BLACK, WHITE = 0, 1
BLACK_N_WHITE = (
(BLACK, 'black'),
(WHITE, 'white'),
)
TOP, MIDDLE, BOTTOM = 0, 1, 2
VALIGN_CHOICES = (
(TOP, 'top'),
(MIDDLE, 'middle'),
(BOTTOM, 'bottom'),
)
slide = models.ForeignKey(Slide, related_name='boxes')
boxtype_label = models.PositiveIntegerField(
verbose_name='box type',
choices=BOXTYPE_CHOICES,
default=CUSTOM_BOXTYPE,
help_text="Please use the following format: <em>YYYY-MM-DD</em>."
)
ordering = models.SmallIntegerField(blank=True, null=True, default=0)
title = models.TextField(blank=True, null=True)
url = models.CharField(max_length=2048, blank=True, null=True)
image = models.ImageField(upload_to="box", blank=True, null=True)
text_colour = models.PositiveIntegerField(
choices=BLACK_N_WHITE,
default=WHITE
)
background_colour = RGBColorField(default='#F00000')
text_valign = models.PositiveIntegerField(
verbose_name='vertical alignment',
choices=VALIGN_CHOICES,
default=BOTTOM
)
.........
boxtype_config.py
.........
CUSTOM_BOXTYPE = 2
BOXTYPE_CHOICES = (
(0, 'twitter'),
(1, 'soundcloud'),
(CUSTOM_BOXTYPE, 'custom'),
)
......
forms.py
......
class BoxForm(ModelForm):
class Meta:
model = Box
widgets = {
'ordering': HiddenInput,
'slide': HiddenInput,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment