[Rt-commit] rt branch, admin_ui, updated. 3b88528deb855605b169fab77ec3ebee114880ab
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Wed Jan 6 02:07:46 EST 2010
The branch, admin_ui has been updated
via 3b88528deb855605b169fab77ec3ebee114880ab (commit)
from cf9499029e7499e5a598af0b223bebea2a611357 (commit)
Summary of changes:
lib/RT/Action/CreateCustomField.pm | 27 -----------
lib/RT/Action/UpdateCustomField.pm | 26 +----------
lib/RT/Model/CustomField.pm | 85 +++---------------------------------
sbin/rt-migrate-db-from-3.8 | 17 +++++++
4 files changed, 27 insertions(+), 128 deletions(-)
- Log -----------------------------------------------------------------
commit 3b88528deb855605b169fab77ec3ebee114880ab
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Jan 6 15:07:20 2010 +0800
link_value_to and include_content_for_value are columns in cf model
diff --git a/lib/RT/Action/CreateCustomField.pm b/lib/RT/Action/CreateCustomField.pm
index a818e2d..41e867f 100644
--- a/lib/RT/Action/CreateCustomField.pm
+++ b/lib/RT/Action/CreateCustomField.pm
@@ -8,36 +8,9 @@ sub record_class { 'RT::Model::CustomField' }
use constant report_detailed_messages => 1;
-use Jifty::Param::Schema;
-use Jifty::Action schema {
- param 'link_value_to' => hints is _(
-q{RT can make this custom field's values into hyperlinks to another service.
-Fill in this field with a URL.
-RT will replace <tt>__id__</tt> and <tt>__CustomField__</tt> with the record
-id and custom field value, respectively}
- );
- param 'include_content_for_value' => hints is _(
-q{RT can include content from another web service when showing this custom field.
-Fill in this field with a URL.
-RT will replace <tt>__id__</tt> and <tt>__CustomField__</tt> with the record id and custom field value, respectively
-Some browsers may only load content from the same domain as your RT server.}
- );
-};
-
sub take_action {
my $self = shift;
$self->SUPER::take_action;
-
- my @attrs = qw/link_value_to include_content_for_value/;
-
- for my $attr (@attrs) {
- if ( $self->has_argument($attr) ) {
- my $method = "set_$attr";
- my ( $status, $msg ) =
- $self->record->$method( $self->argument_value($attr) );
- Jifty->log->error($msg) unless $status;
- }
- }
return 1;
}
diff --git a/lib/RT/Action/UpdateCustomField.pm b/lib/RT/Action/UpdateCustomField.pm
index 3178415..405f8f2 100644
--- a/lib/RT/Action/UpdateCustomField.pm
+++ b/lib/RT/Action/UpdateCustomField.pm
@@ -8,24 +8,6 @@ sub record_class { 'RT::Model::CustomField' }
use constant report_detailed_messages => 1;
-use Jifty::Param::Schema;
-use Jifty::Action schema {
- my $self = shift;
- param 'link_value_to' => hints is _(
-q{RT can make this custom field's values into hyperlinks to another service.
-Fill in this field with a URL.
-RT will replace <tt>__id__</tt> and <tt>__CustomField__</tt> with the record
-id and custom field value, respectively}
- );
- param 'include_content_for_value' => hints is _(
-q{RT can include content from another web service when showing this custom field.
-Fill in this field with a URL.
-RT will replace <tt>__id__</tt> and <tt>__CustomField__</tt> with the record id and custom field value, respectively
-Some browsers may only load content from the same domain as your RT server.}
- );
-
-};
-
sub arguments {
my $self = shift;
my $args = $self->SUPER::arguments;
@@ -70,15 +52,13 @@ sub take_action {
my $self = shift;
$self->SUPER::take_action;
- my @attrs = qw/link_value_to include_content_for_value/;
- push @attrs, 'values_class' if $self->has_values_sources;
-
- for my $attr (@attrs) {
+ if ( $self->has_values_sources ) {
+ my $attr = 'values_class';
if ( $self->has_argument($attr) ) {
my $method = "set_$attr";
# for non select cfs, we supply an empty and hidden input
# and we don't want to set_... for that.
- next if $attr eq 'values_class' && !$self->argument_value($attr);
+ next unless $self->argument_value($attr);
my ( $status, $msg ) =
$self->record->$method( $self->argument_value($attr) );
diff --git a/lib/RT/Model/CustomField.pm b/lib/RT/Model/CustomField.pm
index 4e4e3df..0e1b59f 100755
--- a/lib/RT/Model/CustomField.pm
+++ b/lib/RT/Model/CustomField.pm
@@ -105,6 +105,11 @@ use Jifty::DBI::Record schema {
},
],
default is 'RT::Model::Queue-RT::Model::Ticket';
+ # TODO do we want to set URI filter for the following 2?
+ column link_value_to => type is 'text', display_length is 60, default is '';
+ column
+ include_content_for_value => type is 'text',
+ display_length is 60, default is '';
column disabled => max_length is 6, type is 'smallint', render as
'Checkbox', default is '0';
};
@@ -294,16 +299,10 @@ sub create {
disabled => $args{'disabled'},
lookup_type => $args{'lookup_type'},
repeated => $args{'repeated'},
+ link_value_to => $args{'link_value_to'},
+ include_content_for_value => $args{include_content_for_value},
);
- if ( exists $args{'link_value_to'} ) {
- $self->set_link_value_to( $args{'link_value_to'} );
- }
-
- if ( exists $args{'include_content_for_value'} ) {
- $self->set_include_content_for_value( $args{'include_content_for_value'} );
- }
-
if ( exists $args{'values_class'} ) {
$self->set_values_class( $args{'values_class'} );
}
@@ -1157,76 +1156,6 @@ sub _for_object_type {
}
-=head2 include_content_for_value [value] (and Setinclude_content_for_value)
-
-Gets or sets the C<include_content_for_value> for this custom field. RT
-uses this field to automatically include content into the user's browser
-as they display records with custom fields in RT.
-
-=cut
-
-sub set_include_content_for_value {
- shift->include_content_for_value(@_);
-}
-
-sub include_content_for_value {
- my $self = shift;
- $self->url_template( 'include_content_for_value', @_ );
-}
-
-=head2 link_value_to [value] (and Setlink_value_to)
-
-Gets or sets the C<link_value_to> for this custom field. RT
-uses this field to make custom field values into hyperlinks in the user's
-browser as they display records with custom fields in RT.
-
-=cut
-
-sub set_link_value_to {
- shift->link_value_to(@_);
-}
-
-sub link_value_to {
- my $self = shift;
- $self->url_template( 'link_value_to', @_ );
-
-}
-
-=head2 url_template name [value]
-
-With one argument, returns the url_template named C<name>, but only if
-the current user has the right to see this custom field.
-
-With two arguments, attemptes to set the relevant template value.
-
-=cut
-
-sub url_template {
- my $self = shift;
- my $template_name = shift;
- if (@_) {
-
- my $value = shift;
- unless ( $self->current_user_has_right('AdminCustomField') ) {
- return ( 0, _('Permission Denied') );
- }
- $self->set_attribute( name => $template_name, content => $value );
- return ( 1, _('Updated') );
- } else {
- unless ( $self->id
- && $self->current_user_has_right('SeeCustomField') )
- {
- return (undef);
- }
-
- my @attr = $self->attributes->named($template_name);
- my $attr = shift @attr;
-
- if ($attr) { return $attr->content }
-
- }
-}
-
=head2 type_for_rendering
This returns an appropriate C<render as> value based on the custom field's
diff --git a/sbin/rt-migrate-db-from-3.8 b/sbin/rt-migrate-db-from-3.8
index a2385a4..b296dde 100755
--- a/sbin/rt-migrate-db-from-3.8
+++ b/sbin/rt-migrate-db-from-3.8
@@ -202,6 +202,23 @@ sub post_update_all_tables {
(&$function)->();
print "updated table $table\n";
}
+
+ # LinkValueTo and IncludeContentForValue are real columns in rt4
+ # this involves 2 tables, let's put it here for now.
+ require RT::Model::CustomFieldCollection;
+ my $cfs =
+ RT::Model::CustomFieldCollection->new( current_user => RT->system_user );
+ $cfs->unlimit;
+ while ( my $cf = $cfs->next ) {
+ for my $column ( qw/LinkValueTo IncludeContentForValue/ ) {
+ my ( $attr ) = $cf->attributes->named($column);
+ if ( $attr ) {
+ my $set_method = "set_" . renaming $column;
+ $cf->$set_method( $attr->content );
+ $attr->delete;
+ }
+ }
+ }
}
sub drop_columns_in_all_tables {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list