Skip to content

Commit

Permalink
Split model back up, moved sites to AdPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Ober committed Nov 8, 2012
1 parent 81bfd48 commit b98d0d0
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions adgeletti/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,25 @@ def __unicode__(self):
return _(u'%dpx x %dpx') % (self.width, self.height)


class AdUnit(models.Model):
"""An ad for the selected ``Site``.
"""
label = models.CharField(_(u'Label'), max_length=50, unique=True, help_text=_(u'A helpful label for this ad unit.'))
ad_unit = models.CharField(_(u'Ad unit ID'), max_length=255, unique=True, help_text=_(u'The ad unit ID, without the network ID'))

def __unicode__(self):
return self.label

@property
def ad_unit_id(self):
return u'%s/%s' % (settings.ADGELETTI_DFP_NETWORK_ID, self.ad_unit)


class AdPosition(models.Model):
"""An ad unit for display at the selected sizes, for the selected breakpoint
in the selected slot.
"""
ad_unit = models.CharField(_(u'Ad unit ID'), max_length=255, unique=True, help_text=_(u'The ad unit ID, without the network ID'))
ad_unit = models.ForeignKey(AdUnit, verbose=_(u'ad unit'))
slot = models.CharField(_(u'slot'), max_length=255, choices=[(slot, slot) for slot in settings.ADGELETTI_SLOTS])
breakpoint = models.CharField(_(u'breakpoint'), max_length=255, choices=[(bp, bp) for bp in settings.ADGELETTI_BREAKPOINTS])
sizes = models.ManyToManyField(Size, verbose_name=_(u'allowed sizes'))
Expand All @@ -31,8 +45,3 @@ class AdPosition(models.Model):
class Meta:
unique_together = ('ad_unit', 'slot', 'breakpoint', 'site')

@property
def ad_unit_id(self):
return u'%s/%s' % (settings.ADGELETTI_DFP_NETWORK_ID, self.ad_unit)


0 comments on commit b98d0d0

Please sign in to comment.