From 6a5e34d21b4cb9a5710b45dfbc15f92add2755c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Evren=20Esat=20=C3=96zkan?= Date: Wed, 22 Jun 2016 18:22:33 +0300 Subject: [PATCH] rref #5367 rref #5366 ref zetaops/zengine#66 ref zetaops/zengine#65 --- ulakbus/models/auth.py | 55 +++--------------------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/ulakbus/models/auth.py b/ulakbus/models/auth.py index b527bbbb..ff4bca6b 100644 --- a/ulakbus/models/auth.py +++ b/ulakbus/models/auth.py @@ -15,6 +15,7 @@ from passlib.hash import pbkdf2_sha512 from pyoko import LinkProxy from pyoko.conf import settings +from pyoko.lib.utils import lazy_property from zengine.auth.permissions import get_all_permissions from zengine.dispatch.dispatcher import receiver @@ -51,59 +52,11 @@ class Meta: verbose_name_plural = "Kullanıcılar" search_fields = ['username', 'name', 'surname'] - def get_avatar_url(self): - """ - Bu metot kullanıcıya ait avatar url'ini üretir. - - Returns: - str: kullanıcı avatar url - """ - return "%s%s" % (settings.S3_PUBLIC_URL, self.avatar) - - def __unicode__(self): - return "User %s" % self.username - - def set_password(self, raw_password): - """ - Kullanıcı şifresini encrypt ederek set eder. - - Args: - raw_password (str) - """ - self.password = pbkdf2_sha512.encrypt(raw_password, rounds=10000, - salt_size=10) - - def pre_save(self): - """ encrypt password if not already encrypted """ - if self.password and not self.password.startswith('$pbkdf2'): - self.set_password(self.password) + @lazy_property + def full_name(self): + return "%s %s" % (self.name, self.surname) - def check_password(self, raw_password): - """ - Verilen encrypt edilmemiş şifreyle kullanıcıya ait encrypt - edilmiş şifreyi karşılaştırır. - - Args: - raw_password (str) - Returns: - bool: Değerler aynı olması halinde True, değilse False - döner. - """ - return pbkdf2_sha512.verify(raw_password, self.password) - - def get_role(self, role_id): - """ - Kullanıcıya ait Role nesnesini getirir. - - Args: - role_id (int) - - Returns: - dict: Role nesnesi - - """ - return self.role_set.node_dict[role_id] # def send_message(self, title, message, sender=None): # from zengine.messaging import Notify