Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Request Tracker: Commit

rt branch, 4.0/allow-times-for-ical-feeds, created. rt-4.0.6-250-g6ebf6aa

 

 

Request Tracker commit RSS feed   Index | Next | Previous | View Threaded


jbrandt at bestpractical

Aug 17, 2012, 6:11 AM

Post #1 of 1 (110 views)
Permalink
rt branch, 4.0/allow-times-for-ical-feeds, created. rt-4.0.6-250-g6ebf6aa

The branch, 4.0/allow-times-for-ical-feeds has been created
at 6ebf6aae9e66b6670152b5ab43758cd3b5c70415 (commit)

- Log -----------------------------------------------------------------
commit 6ebf6aae9e66b6670152b5ab43758cd3b5c70415
Author: Jim Brandt <jbrandt [at] bestpractical>
Date: Wed Aug 8 11:01:59 2012 -0400

Add time and single events as options for iCal feed entries

Allow time to be optionally included in iCal feed events
so these events will show up in the calendar at the specific
start or due time from the ticket rather than being all-day
events. This is a global config option which can also be
set individually by users.

Add a SingleEvent mode such that if you pass SingleEvent=1
as a query parameter, each ticket in the feed will create
a single calendar event with the start and due date
rather than the default two events.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 784d76c..435bdb9 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2039,6 +2039,20 @@ minutes. Note that this only effects entry, not display.

Set($DefaultTimeUnitsToHours, 0);

+=item C<$TimeInICal>
+
+By default, events in the iCal feed on the ticket search page
+contain only dates, making them all day calendar events. Set
+C<$TimeInICal> if you have start or due dates on tickets that
+have significant time values and you want those times to be
+included in the events in the iCal feed.
+
+This option can also be set as an individual user preference.
+
+=cut
+
+Set($TimeInICal, 0);
+
=back


diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index ba338bb..e9b655a 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -215,6 +215,16 @@ our %META = (
$self->Set('WebDefaultStylesheet', 'aileron');
},
},
+ TimeInICal => {
+ Section => 'General',
+ Overridable => 1,
+ SortOrder => 5,
+ Widget => '/Widgets/Form/Boolean',
+ WidgetArguments => {
+ Description => 'Include time in iCal feed events?', # loc
+ Hints => 'Formats iCal feed events with date and time' #loc
+ }
+ },
UseSideBySideLayout => {
Section => 'Ticket composition',
Overridable => 1,
diff --git a/share/html/NoAuth/iCal/dhandler b/share/html/NoAuth/iCal/dhandler
index c86f4cf..d5baf93 100644
--- a/share/html/NoAuth/iCal/dhandler
+++ b/share/html/NoAuth/iCal/dhandler
@@ -101,19 +101,37 @@ while (my $t = $tickets->Next) {
'last-modified' => $t->LastUpdatedObj->iCal,
) for $start, $end;

- $start->add_properties(
- summary => "Start: ".$t->Subject,
- dtstart => [.$starttime->iCal( Time => 0 ) => { value => 'DATE' }],
- dtend => [$starttime->iCal( Time => 0 ) => { value => 'DATE'}],
- );
- $end->add_properties(
- summary => "Due: ".$t->Subject,
- dtstart => [.$t->DueObj->iCal( Time => 0 ) => { value => 'DATE' }],
- dtend => [.$t->DueObj->iCal( Time => 0 ) => { value => 'DATE' }],
- );
-
- $feed->add_entry($start);
- $feed->add_entry($end);
+ my %time = ( Time => 0 );
+ my %ical_value = ( value => 'DATE' );
+
+ if ( RT->Config->Get('TimeInICal', $user) ){
+ $time{Time} = 1;
+ $ical_value{value} = 'DATE-TIME';
+ }
+
+ if( $ARGS{SingleEvent} ){
+ $start->add_properties(
+ summary => $t->Subject,
+ dtstart => [$starttime->iCal( %time ) => \%ical_value ],
+ dtend => [$t->DueObj->iCal( %time ) => \%ical_value ],
+ );
+ $feed->add_entry($start);
+ }
+ else{
+ $start->add_properties(
+ summary => "Start: ".$t->Subject,
+ dtstart => [$starttime->iCal( %time ) => \%ical_value ],
+ dtend => [$starttime->iCal( %time ) => \%ical_value ],
+ );
+ $end->add_properties(
+ summary => "Due: ".$t->Subject,
+ dtstart => [$t->DueObj->iCal( %time ) => \%ical_value ],
+ dtend => [$t->DueObj->iCal( %time ) => \%ical_value ],
+ );
+
+ $feed->add_entry($start);
+ $feed->add_entry($end);
+ }
}

