- Timestamp:
- 04/17/03 11:26:21 (22 years ago)
- Location:
- pykota/trunk
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/repykota
r927 r929 23 23 # 24 24 # $Log$ 25 # Revision 1.27 2003/04/17 09:26:21 jalet 26 # repykota now reports account balances too. 27 # 25 28 # Revision 1.26 2003/04/16 12:35:49 jalet 26 29 # Groups quota work now ! … … 177 180 print _("Pages grace time: %idays") % self.config.getGraceDelay(printer) 178 181 total = 0 182 totalmoney = 0.0 179 183 if options["groups"] : 180 print _("Group used soft hard grace total")181 print "------------------------------------------------------------ "184 print _("Group used soft hard balance grace total paid") 185 print "------------------------------------------------------------------------------" 182 186 for (ident, name) in self.storage.getPrinterGroups(printerid) : 183 187 quota = self.storage.getGroupPQuota(ident, printerid) 184 total += self.printQuota(name, quota) 188 balance = self.storage.getGroupBalance(ident) 189 limitby = self.storage.getGroupLimitBy(ident) 190 (pages, money) = self.printQuota(name, quota, balance, limitby) 191 total += pages 192 totalmoney += money 185 193 else : 186 194 # default is user quota report 187 print _("User used soft hard grace total")188 print "------------------------------------------------------------ "195 print _("User used soft hard balance grace total paid") 196 print "------------------------------------------------------------------------------" 189 197 for (ident, name) in self.storage.getPrinterUsers(printerid) : 190 198 quota = self.storage.getUserPQuota(ident, printerid) 191 total += self.printQuota(name, quota) 192 if total : 193 print (" " * 43) + (_("Total : %9i") % total) 199 balance = self.storage.getUserBalance(ident) 200 limitby = self.storage.getUserLimitBy(ident) 201 (pages, money) = self.printQuota(name, quota, balance, limitby) 202 total += pages 203 totalmoney += money 204 if total or totalmoney : 205 print (" " * 50) + (_("Total : %9i") % total) + (" %-12.12s" % ("%7.2f" % totalmoney)[:12]) 194 206 printerpagecounter = self.storage.getPrinterPageCounter(printerid) 195 207 try : … … 197 209 except TypeError : 198 210 msg = _("unknown") 199 print (" " * 44) + (_("Real : %s") % msg)211 print (" " * 51) + (_("Real : %s") % msg) 200 212 print 213 if options["groups"] : 214 print _("Totals may be inaccurate if some users are members of several groups.") 201 215 202 def printQuota(self, name, quota ) :216 def printQuota(self, name, quota, balance, limitby) : 203 217 """Prints the quota information.""" 204 218 if quota is not None : … … 208 222 hardlimit = quota["hardlimit"] 209 223 datelimit = quota["datelimit"] 224 if balance is not None : 225 (balance, lifetimepaid) = balance 226 else : 227 (balance, lifetimepaid) = 0.0 210 228 if datelimit is not None : 211 229 now = DateTime.now() … … 215 233 else : 216 234 datelimit = "" 217 reached = ((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-" 218 print "%-10.10s %c %8i %8s %8s %10s %9i" % (name, reached, pagecounter, str(softlimit), str(hardlimit), str(datelimit)[:10], lifepagecounter) 219 return lifepagecounter 235 if limitby == "balance" : 236 reached = (((balance <= 0) and "+") or "-") + "B" 237 else : 238 reached = (((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-") + "Q" 239 strbalance = ("%5.2f" % balance)[:10] 240 strlifetimepaid = ("%6.2f" % lifetimepaid)[:11] 241 print "%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %-11.11s" % (name, reached, pagecounter, str(softlimit), str(hardlimit), strbalance, str(datelimit)[:10], lifepagecounter, strlifetimepaid) 242 return (lifepagecounter, lifetimepaid) 220 243 221 244 -
pykota/trunk/NEWS
r927 r929 22 22 PyKota NEWS : 23 23 24 - 1.03beta2 : 25 26 - repykota now reports account balances too. 27 24 28 - 1.03beta : 25 29 -
pykota/trunk/po/en/pykota.po
r927 r929 21 21 # 22 22 # $Log$ 23 # Revision 1.19 2003/04/17 09:26:21 jalet 24 # repykota now reports account balances too. 25 # 23 26 # Revision 1.18 2003/04/16 12:35:49 jalet 24 27 # Groups quota work now ! … … 145 148 msgstr "" 146 149 147 msgid "Group used soft hard grace total"150 msgid "Group used soft hard balance grace total paid" 148 151 msgstr "" 149 152 … … 160 163 msgstr "" 161 164 162 msgid "User used soft hard grace total"165 msgid "User used soft hard balance grace total paid" 163 166 msgstr "" 164 167 … … 304 307 "your group Print Quota is almost reached on printer %s." 305 308 msgstr "" 309 310 msgid "Totals may be inaccurate if some users are members of several groups." 311 msgstr "" -
pykota/trunk/po/fr/pykota.po
r927 r929 21 21 # 22 22 # $Log$ 23 # Revision 1.17 2003/04/17 09:26:21 jalet 24 # repykota now reports account balances too. 25 # 23 26 # Revision 1.16 2003/04/16 12:35:49 jalet 24 27 # Groups quota work now ! … … 146 149 msgstr "Valeur %s invalide pour la limite dure." 147 150 148 msgid "Group used soft hard grace total" 149 msgstr "Groupe used soft hard grace total" 150 151 msgid "Group used soft hard balance grace total paid" 152 msgstr "Groupe util soft hard solde gr� total pay� 151 153 msgid "There's no printer matching %s" 152 154 msgstr "Aucune imprimante ne correspond �s" … … 161 163 msgstr "Nom de groupe %s invalide" 162 164 163 msgid "User used soft hard grace total" 164 msgstr "Utilisateur used soft hard grace total" 165 165 msgid "User used soft hard balance grace total paid" 166 msgstr "Utilisateur util soft hard solde gr� total pay� 166 167 msgid "Invalid printer name %s" 167 168 msgstr "Nom d'imprimante %s invalide" … … 316 317 "Vous n'aurez bient�lus le droit d'imprimer car\n" 317 318 "le Quota d'Impression de votre groupe sur l'imprimante %s est presque atteint." 319 320 msgid "Totals may be inaccurate if some users are members of several groups." 321 msgstr "Les totaux peuvent �e faux si des utilisateurs sont dans plusieurs groupes." -
pykota/trunk/po/pykota.pot
r927 r929 21 21 # 22 22 # $Log$ 23 # Revision 1.19 2003/04/17 09:26:21 jalet 24 # repykota now reports account balances too. 25 # 23 26 # Revision 1.18 2003/04/16 12:35:49 jalet 24 27 # Groups quota work now ! … … 145 148 msgstr "" 146 149 147 msgid "Group used soft hard grace total"150 msgid "Group used soft hard balance grace total paid" 148 151 msgstr "" 149 152 … … 160 163 msgstr "" 161 164 162 msgid "User used soft hard grace total"165 msgid "User used soft hard balance grace total paid" 163 166 msgstr "" 164 167 … … 304 307 "your group Print Quota is almost reached on printer %s." 305 308 msgstr "" 309 310 msgid "Totals may be inaccurate if some users are members of several groups." 311 msgstr "" -
pykota/trunk/pykota/storages/sql.py
r927 r929 21 21 # 22 22 # $Log$ 23 # Revision 1.28 2003/04/17 09:26:21 jalet 24 # repykota now reports account balances too. 25 # 23 26 # Revision 1.27 2003/04/16 12:35:49 jalet 24 27 # Groups quota work now ! … … 254 257 def getUserBalance(self, userid) : 255 258 """Returns the current account balance for a given user.""" 256 result = self.doQuery("SELECT balance FROM users WHERE id=%s" % self.doQuote(userid)) 257 try : 258 return self.doParseResult(result)[0]["balance"] 259 except TypeError : # Not found 260 return 259 result = self.doQuery("SELECT balance, lifetimepaid FROM users WHERE id=%s" % self.doQuote(userid)) 260 try : 261 result = self.doParseResult(result)[0] 262 except TypeError : # Not found 263 return 264 else : 265 return (result["balance"], result["lifetimepaid"]) 261 266 262 267 def getGroupBalance(self, groupid) : 263 268 """Returns the current account balance for a given group, as the sum of each of its users' account balance.""" 264 result = self.doQuery("SELECT SUM(balance) AS balance FROM users WHERE id in (SELECT userid FROM groupsmembers WHERE groupid=%s)" % self.doQuote(groupid)) 265 try : 266 return self.doParseResult(result)[0]["balance"] 267 except TypeError : # Not found 268 return 269 result = self.doQuery("SELECT SUM(balance) AS balance, SUM(lifetimepaid) AS lifetimepaid FROM users WHERE id in (SELECT userid FROM groupsmembers WHERE groupid=%s)" % self.doQuote(groupid)) 270 try : 271 result = self.doParseResult(result)[0] 272 except TypeError : # Not found 273 return 274 else : 275 return (result["balance"], result["lifetimepaid"]) 269 276 270 277 def getUserLimitBy(self, userid) : … … 286 293 def setUserBalance(self, userid, balance) : 287 294 """Sets the account balance for a given user to a fixed value.""" 288 current= self.getUserBalance(userid)295 (current, lifetimepaid) = self.getUserBalance(userid) 289 296 difference = balance - current 290 297 self.increaseUserBalance(userid, difference) -
pykota/trunk/pykota/tool.py
r927 r929 21 21 # 22 22 # $Log$ 23 # Revision 1.34 2003/04/17 09:26:21 jalet 24 # repykota now reports account balances too. 25 # 23 26 # Revision 1.33 2003/04/16 12:35:49 jalet 24 27 # Groups quota work now ! … … 306 309 else : 307 310 # TODO : there's no warning (no account balance soft limit) 311 (balance, lifetimepaid) = balance 308 312 if balance <= 0.0 : 309 313 action = "DENY" … … 381 385 else : 382 386 # TODO : there's no warning (no account balance soft limit) 387 (balance, lifetimepaid) = balance 383 388 if balance <= 0.0 : 384 389 action = "DENY" -
pykota/trunk/pykota/version.py
r927 r929 21 21 # 22 22 23 __version__ = "1.03beta -unofficial"23 __version__ = "1.03beta2-unofficial" 24 24 25 25 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS."""