[Rt-commit] r13212 - in rt/branches/3.8-TESTING: lib/RT/Interface share/html/REST/1.0/Forms/ticket
sartak at bestpractical.com
sartak at bestpractical.com
Thu Jun 12 13:10:58 EDT 2008
Author: sartak
Date: Thu Jun 12 13:10:56 2008
New Revision: 13212
Modified:
rt/branches/3.8-TESTING/ (props changed)
rt/branches/3.8-TESTING/lib/RT/Interface/REST.pm
rt/branches/3.8-TESTING/share/html/REST/1.0/Forms/ticket/default
Log:
r62272 at onn: sartak | 2008-06-12 13:07:02 -0400
Have the REST interface parse CF.{Foo} correctly
Modified: rt/branches/3.8-TESTING/lib/RT/Interface/REST.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Interface/REST.pm (original)
+++ rt/branches/3.8-TESTING/lib/RT/Interface/REST.pm Thu Jun 12 13:10:56 2008
@@ -63,7 +63,31 @@
@EXPORT = qw(expand_list form_parse form_compose vpush vsplit);
}
-sub field_spec { '(?i:[a-z][a-z0-9_-]*|C(?:ustom)?F(?:ield)?-(?:[a-z0-9_ :()/-]|\s)+)' }
+sub custom_field_spec {
+ my $self = shift;
+ my $capture = shift;
+
+ my $CF_char = '[\sa-z0-9_ :()/-]';
+ my $CF_name = $CF_char . '+';
+ $CF_name = '(' . $CF_name . ')' if $capture;
+
+ my $new_style = 'CF\.\{'.$CF_name.'\}';
+ my $old_style = 'C(?:ustom)?F(?:ield)?-'.$CF_name;
+
+ return '(?i:' . join('|', $new_style, $old_style) . ')';
+}
+
+sub field_spec {
+ my $self = shift;
+ my $capture = shift;
+
+ my $field = '[a-z][a-z0-9_-]*';
+ $field = '(' . $field . ')' if $capture;
+
+ my $custom_field = __PACKAGE__->custom_field_spec($capture);
+
+ return '(?i:' . join('|', $field, $custom_field) . ')';
+}
# WARN: this code is duplicated in bin/rt.in,
# change both functions at once
Modified: rt/branches/3.8-TESTING/share/html/REST/1.0/Forms/ticket/default
==============================================================================
--- rt/branches/3.8-TESTING/share/html/REST/1.0/Forms/ticket/default (original)
+++ rt/branches/3.8-TESTING/share/html/REST/1.0/Forms/ticket/default Thu Jun 12 13:10:56 2008
@@ -55,6 +55,9 @@
</%ARGS>
<%INIT>
use MIME::Entity;
+use RT::Interface::REST;
+
+my $cf_spec = RT::Interface::REST->custom_field_spec(1);
my @comments;
my ($c, $o, $k, $e) = ("", [], {}, 0);
@@ -138,10 +141,9 @@
$v{$create{lc $k}} = delete $data{$k};
}
# Set custom field
- elsif ($k =~ /^CF-/i) {
+ elsif ($k =~ /^$cf_spec/) {
my $cf = RT::CustomField->new( $RT::SystemUser );
- my $cfk = $k;
- $cfk =~ s/^CF-//i;
+ my $cfk = $1 || $2;
unless($cf->LoadByName( Name => $cfk )) {
push @comments, "# Invalid custom field name ($cfk)";
delete $data{$k};
@@ -227,7 +229,7 @@
while (my $v = $vals->Next()) {
push @out, $v->Content;
}
- push @data, [ 'CF-' . $cf->Name => join ',', @out ];
+ push @data, [ ('CF.{' . $cf->Name . '}') => join ',', @out ];
}
my %k = map {@$_} @data;
@@ -314,9 +316,9 @@
}
}
# Set custom field
- elsif ($key =~ /^CF-/i) {
+ elsif ($key =~ /^$cf_spec/) {
my $cf = RT::CustomField->new( $RT::SystemUser );
- $key =~ s/^CF-//i;
+ $key = $1 || $2;
if (not $cf->LoadByName( Name => $key )) {
$n = 0;
$s = "Unknown custom field.";
More information about the Rt-commit
mailing list