Age property in penguin data model

This commit is contained in:
Ben 2019-06-08 21:12:48 +01:00
parent 7e9ccf4b9a
commit 75add84f09

View File

@ -1,3 +1,5 @@
from datetime import datetime
from houdini.data import db from houdini.data import db
from houdini.data.permission import PermissionCrumbsCollection from houdini.data.permission import PermissionCrumbsCollection
@ -103,6 +105,10 @@ class Penguin(db.Model):
def safe_nickname(self, language_bitmask): def safe_nickname(self, language_bitmask):
return self.nickname if self.approval & language_bitmask else "P" + str(self.id) return self.nickname if self.approval & language_bitmask else "P" + str(self.id)
@property
def age(self):
return (datetime.now() - self.registration_date).days
@property @property
def approval(self): def approval(self):
return int('{}{}0{}{}{}{}'.format(self.approval_ru * 1, self.approval_de * 1, self.approval_es * 1, return int('{}{}0{}{}{}{}'.format(self.approval_ru * 1, self.approval_de * 1, self.approval_es * 1,