Merge pull request #103 from kratorius/save-fix

Pass generic parameters to inherited model save()
This commit is contained in:
Ross Poulton 2012-01-23 14:59:41 -08:00
commit 62e9866254

View File

@ -197,7 +197,7 @@ class Queue(models.Model):
return u'%s <%s>' % (self.title, self.email_address) return u'%s <%s>' % (self.title, self.email_address)
from_address = property(_from_address) from_address = property(_from_address)
def save(self, force_insert=False, force_update=False): def save(self, *args, **kwargs):
if self.email_box_type == 'imap' and not self.email_box_imap_folder: if self.email_box_type == 'imap' and not self.email_box_imap_folder:
self.email_box_imap_folder = 'INBOX' self.email_box_imap_folder = 'INBOX'
@ -210,7 +210,7 @@ class Queue(models.Model):
self.email_box_port = 995 self.email_box_port = 995
elif self.email_box_type == 'pop3' and not self.email_box_ssl: elif self.email_box_type == 'pop3' and not self.email_box_ssl:
self.email_box_port = 110 self.email_box_port = 110
super(Queue, self).save(force_insert, force_update) super(Queue, self).save(*args, **kwargs)
class Ticket(models.Model): class Ticket(models.Model):
@ -436,7 +436,7 @@ class Ticket(models.Model):
return ('helpdesk_view', (self.id,)) return ('helpdesk_view', (self.id,))
get_absolute_url = models.permalink(get_absolute_url) get_absolute_url = models.permalink(get_absolute_url)
def save(self, force_insert=False, force_update=False): def save(self, *args, **kwargs):
if not self.id: if not self.id:
# This is a new ticket as no ID yet exists. # This is a new ticket as no ID yet exists.
self.created = datetime.now() self.created = datetime.now()
@ -446,7 +446,7 @@ class Ticket(models.Model):
self.modified = datetime.now() self.modified = datetime.now()
super(Ticket, self).save(force_insert, force_update) super(Ticket, self).save(*args, **kwargs)
class FollowUpManager(models.Manager): class FollowUpManager(models.Manager):
@ -527,11 +527,11 @@ class FollowUp(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return u"%s#followup%s" % (self.ticket.get_absolute_url(), self.id) return u"%s#followup%s" % (self.ticket.get_absolute_url(), self.id)
def save(self, force_insert=False, force_update=False): def save(self, *args, **kwargs):
t = self.ticket t = self.ticket
t.modified = datetime.now() t.modified = datetime.now()
t.save() t.save()
super(FollowUp, self).save(force_insert, force_update) super(FollowUp, self).save(*args, **kwargs)
class TicketChange(models.Model): class TicketChange(models.Model):
@ -843,10 +843,10 @@ class KBItem(models.Model):
blank=True, blank=True,
) )
def save(self, force_insert=False, force_update=False): def save(self, *args, **kwargs):
if not self.last_updated: if not self.last_updated:
self.last_updated = datetime.now() self.last_updated = datetime.now()
return super(KBItem, self).save(force_insert, force_update) return super(KBItem, self).save(*args, **kwargs)
def _score(self): def _score(self):
if self.votes > 0: if self.votes > 0:
@ -1024,10 +1024,10 @@ class IgnoreEmail(models.Model):
def __unicode__(self): def __unicode__(self):
return u'%s' % self.name return u'%s' % self.name
def save(self): def save(self, *args, **kwargs):
if not self.date: if not self.date:
self.date = datetime.now() self.date = datetime.now()
return super(IgnoreEmail, self).save() return super(IgnoreEmail, self).save(*args, **kwargs)
def test(self, email): def test(self, email):
""" """