[Rt-commit] r2336 - in rtfm/branches/2.1-TESTING: . docs html/RTFM/Admin/Classes html/RTFM/Article lib/RT/FM t

jesse at bestpractical.com jesse at bestpractical.com
Thu Mar 10 15:03:40 EST 2005


Author: jesse
Date: Thu Mar 10 15:03:40 2005
New Revision: 2336

Added:
   rtfm/branches/2.1-TESTING/docs/todo
   rtfm/branches/2.1-TESTING/html/RTFM/Admin/Classes/CustomFields.html
   rtfm/branches/2.1-TESTING/t/3upload-customfields.t
Modified:
   rtfm/branches/2.1-TESTING/   (props changed)
   rtfm/branches/2.1-TESTING/html/RTFM/Article/Edit.html
   rtfm/branches/2.1-TESTING/lib/RT/FM/Article_Overlay.pm
Log:
 r6659 at hualien:  jesse | 2005-03-10 14:54:10 -0500
 added a todo list for the next release
 


Added: rtfm/branches/2.1-TESTING/docs/todo
==============================================================================
--- (empty file)
+++ rtfm/branches/2.1-TESTING/docs/todo	Thu Mar 10 15:03:40 2005
@@ -0,0 +1,51 @@
+TODO
+
+Links:
+
+
+    When extracting an article from an RT link, shall add functionality to automatically create the relationship and provide links between the original ticket and the newly created article.
+
+
+
+Custom fields:
+
+    File upload custom fields
+
+
+
+Hierarchy:
+
+
+    Hierarchy selection on article creation
+
+
+M. Menu
+
+    FAQ Class page: Show linkable hierarchies with an option to show all (like a table of contents).  
+
+
+Access control:
+
+    Configuration should not be shown unless the user has 
+    permissions to Configure a class.
+
+N. Formatting
+
+    Custom field UI display cleanup:
+    Needs to be more space between each custom field 
+        (ie, Answer and Question need more separation).
+
+Search UI
+
+    If link "Show advanced search options" is selected, 
+        the Search section should appear at the top of the page.
+
+    Saved searches
+
+    Bookmarkable searches
+
+    Search in upper right shall query article id, name and summary.
+
+    Add: Search all custom fields for _____
+    
+    Search by hierachy

Added: rtfm/branches/2.1-TESTING/html/RTFM/Admin/Classes/CustomFields.html
==============================================================================
--- (empty file)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Admin/Classes/CustomFields.html	Thu Mar 10 15:03:40 2005
@@ -0,0 +1,2 @@
+<& /Admin/Elements/ObjectCustomFields, %ARGS, ObjectType => 'RT::FM::Class' &>
+

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/Edit.html
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/Edit.html	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/Edit.html	Thu Mar 10 15:03:40 2005
@@ -28,8 +28,8 @@
 % }
 <& /Elements/ListActions, actions => \@results &>
 
-<FORM METHOD=POST ACTION="Edit.html">
-<INPUT TYPE=HIDDEN NAME="id" VALUE="<%$id%>">
+<FORM METHOD=POST ACTION="Edit.html" name="EditArticle" id="EditArticle" enctype="multipart/form-data">
+<INPUT TYPE=HIDDEN NAME="id" VALUE="<%$id%>"/>
 
 <& Elements/EditBasics, ArticleObj => $ArticleObj,
                         EditClass =>$EditClass,
@@ -58,8 +58,9 @@
 </form>
 <%INIT>
 
