from django.db import models
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import get_language

from rdmo.core.exceptions import RDMOException
from rdmo.core.utils import get_languages


class Model(models.Model):

    created = models.DateTimeField(editable=False, verbose_name=_('created'))
    updated = models.DateTimeField(editable=False, verbose_name=_('updated'))

    class Meta:
        abstract = True

    def save(self, *args, **kwargs):
        if not self.id or kwargs.get('force_insert', False):
            self.created = now()

        self.updated = now()
        super(Model, self).save(*args, **kwargs)


class TranslationMixin(object):

    def trans(self, field):
        current_language = get_language()

        languages = get_languages()
        for lang_code, lang_string, lang_field in languages:
            if lang_code == current_language:
                return getattr(self, '%s_%s' % (field, lang_field)) or ''

        primary_lang_field = languages[0][2]
        return getattr(self, '%s_%s' % (field, primary_lang_field)) or ''

@@ -101,26 +101,20 @@
 ort 
-u
 get
-text_lazy as _
+_language
 %0Afro
@@ -151,68 +151,26 @@
 ort 
+u
 get
-_language%0A%0Afrom rdmo.core.exceptions import RDMOException
+text_lazy as _
 %0Afro
@@ -488,56 +488,28 @@
  if 
-not 
 self.
-id or kwargs.get('force_insert', False)
+created is None
 :%0A  
@@ -569,16 +569,17 @@
 = now()%0A
+%0A
         

Refactor core models.py