[Bps-public-commit] rt-extension-rest2 branch, update-custom-roles-on-correspond-and-comment, repushed

Dianne Skoll dianne at bestpractical.com
Tue Jan 12 10:14:17 EST 2021


The branch update-custom-roles-on-correspond-and-comment was deleted and repushed:
       was e4f441c0b819e065034f71c3065cc0b62919d38c
       now 4d92af9c7c29e684cb8ce7ff2cb970cdd649011d

1:  6dac39c = 1:  6dac39c Move _update_role_members out of RT::Extension::REST2::Resource::Record::Writable and into RT::Extension::REST2::Util
4:  797eef9 ! 2:  8c7fc47 Move _fix_custom_role_ids out of ... Resource::Message.pm into ... Util.pm
    @@ -11,41 +11,22 @@
      use MIME::Base64;
      
      extends 'RT::Extension::REST2::Resource';
    --use RT::Extension::REST2::Util qw( error_as_json update_custom_fields update_role_members);
    -+use RT::Extension::REST2::Util qw( error_as_json update_custom_fields update_role_members fix_custom_role_ids);
    ++
    + use RT::Extension::REST2::Util qw( error_as_json update_custom_fields );
      
      sub dispatch_rules {
    -     Path::Dispatcher::Rule::Regex->new(
     @@
      
    -     # update_role_members wants custom role IDs (like RT::CustomRole-ID)
    -     # rather than role names.
    --    my $renamed_custom_roles = $self->_fix_custom_role_ids($args{CustomRoles});
    +     push @results, $msg;
    +     push @results, update_custom_fields($self->record, $args{CustomFields});
    +-    push @results, $self->_update_txn_custom_fields( $TransObj, $args{TxnCustomFields} || $args{TransactionCustomFields} );
    ++    # update_role_members wants custom role IDs (like RT::CustomRole-ID)
    ++    # rather than role names.
     +    my $renamed_custom_roles = fix_custom_role_ids($self->record, $args{CustomRoles});
    -     push @results, update_role_members($self->record, $renamed_custom_roles);
    -     push @results, $self->_update_txn_custom_fields( $TransObj, $args{TxnCustomFields} || $args{TransactionCustomFields} );
    ++    push @results, update_role_members($self->record, $renamed_custom_roles);
      
    -@@
    -     return 1;
    - }
    - 
    --sub _fix_custom_role_ids
    --{
    --    my ($self, $custom_roles) = @_;
    --    my $ret = {};
    --    return $ret unless $custom_roles;
    --
    --    foreach my $key (keys(%$custom_roles)) {
    --        my $cr = RT::CustomRole->new($self->record->CurrentUser);
    --        next unless $cr->Load($key);
    --        $ret->{'RT::CustomRole-' . $cr->Id} = $custom_roles->{$key};
    --    }
    --    return $ret;
    --}
    --
    - sub _update_txn_custom_fields {
    -     my $self = shift;
    -     my $TransObj = shift;
    +     # Set ticket status if we were passed a "Status":"foo" argument
    +     if ($args{Status}) {
     
     diff --git a/lib/RT/Extension/REST2/Util.pm b/lib/RT/Extension/REST2/Util.pm
     --- a/lib/RT/Extension/REST2/Util.pm
2:  0538d5d ! 3:  f6b8073 Allow updating of custom roles on ticket comment/correspond.
    @@ -32,6 +32,7 @@
      use MIME::Base64;
      
      extends 'RT::Extension::REST2::Resource';
    +-
     -use RT::Extension::REST2::Util qw( error_as_json update_custom_fields );
     +use RT::Extension::REST2::Util qw( error_as_json update_custom_fields update_role_members);
      
    @@ -42,13 +43,15 @@
          push @results, $msg;
          push @results, update_custom_fields($self->record, $args{CustomFields});
     +
    -+    # update_role_members wants custom role IDs (like RT::CustomRole-ID)
    -+    # rather than role names.
    +     # update_role_members wants custom role IDs (like RT::CustomRole-ID)
    +     # rather than role names.
    +-    my $renamed_custom_roles = fix_custom_role_ids($self->record, $args{CustomRoles});
     +    my $renamed_custom_roles = $self->_fix_custom_role_ids($args{CustomRoles});
    -+    push @results, update_role_members($self->record, $renamed_custom_roles);
    -     push @results, $self->_update_txn_custom_fields( $TransObj, $args{TxnCustomFields} || $args{TransactionCustomFields} );
    +     push @results, update_role_members($self->record, $renamed_custom_roles);
    ++    push @results, $self->_update_txn_custom_fields( $TransObj, $args{TxnCustomFields} || $args{TransactionCustomFields} );
      
          # Set ticket status if we were passed a "Status":"foo" argument
    +     if ($args{Status}) {
     @@
          return 1;
      }
6:  e4f441c ! 4:  8a3cc6f Update documentation: Document CustomFields and TxnCustomFields; note that CustomRoles can take user names as well as email addresses.
    @@ -35,3 +35,4 @@
      
      =back
      
    +
3:  f8a81a0 = 5:  1bd31c1 Add unit test for updating custom roles on ticket comment/correspond.
5:  ace50de ! 6:  4d92af9 Update tests to verify that we can change a custom role by username as well as email address.
    @@ -40,4 +40,3 @@
      }
      
      done_testing;
    -



More information about the Bps-public-commit mailing list