Show
Ignore:
Timestamp:
02/17/06 23:51:17 (18 years ago)
Author:
jerome
Message:

pkusers now mostly works. Removing an user from a group with
LDAP is not yet done though. Also no test was done with
LDAP yet.
filldb now really creates users (it uses pkusers instead
of edpykota)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkusers

    r2705 r2706  
    297297                    usersgroups = [] 
    298298                         
    299                 if options["description"] : 
     299                description = options["description"] 
     300                if description : 
    300301                    description = options["description"].strip() 
     302                     
     303                comment = options["comment"] 
     304                if comment : 
     305                    comment = options["comment"].strip() 
    301306                     
    302307                nbtotal = len(entries) 
    303308                for i in range(nbtotal) :         
    304309                    entry = entries[i] 
    305                     if description is not None :        # NB : "" is allowed ! 
     310                    if description is not None : # NB : "" is allowed ! 
    306311                        entry.setDescription(description) 
     312                    if limitby :     
     313                        entry.setLimitBy(limitby) 
     314                         
     315                    if suffix == "User" :     
     316                        if overcharge is not None : # NB : 0 is allowed !      
     317                            entry.setOverChargeFactor(overcharge) 
     318                             
    307319                    entry.save()     
    308                     if not options["groups"] : 
     320                     
     321                    if suffix == "User" : 
     322                        if balance : 
     323                            if balance.startswith("+") or balance.startswith("-") : 
     324                                newbalance = float(entry.AccountBalance or 0.0) + balancevalue 
     325                                newlifetimepaid = float(entry.LifeTimePaid or 0.0) + balancevalue 
     326                                entry.setAccountBalance(newbalance, newlifetimepaid, comment) 
     327                            else : 
     328                                diff = balancevalue - float(entry.AccountBalance or 0.0) 
     329                                newlifetimepaid = float(entry.LifeTimePaid or 0.0) + diff 
     330                                entry.setAccountBalance(balancevalue, newlifetimepaid, comment) 
     331                                         
    309332                        for ugroup in usersgroups : 
    310333                            if options["remove"] : 
     
    312335                            else : 
    313336                                ugroup.addUserToGroup(entry) 
     337                                 
    314338                    percent = 100.0 * float(i) / float(nbtotal) 
    315339                    self.display("\r%.02f%%" % percent)