Changeset - d7f13c2a28ba
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 10 years ago 2015-06-01 17:40:31
thomas.de.schampheleire@gmail.com
UserModel: remove code duplication of User.get_by_username()

UserModel.get_by_username() and User.get_by_username() implement the same
logic and thus one should use the other instead of duplicating.
1 file changed with 1 insertions and 10 deletions:
0 comments (0 inline, 0 general)
kallithea/model/user.py
Show inline comments
 
@@ -57,22 +57,13 @@ class UserModel(BaseModel):
 
        return user.get(user_id)
 

	
 
    def get_user(self, user):
 
        return self._get_user(user)
 

	
 
    def get_by_username(self, username, cache=False, case_insensitive=False):
 

	
 
        if case_insensitive:
 
            user = self.sa.query(User).filter(User.username.ilike(username))
 
        else:
 
            user = self.sa.query(User)\
 
                .filter(User.username == username)
 
        if cache:
 
            user = user.options(FromCache("sql_cache_short",
 
                                          "get_user_%s" % username))
 
        return user.scalar()
 
        return User.get_by_username(username, case_insensitive, cache)
 

	
 
    def get_by_email(self, email, cache=False, case_insensitive=False):
 
        return User.get_by_email(email, case_insensitive, cache)
 

	
 
    def get_by_api_key(self, api_key, cache=False):
 
        return User.get_by_api_key(api_key, cache)
0 comments (0 inline, 0 general)