Changeset 1950


Ignore:
Timestamp:
02/14/17 21:39:12 (7 years ago)
Author:
nanardon
Message:

Cleanup useless code

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Employment.pm

    r1949 r1950  
    343343    my $res = $self->SUPER::set_fields(%data); 
    344344 
    345     $self->applyToUser or return; 
    346     return $res; 
    347 } 
    348  
    349 =head2 applyToUser() 
    350  
    351 Set user's attributes if need from this employement. 
    352  
    353 =cut 
    354  
    355 sub applyToUser { 
    356     my ($self) = @_; 
    357  
    358345    my $user = $self->base->get_object('user', $self->get_attributes('user')) or do { 
    359346        $self->base->log(LA_ERR, "Cannot fetch user %s to apply employment", $self->get_attributes('user')); 
     
    361348    }; 
    362349 
    363     $user->base->log(LA_DEBUG, "Applying Employement %s to user %s", $self->id, $user->id); 
    364  
    365     my $currentemployment = $user->get_attributes('currentEmployment') || ''; 
    366  
    367     if (!$currentemployment) { 
    368         return $user->_resetEmployment 
    369     } elsif ($currentemployment eq $self->id) { 
    370         # No sync to do if this employment is not currently applied 
    371         return $user->applyCurrentEmployment; 
    372     } else { 
    373         return $user->computeEmploymentDate; 
    374     } 
     350    $user->applyCurrentEmployment; 
     351 
     352    return $res; 
    375353} 
    376354 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1949 r1950  
    15301530    my ($self) = @_; 
    15311531 
     1532    # Get current employment name 
    15321533    my $currentempl = $self->get_attributes('currentEmployment') || ''; 
    15331534 
     
    15401541 
    15411542    if (my $currentemployment = $self->base->get_object('employment', $currentempl)) { 
     1543 
     1544        # If an employement apply we set the value to the user object 
     1545 
    15421546        $self->computeEmploymentDate; 
    15431547 
     
    15741578        } 
    15751579    } else { 
     1580        # No current employment, resetting values: 
     1581 
    15761582        return $self->_resetEmployment; 
    15771583    } 
    15781584 
    15791585} 
     1586 
     1587# Reset attribute value set by employment 
     1588# except maangerContact and expire 
    15801589 
    15811590sub _resetEmployment { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Employment.pm

    r1824 r1950  
    6060            my $ouser = $self->{_base}->get_object('user', $user) or next; 
    6161 
    62             my $job = $self->{_base}->get_object('employment', $employment); 
    63             $job->applyToUser; 
     62            $ouser->applyCurrentEmployment; 
    6463            $self->{_base}->commit; 
    6564        } 
Note: See TracChangeset for help on using the changeset viewer.