← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/maas/migrate-commoninfo into lp:maas

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/migrate-commoninfo into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jtv/maas/migrate-commoninfo/+merge/104054

As per the migration plan: move CommonInfo out into a models module of its own.


Jeroen
-- 
https://code.launchpad.net/~jtv/maas/migrate-commoninfo/+merge/104054
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/migrate-commoninfo into lp:maas.
=== modified file 'src/maasserver/models/__init__.py'
--- src/maasserver/models/__init__.py	2012-04-27 13:55:54 +0000
+++ src/maasserver/models/__init__.py	2012-04-30 03:57:20 +0000
@@ -59,7 +59,6 @@
 from django.db.models.signals import post_save
 from django.shortcuts import get_object_or_404
 from django.utils.safestring import mark_safe
-from maasserver import DefaultMeta
 from maasserver.enum import (
     ARCHITECTURE,
     ARCHITECTURE_CHOICES,
@@ -78,6 +77,7 @@
     JSONObjectField,
     MACAddressField,
     )
+from maasserver.models.commoninfo import CommonInfo
 from metadataserver import nodeinituser
 from piston.models import (
     Consumer,
@@ -108,33 +108,6 @@
     return cursor.fetchone()[0]
 
 
-# Due for model migration on 2012-04-30.
-class CommonInfo(models.Model):
-    """A base model which:
-    - calls full_clean before saving the model (by default).
-    - records the creation date and the last modification date.
-
-    :ivar created: The creation date.
-    :ivar updated: The last modification date.
-
-    """
-
-    class Meta(DefaultMeta):
-        abstract = True
-
-    created = models.DateTimeField(editable=False)
-    updated = models.DateTimeField(editable=False)
-
-    def save(self, skip_check=False, *args, **kwargs):
-        date_now = now()
-        if not self.id:
-            self.created = date_now
-        self.updated = date_now
-        if not skip_check:
-            self.full_clean()
-        return super(CommonInfo, self).save(*args, **kwargs)
-
-
 def generate_node_system_id():
     return 'node-%s' % uuid1()