from django.utils.translation import ugettext_lazy as _
import mongoengine
from pages.models import LandingPage

mongoengine.connect('seo')


class Position(mongoengine.Document):
    value = mongoengine.IntField(verbose_name=_("position"))
    landing_page = mongoengine.ReferenceField(LandingPage, verbose_name=_("landing page"))
    phrase = mongoengine.ReferenceField('phrases.Phrase', verbose_name=_("phrase"))
    check_date = mongoengine.DateTimeField(verbose_name=_("check date"))

    meta = {
        'ordering': ('-check_date',)
    }

    @property
    def creation_date(self):
        return self.id.generation_time