$m->clear_buffer;
diff --git a/t/web/search_ical.t b/t/web/search_ical.t
new file mode 100644
index 0000000..4a0713d
--- /dev/null
+++ b/t/web/search_ical.t
@@ -0,0 +1,147 @@
+#!/usr/bin/perl
+
+use strict;
+
+use Data::ICal;
+use RT::Test tests => 56;
+
+my $start_obj = RT::Date->new( RT->SystemUser );
+$start_obj->SetToNow;
+my $start = $start_obj->iCal( Time => 1);
+
+my $due_obj = RT::Date->new( RT->SystemUser );
+$due_obj->SetToNow;
+$due_obj->AddDays(2);
+my $due = $due_obj->iCal( Time => 1);
+
+diag 'Test iCal with date only';
+{
+ my ($baseurl, $agent) = RT::Test->started_ok;
+
+ my $ticket = RT::Ticket->new(RT->SystemUser);
+
+ for ( 1 .. 5 ) {
+ $ticket->Create(
+ Subject => 'Ticket ' . $_,
+ Queue => 'General',
+ Owner => 'root',
+ Requestor => 'ical [at] localhos',
+ Starts => $start_obj->ISO,
+ Due => $due_obj->ISO,
+ );
+ }
+
+ ok $agent->login('root', 'password'), 'logged in as root';
+
+ $agent->get_ok('/Search/Build.html');
+ $agent->form_name('BuildQuery');
+ $agent->field('idOp', '>');
+ $agent->field('ValueOfid', '0');
+ $agent->submit('DoSearch');
+ $agent->follow_link_ok({id => 'page-results'});
+
+ for ( 1 .. 5 ) {
+ $agent->content_contains('Ticket ' . $_);
+ }
+
+ $agent->follow_link_ok( { text => 'iCal' } );
+
+ is( $agent->content_type, 'text/calendar', 'content type is text/calendar' );
+
+ for ( 1 .. 5 ) {
+ $agent->content_like(qr/URL\:$baseurl\/\?q=$_/);
+ }
+
+ my $ical = Data::ICal->new(data => $agent->content);
+
+ my @entries = $ical->entries;
+ my $ical_count = @{$entries[0]};
+ is( $ical_count, 10, "Got $ical_count ical entries");
+
+ my $prop_ref = $entries[0]->[0]->properties;
+ my $start = $start_obj->ISO( Time => 0);
+ $start =~ s/-//g;
+ is($prop_ref->{'dtstart'}->[0]->value, $start, "Got start date: $start");
+ like( $prop_ref->{'dtstart'}->[0]->as_string, qr/VALUE=DATE\:/, 'Got DATE value');
+
+ $prop_ref = $entries[0]->[1]->properties;
+ my $due = $due_obj->ISO( Time => 0);
+ $due =~ s/-//g;
+ is($prop_ref->{'dtend'}->[0]->value, $due, "Got due date: $due");
+ like( $prop_ref->{'dtend'}->[0]->as_string, qr/VALUE=DATE\:/, 'Got DATE value');
+}
+
+RT::Test->stop_server;
+
+diag 'Test iCal with date and time';
+{
+ RT->Config->Set(TimeInICal =>1);
+ my ($baseurl, $agent) = RT::Test->started_ok;
+
+ ok $agent->login('root', 'password'), 'logged in as root';
+
+ $agent->get_ok('/Search/Build.html');
+ $agent->form_name('BuildQuery');
+ $agent->field('idOp', '>');
+ $agent->field('ValueOfid', '0');
+ $agent->submit('DoSearch');
+ $agent->follow_link_ok({id => 'page-results'});
+
+ for ( 1 .. 5 ) {
+ $agent->content_contains('Ticket ' . $_);
+ }
+
+ my $link = $agent->find_link( text => 'iCal' ); # use $link later
+ $agent->get_ok($link->url);
+
+ is( $agent->content_type, 'text/calendar', 'content type is text/calendar' );
+
+ for ( 1 .. 5 ) {
+ $agent->content_like(qr/URL\:$baseurl\/\?q=$_/);
+ }
+
+ my $ical = Data::ICal->new(data => $agent->content);
+
+ my @entries = $ical->entries;
+ my $ical_count = @{$entries[0]};
+ is( $ical_count, 10, "Got $ical_count ical entries");
+
+ my $prop_ref = $entries[0]->[0]->properties;
+ $start =~ s/-//g;
+ is($prop_ref->{'dtstart'}->[0]->value, $start, "Got start date with time: $start");
+ like( $prop_ref->{'dtstart'}->[0]->as_string, qr/VALUE=DATE-TIME\:/, 'Got DATE-TIME value');
+
+ $prop_ref = $entries[0]->[1]->properties;
+ $due =~ s/-//g;
+ is($prop_ref->{'dtend'}->[0]->value, $due, "Got due date with time: $due");
+ like( $prop_ref->{'dtend'}->[0]->as_string, qr/VALUE=DATE-TIME\:/, 'Got DATE-TIME value');
+
+ diag 'Test iCal with date and time in single events';
+
+ my $url = $link->url . '?SingleEvent=1';
+ $agent->get_ok($url);
+
+ is( $agent->content_type, 'text/calendar', 'content type is text/calendar' );
+
+ for ( 1 .. 5 ) {
+ $agent->content_like(qr/URL\:$baseurl\/\?q=$_/);
+ }
+
+ $ical = Data::ICal->new(data => $agent->content);
+
+ @entries = $ical->entries;
+ $ical_count = @{$entries[0]};
+
+ # Only 5 entries in single event mode
+ is( $ical_count, 5, "Got $ical_count ical entries");
+
+ $prop_ref = $entries[0]->[0]->properties;
+ $start =~ s/-//g;
+ is($prop_ref->{'dtstart'}->[0]->value, $start, "Got start date with time: $start");
+ like( $prop_ref->{'dtstart'}->[0]->as_string, qr/VALUE=DATE-TIME\:/, 'Got DATE-TIME value');
+
+ $prop_ref = $entries[0]->[1]->properties;
+ $due =~ s/-//g;
+ is($prop_ref->{'dtend'}->[0]->value, $due, "Got due date with time: $due");
+ like( $prop_ref->{'dtend'}->[0]->as_string, qr/VALUE=DATE-TIME\:/, 'Got DATE-TIME value');
+}

-----------------------------------------------------------------------
_______________________________________________
Rt-commit mailing list
Rt-commit [at] lists
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit

Request Tracker commit RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.