Commit e53a1cf2 authored by Shawn M Moore's avatar Shawn M Moore
Browse files

Change the template Type from Full to Perl

parent b6b1c7b3
......@@ -16,7 +16,7 @@
$templates->UnLimit();
while (my $template = $templates->Next) {
my ($status, $msg) = $template->SetType('Full');
my ($status, $msg) = $template->SetType('Perl');
unless ( $status ) {
die "Couldn't change Type of Template #" . $template->Id . ": $msg";
}
......
......@@ -82,7 +82,7 @@ sub _Accessible {
id => 'read',
Name => 'read/write',
Description => 'read/write',
Type => 'read/write', #Type is one of Full or Simple
Type => 'read/write', #Type is one of Perl or Simple
Content => 'read/write',
Queue => 'read/write',
Creator => 'read/auto',
......@@ -206,7 +206,7 @@ sub Create {
Content => undef,
Queue => 0,
Description => '[no description]',
Type => 'Full',
Type => 'Perl',
Name => undef,
@_
);
......@@ -215,7 +215,7 @@ sub Create {
unless ( $self->CurrentUser->HasRight(Right =>'ModifyTemplate', Object => $RT::System) ) {
return ( undef, $self->loc('Permission Denied') );
}
if ( $args{Type} eq 'Full' && !$self->CurrentUser->HasRight(Right => 'ModifyPerlTemplates', Object => $RT::System) ) {
if ( $args{Type} eq 'Perl' && !$self->CurrentUser->HasRight(Right => 'ModifyPerlTemplates', Object => $RT::System) ) {
return ( undef, $self->loc('Permission Denied') );
}
$args{'Queue'} = 0;
......@@ -227,7 +227,7 @@ sub Create {
unless ( $QueueObj->CurrentUserHasRight('ModifyTemplate') ) {
return ( undef, $self->loc('Permission Denied') );
}
if ( $args{Type} eq 'Full' && !$QueueObj->CurrentUserHasRight('ModifyPerlTemplates') ) {
if ( $args{Type} eq 'Perl' && !$QueueObj->CurrentUserHasRight('ModifyPerlTemplates') ) {
return ( undef, $self->loc('Permission Denied') );
}
$args{'Queue'} = $QueueObj->Id;
......@@ -408,8 +408,8 @@ sub _ParseContent {
$args{'loc'} = sub { $self->loc(@_) };
}
if ($self->Type eq 'Full') {
return $self->_ParseContentFull(
if ($self->Type eq 'Perl') {
return $self->_ParseContentPerl(
Content => $content,
TemplateArgs => \%args,
);
......@@ -422,8 +422,8 @@ sub _ParseContent {
}
}
# uses Text::Template for Full templates
sub _ParseContentFull {
# uses Text::Template for Perl templates
sub _ParseContentPerl {
my $self = shift;
my %args = (
Content => undef,
......@@ -597,7 +597,7 @@ sub CurrentUserHasQueueRight {
=head2 SetType
If setting Type to Full, require the ModifyPerlTemplates right on the queue.
If setting Type to Perl, require the ModifyPerlTemplates right on the queue.
=cut
......@@ -605,7 +605,7 @@ sub SetType {
my $self = shift;
my $NewType = shift;
if ($NewType eq 'Full' && !$self->CurrentUserHasQueueRight('ModifyPerlTemplates')) {
if ($NewType eq 'Perl' && !$self->CurrentUserHasQueueRight('ModifyPerlTemplates')) {
return ( undef, $self->loc('Permission Denied') );
}
......@@ -615,7 +615,7 @@ sub SetType {
=head2 SetQueue
When changing the queue, make sure the current user has ModifyPerlTemplates on the
new queue if the type is Full.
new queue if the type is Perl.
Templates can't change Queue in the UI (yet?).
......@@ -628,7 +628,7 @@ sub SetQueue {
my $NewQueueObj = RT::Queue->new( $self->CurrentUser );
$NewQueueObj->Load($NewQueue);
if ( $self->Type eq 'Full' && !$NewQueueObj->CurrentUserHasRight('ModifyPerlTemplates') ) {
if ( $self->Type eq 'Perl' && !$NewQueueObj->CurrentUserHasRight('ModifyPerlTemplates') ) {
return ( undef, $self->loc('Permission Denied. You do not have ModifyPerlTemplates on the new queue.') );
}
......@@ -637,7 +637,7 @@ sub SetQueue {
=head2 CompileCheck
If the template's Type is Full, then compile check all the codeblocks to see if
If the template's Type is Perl, then compile check all the codeblocks to see if
they are syntactically valid. We eval them in a codeblock to avoid actually
executing the code.
......@@ -649,7 +649,7 @@ sub CompileCheck {
my $self = shift;
return (1, $self->loc("Template does not include Perl code"))
unless $self->Type eq 'Full';
unless $self->Type eq 'Perl';
my $content = $self->Content;
$content = '' if !defined($content);
......
......@@ -67,7 +67,7 @@
<&|/l&>Type</&>:
</td>
<td>
<input type="radio" name="Type" value="Full" <% $Type eq "Full" ? 'checked="checked"' : "" |n %>><&|/l&>Full</&></input><br />
<input type="radio" name="Type" value="Perl" <% $Type eq "Perl" ? 'checked="checked"' : "" |n %>><&|/l&>Perl</&></input><br />
<input type="radio" name="Type" value="Simple" <% $Type eq "Simple" ? 'checked="checked"' : "" |n %>><&|/l&>Simple</&></input><br />
</td>
</tr>
......@@ -84,7 +84,7 @@
<%INIT>
$Type = 'Full' if !$Type;
$Type = 'Perl' if !$Type;
</%INIT>
......@@ -92,5 +92,5 @@ $Type = 'Full' if !$Type;
$Name => ''
$Description => ''
$Content => ''
$Type => 'Full'
$Type => 'Perl'
</%ARGS>
......@@ -39,25 +39,25 @@ $ticket->AddCustomFieldValue(
TemplateTest(
Content => "\ntest",
FullOutput => "test",
PerlOutput => "test",
SimpleOutput => "test",
);
TemplateTest(
Content => "\ntest { 5 * 5 }",
FullOutput => "test 25",
PerlOutput => "test 25",
SimpleOutput => "test { 5 * 5 }",
);
TemplateTest(
Content => "\ntest { \$Requestor }",
FullOutput => "test dom\@example.com",
PerlOutput => "test dom\@example.com",
SimpleOutput => "test dom\@example.com",
);
TemplateTest(
Content => "\ntest { \$TicketSubject }",
FullOutput => "test ",
PerlOutput => "test ",
SimpleOutput => "test template testing",
);
......@@ -128,25 +128,25 @@ SimpleTemplateTest(
TemplateTest(
Content => "\ntest { \$Ticket->Nonexistent }",
FullOutput => undef,
PerlOutput => undef,
SimpleOutput => "test { \$Ticket->Nonexistent }",
);
TemplateTest(
Content => "\ntest { \$Nonexistent->Nonexistent }",
FullOutput => undef,
PerlOutput => undef,
SimpleOutput => "test { \$Nonexistent->Nonexistent }",
);
TemplateTest(
Content => "\ntest { \$Ticket->OwnerObj->Name }",
FullOutput => "test root",
PerlOutput => "test root",
SimpleOutput => "test { \$Ticket->OwnerObj->Name }",
);
TemplateTest(
Content => "\ntest { *!( }",
FullOutput => undef,
PerlOutput => undef,
SimpleOutput => "test { *!( }",
);
......@@ -161,12 +161,12 @@ is($ticket->Status, 'new', "simple templates can't call ->Resolve");
my $template = RT::Template->new($RT::SystemUser);
$template->Create(
Name => "type chameleon",
Type => "Full",
Type => "Perl",
Content => "\ntest { 10 * 7 }",
);
ok($id = $template->id, "Created template");
$template->Parse;
is($template->MIMEObj->stringify_body, "test 70", "Full output");
is($template->MIMEObj->stringify_body, "test 70", "Perl output");
$template = RT::Template->new($RT::SystemUser);
$template->Load($id);
......@@ -180,9 +180,9 @@ $template = RT::Template->new($RT::SystemUser);
$template->Load($id);
is($template->Name, "type chameleon");
$template->SetType('Full');
$template->SetType('Perl');
$template->Parse;
is($template->MIMEObj->stringify_body, "test 70", "Full output");
is($template->MIMEObj->stringify_body, "test 70", "Perl output");
my $counter = 0;
sub IndividualTemplateTest {
......@@ -190,7 +190,7 @@ sub IndividualTemplateTest {
my %args = (
Name => "Test-" . ++$counter,
Type => "Full",
Type => "Perl",
@_,
);
......@@ -223,7 +223,7 @@ sub TemplateTest {
local $Test::Builder::Level = $Test::Builder::Level + 1;
my %args = @_;
for my $type ('Full', 'Simple') {
for my $type ('Perl', 'Simple') {
next if $args{"Skip$type"};
IndividualTemplateTest(
......
......@@ -33,7 +33,7 @@ $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
# now try changing Type back and forth
$m->form_name('ModifyTemplate');
is($m->value('Type'), 'Full');
is($m->value('Type'), 'Perl');
$m->field(Type => 'Simple');
$m->submit;
......@@ -42,22 +42,22 @@ $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
$m->form_name('ModifyTemplate');
is($m->value('Type'), 'Simple', 'updated type to simple');
$m->field(Type => 'Full');
$m->field(Type => 'Perl');
$m->submit;
$m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
$m->form_name('ModifyTemplate');
is($m->value('Type'), 'Simple', 'need the ModifyPerlTemplates right to update Type to Full');
is($m->value('Type'), 'Simple', 'need the ModifyPerlTemplates right to update Type to Perl');
$m->content_contains('Permission Denied');
ok( RT::Test->add_rights(
{ Principal => $user_a, Right => [qw(ModifyPerlTemplates)] },
), 'add ModifyPerlTemplates rights');
$m->field(Type => 'Full');
$m->field(Type => 'Perl');
$m->submit;
$m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
$m->form_name('ModifyTemplate');
is($m->value('Type'), 'Full', 'now that we have ModifyPerlTemplates we can update Type to Full');
is($m->value('Type'), 'Perl', 'now that we have ModifyPerlTemplates we can update Type to Perl');
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment