Changeset 2721

Show
Ignore:
Timestamp:
02/20/06 23:26:45 (19 years ago)
Author:
jerome
Message:

Added missing description handling stuff

Location:
pykota/trunk/pykota/storages
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2718 r2721  
    355355        user = StorageUser(self, username) 
    356356        username = self.userCharsetToDatabase(username) 
    357         result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge"], base=self.info["userbase"]) 
     357        result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge", "description"], base=self.info["userbase"]) 
    358358        if result : 
    359359            fields = result[0][1] 
    360360            user.ident = result[0][0] 
     361            user.Description = self.databaseToUserCharset(fields.get("description", [None])[0]) 
    361362            user.Email = fields.get(self.info["usermail"], [None])[0] 
    362363            user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
     
    400401        group = StorageGroup(self, groupname) 
    401402        groupname = self.userCharsetToDatabase(groupname) 
    402         result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy"], base=self.info["groupbase"]) 
     403        result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy", "description"], base=self.info["groupbase"]) 
    403404        if result : 
    404405            fields = result[0][1] 
    405406            group.ident = result[0][0] 
    406407            group.Name = fields.get("pykotaGroupName", [self.databaseToUserCharset(groupname)])[0]  
     408            group.Description = self.databaseToUserCharset(fields.get("description", [None])[0]) 
    407409            group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
    408410            group.AccountBalance = 0.0 
     
    701703        # see comment at the same place in pgstorage.py 
    702704        result = self.doSearch("objectClass=pykotaAccount", \ 
    703                                   ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge"], \ 
     705                                  ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge", "description"], \ 
    704706                                  base=self.info["userbase"]) 
    705707        if result : 
     
    713715                    user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
    714716                    user.OverCharge = float(fields.get("pykotaOverCharge", [1.0])[0]) 
     717                    user.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
    715718                    uname = self.userCharsetToDatabase(username) 
    716719                    result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % \ 
     
    758761        # see comment at the same place in pgstorage.py 
    759762        result = self.doSearch("objectClass=pykotaGroup", \ 
    760                                   ["pykotaGroupName", "pykotaLimitBy"], \ 
     763                                  ["pykotaGroupName", "pykotaLimitBy", "description"], \ 
    761764                                  base=self.info["groupbase"]) 
    762765        if result : 
     
    769772                    group.Name = fields.get("pykotaGroupName", [self.databaseToUserCharset(groupname)])[0]  
    770773                    group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
     774                    group.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
    771775                    group.AccountBalance = 0.0 
    772776                    group.LifeTimePaid = 0.0 
     
    867871                       "pykotaLimitBy" : (user.LimitBy or "quota"), 
    868872                       "pykotaOverCharge" : str(user.OverCharge), 
     873                       "description" : self.userCharsetToDatabase(user.Description or "") 
    869874                    }    
    870875                        
    871876        if user.Email : 
    872877            newfields.update({self.info["usermail"]: user.Email}) 
    873         if user.Description is not None :  
    874             newfields.update({"description": self.userCharsetToDatabase(user.Description)}) 
    875878        mustadd = 1 
    876879        if self.info["newuser"].lower() != 'below' : 
     
    933936                      "pykotaGroupName" : gname, 
    934937                      "pykotaLimitBy" : (group.LimitBy or "quota"), 
     938                      "description" : self.userCharsetToDatabase(group.Description or "") 
    935939                    }  
    936         if group.Description is not None :  
    937             newfields.update({"description": self.userCharsetToDatabase(group.Description)}) 
    938940        mustadd = 1 
    939941        if self.info["newgroup"].lower() != 'below' : 
     
    10411043                       "pykotaLimitBy" : (user.LimitBy or "quota"), 
    10421044                       "pykotaOverCharge" : str(user.OverCharge), 
     1045                       "description" : self.userCharsetToDatabase(user.Description or ""),  
    10431046                    }    
    10441047        if user.Email : 
    10451048            newfields.update({self.info["usermail"]: user.Email}) 
    1046         if user.Description is not None :  
    1047             newfields.update({"description": self.userCharsetToDatabase(user.Description)}) 
    10481049        self.doModify(user.ident, newfields) 
    10491050         
     
    10571058        newfields = { 
    10581059                       "pykotaLimitBy" : (group.LimitBy or "quota"), 
     1060                       "description" : self.userCharsetToDatabase(group.Description or ""),  
    10591061                    }    
    1060         if group.Description is not None :  
    1061             newfields.update({"description": self.userCharsetToDatabase(group.Description)}) 
    10621062        self.doModify(group.ident, newfields) 
    10631063         
     
    14801480        entries = [u for u in [self.getUser(name) for name in self.getAllUsersNames(uname)] if u.Exists] 
    14811481        if entries : 
    1482             result = [ ("dn", "username", "balance", "lifetimepaid", "limitby", "email") ] 
     1482            result = [ ("dn", "username", "balance", "lifetimepaid", "limitby", "email", "description") ] 
    14831483            for entry in entries : 
    1484                 result.append((entry.ident, entry.Name, entry.AccountBalance, entry.LifeTimePaid, entry.LimitBy, entry.Email)) 
     1484                result.append((entry.ident, entry.Name, entry.AccountBalance, entry.LifeTimePaid, entry.LimitBy, entry.Email, entry.Description)) 
    14851485            return result  
    14861486         
     
    15001500        entries = [g for g in [self.getGroup(name) for name in self.getAllGroupsNames(gname)] if g.Exists] 
    15011501        if entries : 
    1502             result = [ ("dn", "groupname", "limitby", "balance", "lifetimepaid") ] 
     1502            result = [ ("dn", "groupname", "limitby", "balance", "lifetimepaid", "description") ] 
    15031503            for entry in entries : 
    1504                 result.append((entry.ident, entry.Name, entry.LimitBy, entry.AccountBalance, entry.LifeTimePaid)) 
     1504                result.append((entry.ident, entry.Name, entry.LimitBy, entry.AccountBalance, entry.LifeTimePaid, entry.Description)) 
    15051505            return result  
    15061506         
  • pykota/trunk/pykota/storages/sql.py

    r2718 r2721  
    477477                    user.Email = record.get("email")  
    478478                    user.OverCharge = record.get("overcharge") 
     479                    user.Description = self.databaseToUserCharset(record.get("description")) 
    479480                    user.Exists = 1 
    480481                    userpquota = StorageUserPQuota(self, user, printer)