Show
Ignore:
Timestamp:
02/27/04 10:23:21 (20 years ago)
Author:
jalet
Message:

Minor code reorganisation

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r1354 r1366  
    2424# 
    2525# $Log$ 
     26# Revision 1.70  2004/02/27 09:23:21  jalet 
     27# Minor code reorganisation 
     28# 
    2629# Revision 1.69  2004/02/19 15:05:56  jalet 
    2730# domain names changed to example.com in the doc, according to RFC2606 
     
    574577                            else :     
    575578                                self.logger.log_message(_("Invalid user name %s") % entry.Name) 
     579                elif options["delete"] :                 
     580                    todelete[entry.Name] = entry 
    576581                                 
    577582                if entry.Exists and (not entrypquota.Exists) : 
     
    583588                    self.logger.log_message(_("Quota not found for object %s on printer %s.") % (entry.Name, printer.Name)) 
    584589                else :     
    585                     if options["delete"] : 
    586                         todelete[entry.Name] = entry # will be done for each printer, we don't care. 
    587                     else : 
    588                         if options["noquota"] or options["prototype"] or ((softlimit is not None) and (hardlimit is not None)) : 
    589                             entrypquota.setLimits(softlimit, hardlimit) 
    590                         if limitby : 
    591                             if changed[entry.Name].get("limitby") is None : 
    592                                 entry.setLimitBy(limitby) 
    593                                 changed[entry.Name]["limitby"] = limitby 
    594                          
    595                         if not options["groups"] : 
    596                             if options["reset"] : 
    597                                 entrypquota.reset() 
     590                    if options["noquota"] or options["prototype"] or ((softlimit is not None) and (hardlimit is not None)) : 
     591                        entrypquota.setLimits(softlimit, hardlimit) 
     592                    if limitby : 
     593                        if changed[entry.Name].get("limitby") is None : 
     594                            entry.setLimitBy(limitby) 
     595                            changed[entry.Name]["limitby"] = limitby 
     596                     
     597                    if not options["groups"] : 
     598                        if options["reset"] : 
     599                            entrypquota.reset() 
     600                             
     601                        if balance : 
     602                            if changed[entry.Name].get("balance") is None : 
     603                                if balance.startswith("+") or balance.startswith("-") : 
     604                                    newbalance = float(entry.AccountBalance or 0.0) + balancevalue 
     605                                    newlifetimepaid = float(entry.LifeTimePaid or 0.0) + balancevalue 
     606                                    entry.setAccountBalance(newbalance, newlifetimepaid) 
     607                                else : 
     608                                    diff = balancevalue - float(entry.AccountBalance or 0.0) 
     609                                    newlifetimepaid = float(entry.LifeTimePaid or 0.0) + diff 
     610                                    entry.setAccountBalance(balancevalue, newlifetimepaid) 
     611                                changed[entry.Name]["balance"] = balance 
    598612                                 
    599                             if balance : 
    600                                 if changed[entry.Name].get("balance") is None : 
    601                                     if balance.startswith("+") or balance.startswith("-") : 
    602                                         newbalance = float(entry.AccountBalance or 0.0) + balancevalue 
    603                                         newlifetimepaid = float(entry.LifeTimePaid or 0.0) + balancevalue 
    604                                         entry.setAccountBalance(newbalance, newlifetimepaid) 
    605                                     else : 
    606                                         diff = balancevalue - float(entry.AccountBalance or 0.0) 
    607                                         newlifetimepaid = float(entry.LifeTimePaid or 0.0) + diff 
    608                                         entry.setAccountBalance(balancevalue, newlifetimepaid) 
    609                                     changed[entry.Name]["balance"] = balance 
     613                        for groupname in groupnames :         
     614                            # not executed if option --ingroups is not used 
     615                            if groupname not in changed[entry.Name]["ingroups"] : 
     616                                group = self.storage.getGroup(groupname) 
     617                                if group.Exists : 
     618                                    self.storage.addUserToGroup(entry, group) 
     619                                    changed[entry.Name]["ingroups"].append(groupname) 
     620                                else : 
     621                                    self.logger.log_message(_("Group %s not found in the PyKota Storage.") % groupname) 
    610622                                     
    611                             for groupname in groupnames :         
    612                                 # not executed if option --ingroups is not used 
    613                                 if groupname not in changed[entry.Name]["ingroups"] : 
    614                                     group = self.storage.getGroup(groupname) 
    615                                     if group.Exists : 
    616                                         self.storage.addUserToGroup(entry, group) 
    617                                         changed[entry.Name]["ingroups"].append(groupname) 
    618                                     else : 
    619                                         self.logger.log_message(_("Group %s not found in the PyKota Storage.") % groupname) 
    620                                          
    621                         # This line disabled to prevent sending of unwanted email                  
    622                         # messages if quota is reached at creation/modification time. 
    623                         # The check will be done at print time anyway. 
    624                         # getattr(self, "warn%sPQuota" % suffix)(entrypquota)     
     623                    # This line disabled to prevent sending of unwanted email                  
     624                    # messages if quota is reached at creation/modification time. 
     625                    # The check will be done at print time anyway. 
     626                    # getattr(self, "warn%sPQuota" % suffix)(entrypquota)     
    625627                         
    626628        # Now delete what has to be deleted