-if (exists $ARGS{'Topics'}) {
-  $ARGS{'Topics'} = ref($ARGS{'Topics'}) ? $ARGS{'Topics'} : [$ARGS{'Topics'}]
+if ( exists $ARGS{'Topics'} ) {
+    $ARGS{'Topics'} =
+      ref( $ARGS{'Topics'} ) ? $ARGS{'Topics'} : [ $ARGS{'Topics'} ];
 }
 
 my @results;
@@ -67,7 +68,7 @@
 
 my $Entries    = {};
 my $ArticleObj = RT::FM::Article->new( $session{'CurrentUser'} );
-my $ClassObj = RT::FM::Class->new($session{'CurrentUser'});
+my $ClassObj   = RT::FM::Class->new( $session{'CurrentUser'} );
 my %create_args;
 my %CFContent;
 my $EditClass = 1;
@@ -83,96 +84,107 @@
 
     $ClassObj->Load($Class);
     unless ( $ClassObj->Id ) {
-        $m->comp( "/RTFM/Elements/Error", Why => loc("'[_1]' isn't a valid class identifier", $Class));
+        $m->comp( "/RTFM/Elements/Error",
+            Why => loc( "'[_1]' isn't a valid class identifier", $Class ) );
     }
     $EditClass = 0;
-    $id = 'new';
+    $id        = 'new';
 }
 elsif ( $id eq 'new' ) {
 
     if ( $ARGS{'RefersTo-new'} ) {
         @{ $create_args{'RefersTo-new'} } =
-          split ( /\s+/, $ARGS{'RefersTo-new'} );
+          split( /\s+/, $ARGS{'RefersTo-new'} );
     }
 
     if ( $ARGS{'new-RefersTo'} ) {
         @{ $create_args{'new-RefersTo'} } =
-          split ( /\s+/, $ARGS{'new-RefersTo'} );
+          split( /\s+/, $ARGS{'new-RefersTo'} );
     }
 
-    foreach my $arg ( keys %ARGS ) {
-        if ( $arg =~ /^Article-new-CustomField-(\d+)-/ ) {
-            $create_args{'CustomField-'.$1} = $ARGS{$arg};
-        }
-    }
 
     my $msg;
-    ( $id, $msg ) = $ArticleObj->Create( Summary => $ARGS{'Summary'},
-                                         Name    => $ARGS{'Name'},
-                                         Class   => $ARGS{'Class'},
-                                         Topics  => $ARGS{'Topics'},
-                                         %create_args );
-        push ( @results, $msg );
-    if ($id ) {
+    ( $id, $msg ) = $ArticleObj->Create(
+        Summary => $ARGS{'Summary'},
+        Name    => $ARGS{'Name'},
+        Class   => $ARGS{'Class'},
+        Topics  => $ARGS{'Topics'},
+        %create_args
+    );
+    my @cf_results = ProcessObjectCustomFieldUpdates(
+        Object  => $ArticleObj,
+        ARGSRef => \%ARGS
+    );
+    @results = ( @results, @cf_results );
+
+    push( @results, $msg );
+    if ($id) {
         $title = loc( 'Modify article #[_1]', $ArticleObj->Id );
     }
     else {
         $ClassObj->Load($Class);
         unless ( $ClassObj->Id ) {
-            $m->comp( "/RTFM/Elements/Error", Why => loc("'[_1]' isn't a valid class identifier", $Class));
-                }
-        $id = 'new';
+            $m->comp( "/RTFM/Elements/Error",
+                Why => loc( "'[_1]' isn't a valid class identifier", $Class ) );
+        }
+        $id        = 'new';
         $EditClass = 0;
-        $title = loc('Create a new article');
+        $title     = loc('Create a new article');
     }
-} else {
+}
+else {
 
     $ArticleObj->Load($id);
-      unless ( $ArticleObj->id ) {
+    unless ( $ArticleObj->id ) {
         $m->comp( "/RTFM/Elements/Error",
-                  Why => loc("Unable to load article") );
+            Why => loc("Unable to load article") );
     }
 
     my @attribs = qw(Name Summary Class);
 
-      @results = UpdateRecordObject( AttributesRef => \@attribs,
-                                     Object        => $ArticleObj,
-                                     ARGSRef       => \%ARGS );
-
-                               
-              my @cf_results = ProcessObjectCustomFieldUpdates(Object => $ArticleObj, ARGSRef => \%ARGS);
-    @results = (@results, at cf_results);
-      # Delete links that are gone gone gone.
-      foreach my $arg ( keys %ARGS ){
+    @results = UpdateRecordObject(
+        AttributesRef => \@attribs,
+        Object        => $ArticleObj,
+        ARGSRef       => \%ARGS
+    );
+
+    my @cf_results = ProcessObjectCustomFieldUpdates(
+        Object  => $ArticleObj,
+        ARGSRef => \%ARGS
+    );
+    @results = ( @results, @cf_results );
+
+    # Delete links that are gone gone gone.
+    foreach my $arg ( keys %ARGS ) {
         if ( $arg =~ /DeleteLink-(.*?)-(RefersTo|MemberOf|RefersTo)-(.*)$/ ) {
             my $base   = $1;
             my $type   = $2;
             my $target = $3;
 
-            my ( $val, $msg ) = $ArticleObj->DeleteLink( Base   => $base,
-                                                         Type   => $type,
-                                                         Target => $target );
+            my ( $val, $msg ) = $ArticleObj->DeleteLink(
+                Base   => $base,
+                Type   => $type,
+                Target => $target
+            );
 
             push @results, $msg;
 
         }
 
-      }
+    }
 
-      my @linktypes = qw(DependsOn MemberOf RefersTo );
+    my @linktypes = qw(DependsOn MemberOf RefersTo );
 
-      foreach my $linktype (@linktypes) {
+    foreach my $linktype (@linktypes) {
 
-        for my $luri ( split ( / /, $ARGS{ $ArticleObj->Id . "-$linktype" } ) )
-        {
+        for my $luri ( split( / /, $ARGS{ $ArticleObj->Id . "-$linktype" } ) ) {
             $luri =~ s/\s*$//;    # Strip trailing whitespace
             my ( $val, $msg ) =
               $ArticleObj->AddLink( Target => $luri, Type => $linktype );
             push @results, $msg;
         }
 
-        for my $luri ( split ( / /, $ARGS{ "$linktype-" . $ArticleObj->Id } ) )
-        {
+        for my $luri ( split( / /, $ARGS{ "$linktype-" . $ArticleObj->Id } ) ) {
             my ( $val, $msg ) =
               $ArticleObj->AddLink( Base => $luri, Type => $linktype );
 
@@ -182,34 +194,36 @@
     }
 
     my %topics;
-    if ($ARGS{'EditTopics'}) {
-        $topics{$_}++ for @{$ARGS{'Topics'}};
-        my $objTopics = new RT::FM::ObjectTopicCollection($session{'CurrentUser'});
+    if ( $ARGS{'EditTopics'} ) {
+        $topics{$_}++ for @{ $ARGS{'Topics'} };
+        my $objTopics =
+          new RT::FM::ObjectTopicCollection( $session{'CurrentUser'} );
         $objTopics->LimitToObject($ArticleObj);
-        while (my $t = $objTopics->Next) {
-            $topics{$t->Topic}--;
+        while ( my $t = $objTopics->Next ) {
+            $topics{ $t->Topic }--;
         }
-        for my $id (keys %topics) {
-            if ($topics{$id} > 0) {
-                my ($val, $msg) = $ArticleObj->AddTopic(Topic => $id);
+        for my $id ( keys %topics ) {
+            if ( $topics{$id} > 0 ) {
+                my ( $val, $msg ) = $ArticleObj->AddTopic( Topic => $id );
                 push @results, $msg;
-            } elsif ($topics{$id} < 0) {
-                my ($val, $msg) = $ArticleObj->DeleteTopic(Topic => $id);
+            }
+            elsif ( $topics{$id} < 0 ) {
+                my ( $val, $msg ) = $ArticleObj->DeleteTopic( Topic => $id );
                 push @results, $msg;
             }
         }
     }
-    
 
     $title = loc( 'Modify article #[_1]', $ArticleObj->Id );
-  }
+}
 
-  # if they're working on an existing article
-  if ($ArticleObj->id) {
-  unless ( $ArticleObj->CurrentUserHasRight('ShowArticle') ) {
-    $m->comp( "/RTFM/Elements/Error", Why => "No permission to view Article" );
+# if they're working on an existing article
+if ( $ArticleObj->id ) {
+    unless ( $ArticleObj->CurrentUserHasRight('ShowArticle') ) {
+        $m->comp( "/RTFM/Elements/Error",
+            Why => "No permission to view Article" );
     }
-  }
+}
 
 </%INIT>
 

Modified: rtfm/branches/2.1-TESTING/lib/RT/FM/Article_Overlay.pm
==============================================================================
--- rtfm/branches/2.1-TESTING/lib/RT/FM/Article_Overlay.pm	(original)
+++ rtfm/branches/2.1-TESTING/lib/RT/FM/Article_Overlay.pm	Thu Mar 10 15:03:40 2005
@@ -175,7 +175,7 @@
     }
     $RT::Handle->Commit();
 
-    return ( $id, $msg );
+    return ( $id, $self->loc('Article [_1] created',$self->id ));
 }
 
 # }}}

Added: rtfm/branches/2.1-TESTING/t/3upload-customfields.t
==============================================================================
--- (empty file)
+++ rtfm/branches/2.1-TESTING/t/3upload-customfields.t	Thu Mar 10 15:03:40 2005
@@ -0,0 +1,138 @@
+#!/usr/bin/perl -w
+use strict;
+
+BEGIN {
+    use RT;
+    RT::LoadConfig;
+    RT::Init;
+}
+use Test::More qw/no_plan/;
+use Test::WWW::Mechanize;
+BEGIN { 
+$RT::WebPort ||= '80';
+$RT::WebPath ||= ''; # Shut up a warning
+};
+use constant BaseURL => "http://localhost:".$RT::WebPort.$RT::WebPath."/";
+use constant ImageFile => $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif';
+use constant ImageFileContent => do {
+    local $/;
+    open my $fh, '<', ImageFile or die $!;
+    binmode($fh);
+    scalar <$fh>;
+};
+
+my $m = Test::WWW::Mechanize->new;
+isa_ok($m, 'Test::WWW::Mechanize');
+ok(1, "Connecting to ".BaseURL);
+$m->get( BaseURL."?user=root;pass=password" );
+$m->content_like(qr/Logout/, 'we did log in');
+$m->follow_link( text => 'Configuration' );
+$m->title_is(q/RT Administration/, 'admin screen');
+$m->follow_link( text => 'Custom Fields' );
+$m->title_is(q/Select a Custom Field/, 'admin-cf screen');
+$m->follow_link( text => 'New custom field' );
+$m->submit_form(
+    form_name => "ModifyCustomField",
+    fields => {
+        TypeComposite => 'Image-0',
+        LookupType => 'RT::FM::Class-RT::FM::Article',
+        Name => 'img'.$$,
+        Description => 'img',
+    },
+);
+$m->title_is(qq/Created CustomField img$$/, 'admin-cf created');
+$m->follow_link( text => 'Applies to' );
+$m->title_is(qq/Modify associated objects for img$$/, 'pick cf screenadmin screen');
+$m->form_number(3);
+# Sort by numeric IDs in names
+my @names = map  { $_->[1] }
+            sort { $a->[0] <=> $b->[0] }
+            map  { /Object-1-CF-(\d+)/ ? [ $1 => $_ ] : () }
+            map  $_->name, $m->current_form->inputs;
+my $tcf = pop(@names);
+$m->field( $tcf => 1 );         # Associate the new CF with this queue
+$m->field( $_ => undef ) for @names;    # ...and not any other. ;-)
+$m->submit;
+
+$m->content_like( qr/Object created/, 'TCF added to the queue' );
+$m->follow_link( text => 'RTFM');
+$m->follow_link( text => 'Articles');
+$m->follow_link( text => 'New Article');
+
+$m->title_is(qq/Create an article in class.../);
+
+$m->follow_link( url_regex => qr/Edit.html\?Class=1/ );
+$m->title_is(qq/Create a new article/);
+
+$m->content_like(qr/Upload multiple images/, 'has a upload image field');
+
+$tcf =~ /(\d+)$/ or die "Hey this is impossible dude";
+my $upload_field = "Object-RT::FM::Article--CustomField-$1-Upload";
+
+
+$m->submit_form(
+    form_name => "EditArticle",
+    fields => {
+        $upload_field => ImageFile,
+        Name => 'Image Test '.$$,
+        Summary => 'testing img cf creation',
+    },
+);
+
+$m->content_like(qr/Article \d+ created/, "an article was created succesfully");
+
+my $id = $1 if $m->content =~ /Article (\d+) created/;
+
+$m->title_like(qr/Modify article #$id/, "Editing!");
+
+$m->follow_link( text => 'bplogo.gif' );
+$m->content_is(ImageFileContent, "it links to the uploaded image");
+exit;
+$m->get( BaseURL );
+
+$m->follow_link( text => 'Tickets' );
+$m->follow_link( text => 'New Query' );
+
+$m->title_is(q/Query Builder/, 'Query building');
+$m->submit_form(
+    form_name => "BuildQuery",
+    fields => {
+        idOp => '=',
+        ValueOfid => $id,
+        ValueOfQueue => 'General',
+    },
+    button => 'AddClause',
+);
+
+$m->form_name('BuildQuery');
+
+my $col = ($m->current_form->find_input('SelectDisplayColumns'))[-1];
+$col->value( ($col->possible_values)[-1] );
+
+$m->click('AddCol');
+
+$m->form_name('BuildQuery');
+$m->click('DoSearch');
+
+$m->follow_link( text_regex => qr/bplogo\.gif/ );
+$m->content_is(ImageFileContent, "it links to the uploaded image");
+
+__END__
+[FC] Bulk Update does not have custom fields.
+
+
+# Create an RTFM class
+
+# Create a custom field
+
+
+# Associate the custom field with our class
+
+# create an RTFM article
+
+# Upload a file to that article
+
+# Validate that it has been erased
+
+
+


More information about the Rt-commit mailing list