Ignore:
Timestamp:
01/30/16 13:06:47 (8 years ago)
Author:
nanardon
Message:

Redirect / to user's page

Location:
trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/About.pm

    r870 r1692  
    33use warnings; 
    44use base 'Catalyst::Controller'; 
     5 
     6use POSIX; 
     7use DateTime; 
     8use Date::Calc; 
     9use Date::Parse; 
    510 
    611=head1 NAME 
     
    2530 
    2631    $c->stash->{page}{title} = "A propos..."; 
     32 
     33    if ($c->user) { 
     34        my $ouser = $c->model('Accounts')->db->get_object( 
     35            'user', 
     36            $c->user->{username}, 
     37        ); 
     38 
     39        my @cd = split('-', DateTime->from_epoch( 
     40            epoch => str2time( 
     41                $ouser->get_attributes('create'), 
     42            ) 
     43        )->ymd('-')); 
     44        my @now = split('-', DateTime->now()->ymd('-')); 
     45 
     46        my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@cd, @now); 
     47        $c->stash->{accountExists} = join(', ', 
     48            ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
     49            ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
     50            ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
     51        ); 
     52 
     53        if (my $expire = $ouser->get_attributes('expire')) { 
     54            my @ed = split('-', DateTime->from_epoch( 
     55                epoch => str2time( 
     56                    $expire 
     57                ) 
     58            )->ymd('-')); 
     59 
     60            my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@now, @ed); 
     61            $c->stash->{accountExpire} = join(', ', 
     62                ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
     63                ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
     64                ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
     65            ); 
     66        } 
     67    } 
    2768} 
    2869 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Root.pm

    r1690 r1692  
    7474 
    7575    if ($c->user) { 
    76         my $ouser = $c->model('Accounts')->db->get_object( 
    77             'user', 
    78             $c->user->{username}, 
    79         ); 
    80  
    81         my @cd = split('-', DateTime->from_epoch( 
    82             epoch => str2time( 
    83                 $ouser->get_attributes('create'), 
    84             ) 
    85         )->ymd('-')); 
    86         my @now = split('-', DateTime->now()->ymd('-')); 
    87  
    88         my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@cd, @now); 
    89         $c->stash->{accountExists} = join(', ', 
    90             ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
    91             ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
    92             ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
    93         ); 
    94  
    95         if (my $expire = $ouser->get_attributes('expire')) { 
    96             my @ed = split('-', DateTime->from_epoch( 
    97                 epoch => str2time( 
    98                     $expire 
    99                 ) 
    100             )->ymd('-')); 
    101  
    102             my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@now, @ed); 
    103             $c->stash->{accountExpire} = join(', ', 
    104                 ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
    105                 ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
    106                 ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
    107             ); 
    108         } 
     76        $c->res->redirect( 
     77            $c->uri_for('/users', $c->user->{username}) 
     78        ) 
    10979    } 
    11080} 
Note: See TracChangeset for help on using the changeset viewer.