~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/user.py

  • Committer: mattgiuca
  • Date: 2008-02-19 06:10:53 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:503
user.py: Added acct_expired and pass_expired methods.
login.py: Removed has_expired function (now we put it inside the class)
    and called those methods instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
))
33
33
user_fields_list = (
34
34
    "login", "state", "unixid", "email", "nick", "fullname",
35
 
    "role", "studentid"
 
35
    "role", "studentid", "acct_exp", "pass_exp"
36
36
)
37
 
# Fields not included: passhash, acct_exp, pass_exp, last_login
 
37
# Fields not included: passhash, last_login
38
38
 
39
39
class UserException(Exception):
40
40
    pass
72
72
        items = ["%s=%s" % (r, repr(self.__getattribute__(r)))
73
73
            for r in user_fields_list]
74
74
        return "User(" + ', '.join(items) + ")"
 
75
 
75
76
    def hasCap(self, capability):
76
77
        """Given a capability (which is a Role object), returns True if this
77
78
        User has that capability, False otherwise.
78
79
        """
79
80
        return self.role.hasCap(capability)
 
81
 
 
82
    def pass_expired(self):
 
83
        """Determines whether the pass_exp field indicates that
 
84
           login should be denied.
 
85
        """
 
86
        fieldval = self.pass_exp
 
87
        return fieldval is not None and time.localtime() > fieldval
 
88
    def acct_expired(self):
 
89
        """Determines whether the acct_exp field indicates that
 
90
           login should be denied.
 
91
        """
 
92
        fieldval = self.acct_exp
 
93
        return fieldval is not None and time.localtime() > fieldval