[Rt-commit] rt branch, admin_ui, updated. 8cc1b04cdbaa14c7856051b560da9f3b1b106c58

Jesse Vincent jesse at bestpractical.com
Mon Dec 28 10:59:22 EST 2009


I'd probably put helpers that are specific to showing a admin stuff in
their own packages



On Sun 27.Dec'09 at 22:49:12 -0500, sunnavy at bestpractical.com wrote:
> The branch, admin_ui has been updated
>        via  8cc1b04cdbaa14c7856051b560da9f3b1b106c58 (commit)
>       from  6921c5e0266bfd7f4c471c4a5fbbd963f23048e0 (commit)
> 
> Summary of changes:
>  lib/RT/View/Admin/Users.pm |   55 +--------------------------------------
>  lib/RT/View/Helpers.pm     |   60 +++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 61 insertions(+), 54 deletions(-)
> 
> - Log -----------------------------------------------------------------
> commit 8cc1b04cdbaa14c7856051b560da9f3b1b106c58
> Author: sunnavy <sunnavy at bestpractical.com>
> Date:   Mon Dec 28 11:48:17 2009 +0800
> 
>     abstract show_key_info stuff
> 
> diff --git a/lib/RT/View/Admin/Users.pm b/lib/RT/View/Admin/Users.pm
> index 8bd9be1..ed0c698 100644
> --- a/lib/RT/View/Admin/Users.pm
> +++ b/lib/RT/View/Admin/Users.pm
> @@ -50,6 +50,7 @@ use strict;
>  
>  package RT::View::Admin::Users;
>  use Jifty::View::Declare -base;
> +use RT::View::Helpers qw/show_key_info/;
>  use base 'RT::View::CRUD';
>  
>  use constant page_title      => 'User Management';
> @@ -140,59 +141,7 @@ template 'gnupg' => page { title => _('User GnuPG') } content {
>          return;
>      }
>  
> -    my %res = RT::Crypt::GnuPG::get_key_info( $user->email, 'public' );
> -
> -    if ( $res{'exit_code'} || !keys %{ $res{'info'} } ) {
> -        outs( _('No keys for this address') );
> -    }
> -    else {
> -        h3 { _('GnuPG public key for %1', $user->email) };
> -        table {
> -            row {
> -                th { _( 'Trust' . ':' ) };
> -                cell {
> -                    _( $res{'info'}{'trust'} );
> -                };
> -            };
> -            row {
> -                th { _( 'Created' . ':' ) };
> -                cell {
> -                    $res{'info'}{'created'}
> -                      ? $res{'info'}{'created'}->date
> -                      : _('never');
> -                };
> -            };
> -
> -            row {
> -                th { _('Expire') . ':' };
> -                cell {
> -                    $res{'info'}{'expire'}
> -                      ? $res{'info'}{'expire'}->date
> -                      : _('never');
> -                };
> -            };
> -
> -            for my $uinfo ( @{ $res{'info'}{'user'} } ) {
> -                row {
> -                    th { _('User (Created - expire)') . ':' };
> -                    cell {
> -                        $uinfo->{'string'}
> -                          . '(' . (
> -                            $uinfo->{'created'} ? $uinfo->{'created'}->date
> -                            : _('never') . ' - ' 
> -                          )
> -                          . (
> -                            $uinfo->{'expire'} ? $uinfo->{'expire'}->date
> -                            : _('never')
> -                          ) . ')';
> -                    };
> -                };
> -            }
> -        };
> -    }
> -
> -    my %keys_meta =
> -      RT::Crypt::GnuPG::get_keys_for_signing( $user->email, 'force' );
> +    show_key_info( $user->email, 'public' );
>  
>      my $moniker = 'select_private_key';
>      my $action = new_action(
> diff --git a/lib/RT/View/Helpers.pm b/lib/RT/View/Helpers.pm
> index 28e53f3..da3c23d 100644
> --- a/lib/RT/View/Helpers.pm
> +++ b/lib/RT/View/Helpers.pm
> @@ -49,9 +49,12 @@ use warnings;
>  use strict;
>  
>  package RT::View::Helpers;
> +use Jifty::View::Declare -base;
> +
>  use base qw/Exporter/;
>  our @EXPORT    = ();
> -our @EXPORT_OK = qw(render_user render_user_concise render_user_verbose);
> +our @EXPORT_OK = qw(render_user render_user_concise render_user_verbose
> +        show_key_info );
>  
>  sub render_user {
>      my $user = shift;
> @@ -114,5 +117,60 @@ sub render_user_verbose {
>      return $address->format;
>  }
>  
> +sub show_key_info {
> +    my $email = shift;
> +    my $type = shift || 'public';
> +    my %res = RT::Crypt::GnuPG::get_key_info( $email, $type );
> +
> +    if ( $res{'exit_code'} || !keys %{ $res{'info'} } ) {
> +        outs( _('No keys for this address') );
> +    }
> +    else {
> +        h3 { _('GnuPG public key for %1', $email) };
> +        table {
> +            row {
> +                th { _( 'Trust' . ':' ) };
> +                cell {
> +                    _( $res{'info'}{'trust'} );
> +                };
> +            };
> +            row {
> +                th { _( 'Created' . ':' ) };
> +                cell {
> +                    $res{'info'}{'created'}
> +                      ? $res{'info'}{'created'}->date
> +                      : _('never');
> +                };
> +            };
> +
> +            row {
> +                th { _('Expire') . ':' };
> +                cell {
> +                    $res{'info'}{'expire'}
> +                      ? $res{'info'}{'expire'}->date
> +                      : _('never');
> +                };
> +            };
> +
> +            for my $uinfo ( @{ $res{'info'}{'user'} } ) {
> +                row {
> +                    th { _('User (Created - expire)') . ':' };
> +                    cell {
> +                        $uinfo->{'string'}
> +                          . '(' . (
> +                            $uinfo->{'created'} ? $uinfo->{'created'}->date
> +                            : _('never') . ' - ' 
> +                          )
> +                          . (
> +                            $uinfo->{'expire'} ? $uinfo->{'expire'}->date
> +                            : _('never')
> +                          ) . ')';
> +                    };
> +                };
> +            }
> +        };
> +    }
> +}
> +
>  1;
>  
> 
> -----------------------------------------------------------------------
> _______________________________________________
> Rt-commit mailing list
> Rt-commit at lists.bestpractical.com
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.bestpractical.com/pipermail/rt-commit/attachments/20091228/4309d870/attachment.pgp 


More information about the Rt-commit mailing list