Changeset 925
- Timestamp:
- 04/16/03 10:53:14 (22 years ago)
- Location:
- pykota/trunk
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r919 r925 68 68 See http://web.mit.edu/source/third/lprng/doc/LPRng-HOWTO-15.html 69 69 For a more accurate accounting, never switch your HP printers 70 off. 70 off. This is untested, please report any problem. 71 71 72 72 - A bug was fixed when edpykota --add was used with users who already … … 80 80 - Support for AppleTalk printers was added, see sample configuration 81 81 file for details. 82 83 - Users and group printing can now be controlled (limited) either by 84 print quota or by account balance. 82 85 83 86 - 1.02 : -
pykota/trunk/po/en/pykota.po
r924 r925 21 21 # 22 22 # $Log$ 23 # Revision 1.17 2003/04/16 08:53:14 jalet 24 # Printing can now be limited either by user's account balance or by 25 # page quota (the default). Quota report doesn't include account balance 26 # yet, though. 27 # 23 28 # Revision 1.16 2003/04/16 08:22:09 jalet 24 29 # More strict error detection. … … 271 276 msgid "Invalid limitby value %s" 272 277 msgstr "" 278 279 msgid "Unable to find user %s's account balance, applying default policy (%s) for printer %s" 280 msgstr "" -
pykota/trunk/po/fr/pykota.po
r924 r925 21 21 # 22 22 # $Log$ 23 # Revision 1.15 2003/04/16 08:53:14 jalet 24 # Printing can now be limited either by user's account balance or by 25 # page quota (the default). Quota report doesn't include account balance 26 # yet, though. 27 # 23 28 # Revision 1.14 2003/04/16 08:22:10 jalet 24 29 # More strict error detection. … … 279 284 msgid "Invalid limitby value %s" 280 285 msgstr "Valeur de l'option limitby %s invalide" 286 287 msgid "Unable to find user %s's account balance, applying default policy (%s) for printer %s" 288 msgstr "Impossible de trouver le solde du compte de l'utilisateur %s, action par d�ut (%s) appliqu�sur l'imprimante %s" -
pykota/trunk/po/pykota.pot
r924 r925 21 21 # 22 22 # $Log$ 23 # Revision 1.17 2003/04/16 08:53:14 jalet 24 # Printing can now be limited either by user's account balance or by 25 # page quota (the default). Quota report doesn't include account balance 26 # yet, though. 27 # 23 28 # Revision 1.16 2003/04/16 08:22:09 jalet 24 29 # More strict error detection. … … 271 276 msgid "Invalid limitby value %s" 272 277 msgstr "" 278 279 msgid "Unable to find user %s's account balance, applying default policy (%s) for printer %s" 280 msgstr "" -
pykota/trunk/pykota/storages/sql.py
r921 r925 21 21 # 22 22 # $Log$ 23 # Revision 1.26 2003/04/16 08:53:14 jalet 24 # Printing can now be limited either by user's account balance or by 25 # page quota (the default). Quota report doesn't include account balance 26 # yet, though. 27 # 23 28 # Revision 1.25 2003/04/15 21:58:33 jalet 24 29 # edpykota now accepts a --delete option. … … 234 239 return 235 240 241 def getUserLimitBy(self, userid) : 242 """Returns the way in which user printing is limited.""" 243 result = self.doQuery("SELECT limitby FROM users WHERE id=%s" % self.doQuote(userid)) 244 try : 245 return self.doParseResult(result)[0]["limitby"] 246 except TypeError : # Not found 247 return 248 249 def getGroupLimitBy(self, groupid) : 250 """Returns the way in which group printing is limited.""" 251 result = self.doQuery("SELECT limitby FROM groups WHERE id=%s" % self.doQuote(groupid)) 252 try : 253 return self.doParseResult(result)[0]["limitby"] 254 except TypeError : # Not found 255 return 256 236 257 def setUserBalance(self, userid, balance) : 237 258 """Sets the account balance for a given user to a fixed value.""" -
pykota/trunk/pykota/tool.py
r915 r925 21 21 # 22 22 # $Log$ 23 # Revision 1.32 2003/04/16 08:53:14 jalet 24 # Printing can now be limited either by user's account balance or by 25 # page quota (the default). Quota report doesn't include account balance 26 # yet, though. 27 # 23 28 # Revision 1.31 2003/04/15 11:30:57 jalet 24 29 # More work done on money print charging. … … 286 291 printerid = self.storage.getPrinterId(printername) 287 292 userid = self.storage.getUserId(username) 288 quota = self.storage.getUserPQuota(userid, printerid) 289 if quota is None : 290 # Unknown user or printer or combination 291 policy = self.config.getPrinterPolicy(printername) 292 if policy in [None, "ALLOW"] : 293 action = "POLICY_ALLOW" 293 limitby = self.storage.getUserLimitBy(userid) 294 if limitby == "balance" : 295 balance = self.storage.getUserBalance(userid) 296 if balance is None : 297 policy = self.config.getPrinterPolicy(printername) 298 if policy in [None, "ALLOW"] : 299 action = "POLICY_ALLOW" 300 else : 301 action = "POLICY_DENY" 302 self.logger.log_message(_("Unable to find user %s's account balance, applying default policy (%s) for printer %s") % (username, action, printername)) 294 303 else : 295 action = "POLICY_DENY" 296 self.logger.log_message(_("Unable to match user %s on printer %s, applying default policy (%s)") % (username, printername, action)) 297 else : 298 pagecounter = quota["pagecounter"] 299 softlimit = quota["softlimit"] 300 hardlimit = quota["hardlimit"] 301 datelimit = quota["datelimit"] 302 if softlimit is not None : 303 if pagecounter < softlimit : 304 # TODO : there's no warning (no account balance soft limit) 305 if balance <= 0.0 : 306 action = "DENY" 307 else : 304 308 action = "ALLOW" 309 else : 310 quota = self.storage.getUserPQuota(userid, printerid) 311 if quota is None : 312 # Unknown user or printer or combination 313 policy = self.config.getPrinterPolicy(printername) 314 if policy in [None, "ALLOW"] : 315 action = "POLICY_ALLOW" 305 316 else : 306 if hardlimit is None : 307 # only a soft limit, this is equivalent to having only a hard limit 308 action = "DENY" 317 action = "POLICY_DENY" 318 self.logger.log_message(_("Unable to match user %s on printer %s, applying default policy (%s)") % (username, printername, action)) 319 else : 320 pagecounter = quota["pagecounter"] 321 softlimit = quota["softlimit"] 322 hardlimit = quota["hardlimit"] 323 datelimit = quota["datelimit"] 324 if softlimit is not None : 325 if pagecounter < softlimit : 326 action = "ALLOW" 309 327 else : 310 if softlimit <= pagecounter < hardlimit : 311 now = DateTime.now() 312 if datelimit is not None : 313 datelimit = DateTime.ISO.ParseDateTime(datelimit) 314 else : 315 datelimit = now + self.config.getGraceDelay(printername) 316 self.storage.setUserDateLimit(userid, printerid, datelimit) 317 if now < datelimit : 318 action = "WARN" 319 else : 328 if hardlimit is None : 329 # only a soft limit, this is equivalent to having only a hard limit 330 action = "DENY" 331 else : 332 if softlimit <= pagecounter < hardlimit : 333 now = DateTime.now() 334 if datelimit is not None : 335 datelimit = DateTime.ISO.ParseDateTime(datelimit) 336 else : 337 datelimit = now + self.config.getGraceDelay(printername) 338 self.storage.setUserDateLimit(userid, printerid, datelimit) 339 if now < datelimit : 340 action = "WARN" 341 else : 342 action = "DENY" 343 else : 320 344 action = "DENY" 321 else : 345 else : 346 if hardlimit is not None : 347 # no soft limit, only a hard one. 348 if pagecounter < hardlimit : 349 action = "ALLOW" 350 else : 322 351 action = "DENY" 323 else : 324 if hardlimit is not None : 325 # no soft limit, only a hard one. 326 if pagecounter < hardlimit : 352 else : 353 # Both are unset, no quota, i.e. accounting only 327 354 action = "ALLOW" 328 else :329 action = "DENY"330 else :331 # Both are unset, no quota, i.e. accounting only332 action = "ALLOW"333 355 return action 334 356 -
pykota/trunk/README
r920 r925 68 68 - Complete job history is saved. This will allow more 69 69 complex reports in the future. 70 71 - Price per page and price per job can be defined for 72 every printers. A job's price is the sum of the 73 price per job for this printer plus the number of 74 pages multiplied by the price per page for this 75 printer. 76 77 - User's account balance and lifetime paid money are now 78 stored in the Quota Storage, and account balance can be 79 used to limit the user printing instead of a print quota. 80 Actually you can limit either by account balance OR by 81 print quota, but maybe both should be checked at the 82 same time. Tell me what you prefer. 70 83 71 84 All the command line tools accept the -h | --help command line option