Commit bcbd77b8 authored by Adrián Ribao's avatar Adrián Ribao
Browse files

changed models for cartero

parent 0c35eb2b
......@@ -2,7 +2,7 @@
from django.contrib.sites.models import Site
from django.db import models
#from django.template.defaultfilters import slugify
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext_lazy as _
import os
import datetime
from django.template import Template, Context
......@@ -16,6 +16,8 @@ from django.conf import settings
from cartero.conf import CarteroConf
#from django.contrib.auth.models import User
print "HI THERE"
class Contact(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
......@@ -35,7 +37,7 @@ class Contact(models.Model):
class Meta:
verbose_name = _(u'Contact')
verbose_name_plural = _(u'Contacts')
def __unicode__(self):
representation = u'{0} {1} {2}'.format(self.email, self.first_name, self.last_name)
if self.testing:
......@@ -59,7 +61,7 @@ class EmailTemplate(models.Model):
class Meta:
verbose_name = _(u'Email template')
verbose_name_plural = _(u'Email templates')
def __unicode__(self):
return u'{0}'.format(self.name)
......@@ -138,14 +140,14 @@ class Campaign(models.Model):
#ordering = ['order', ]
verbose_name = _(u'Campaign')
verbose_name_plural = _(u'Campaigns')
def __unicode__(self):
return u'%s' % (self.name, )
@property
def rate_limit(self):
return '{0}/{1}'.format(self.rate_limit_amount, self.rate_limit_interval)
def add_contacts(self, contacts):
"""
Adds the contacts to the campaign, and check if they are not excluded.
......@@ -205,7 +207,7 @@ class ExcludedEmail(models.Model):
class Meta:
verbose_name = _(u'Excluded Email')
verbose_name_plural = _(u'Excluded Emails')
def __unicode__(self):
return u'{0} {1}'.format(self.email, self.get_reason_display())
......@@ -218,11 +220,11 @@ class ShortURL(models.Model):
modified = models.DateTimeField(auto_now=True)
url = models.CharField(max_length=255, verbose_name=_(u'URL'), db_index=True)
code = models.CharField(max_length=75, verbose_name=_(u'Code'), db_index=True, unique=True)
class Meta:
verbose_name = _(u'Short URL')
verbose_name_plural = _(u'Short URLs')
def __unicode__(self):
return u'{0}: {1}'.format(self.url, self.code)
......@@ -246,17 +248,17 @@ class LinkClick(models.Model):
#short_url = models.CharField(max_length=75, verbose_name=_(u'Short url'), db_index=True)
ip_address = models.IPAddressField(verbose_name=_(u'IP Address'), null=True, db_index=True)
campaign = models.ForeignKey(Campaign, verbose_name=_(u'Campaign'))
class Meta:
verbose_name = _(u'Link Click')
verbose_name_plural = _(u'Link Clicks')
def __unicode__(self):
return u'{0} {1}'.format(self.url, self.campaign)
#def save(self, force_insert=False, force_update=False):
#@models.permalink
#def get_absolute_url(self):
#return ('view_or_url_name' )
......@@ -270,7 +272,7 @@ class MailTracks(models.Model):
class Meta:
verbose_name = _(u'Mail Track')
verbose_name_plural = _(u'Mail Tracks')
def __unicode__(self):
return u'{0} {1}'.format(self.campaign, self.contact)
......@@ -283,16 +285,16 @@ class OpenEmail(models.Model):
ip_address = models.IPAddressField(verbose_name=_(u'IP Address'), null=True, db_index=True)
campaign = models.ForeignKey(Campaign, verbose_name=_(u'Campaign'))
contact = models.ForeignKey(Contact, verbose_name=_(u'Contact'))
class Meta:
verbose_name = _(u'Open Mail')
verbose_name_plural = _(u'Open Mails')
def __unicode__(self):
return u'{0} {1}'.format(self.campaign, self.contact)
#def save(self, force_insert=False, force_update=False):
#@models.permalink
#def get_absolute_url(self):
#return ('view_or_url_name' )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment