Skip to content

Commit

Permalink
[change] Move task files to task/ subdirectories. Previously list_tas…
Browse files Browse the repository at this point in the history
…k_models/ and global_task_models/ directories were used. Task files in older directories will be automatically copied to new places during upgrading process.
  • Loading branch information
ikedas committed Aug 14, 2018
1 parent c888fa0 commit 1beb36b
Show file tree
Hide file tree
Showing 35 changed files with 81 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ installconfig: installdir sympa_wizard.pl.inst
chgrp $(GROUP) data_structure.version; \
fi
-@for dir in create_list_templates custom_actions custom_conditions \
data_sources families global_task_models list_task_models \
data_sources families tasks \
mail_tt2 scenari search_filters web_tt2; do \
if [ ! -d $(DESTDIR)$(sysconfdir)/$$dir ] ; then \
echo "Creating $(DESTDIR)$(sysconfdir)/$$dir"; \
Expand Down
36 changes: 18 additions & 18 deletions default/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,6 @@ nobase_default_DATA = \
create_list_templates/private_working_group/config.tt2 \
create_list_templates/public_web_forum/comment.tt2 \
create_list_templates/public_web_forum/config.tt2 \
global_task_models/eval_bouncers.daily.task \
global_task_models/expire_bounce.daily.task \
global_task_models/process_bouncers.weekly.task \
global_task_models/purge_logs_table.daily.task \
global_task_models/purge_one_time_ticket_table.daily.task \
global_task_models/purge_orphan_bounces.monthly.task \
global_task_models/purge_session_table.daily.task \
global_task_models/purge_spools.daily.task \
global_task_models/purge_tables.daily.task \
global_task_models/purge_user_table.monthly.task \
list_task_models/remind.2month.task \
list_task_models/remind.3month.task \
list_task_models/remind.4month.task \
list_task_models/remind.6month.task \
list_task_models/remind.9month.task \
list_task_models/remind.monthly.task \
list_task_models/remind.yearly.task \
list_task_models/sync_include.ttl.task \
scenari/add.auth \
scenari/add.authdkim \
scenari/add.closed \
Expand Down Expand Up @@ -187,6 +169,24 @@ nobase_default_DATA = \
scenari/visibility.intranet \
scenari/visibility.noconceal \
scenari/visibility.secret \
tasks/eval_bouncers.daily.task \
tasks/expire_bounce.daily.task \
tasks/process_bouncers.weekly.task \
tasks/purge_logs_table.daily.task \
tasks/purge_one_time_ticket_table.daily.task \
tasks/purge_orphan_bounces.monthly.task \
tasks/purge_session_table.daily.task \
tasks/purge_spools.daily.task \
tasks/purge_tables.daily.task \
tasks/purge_user_table.monthly.task \
tasks/remind.2month.task \
tasks/remind.3month.task \
tasks/remind.4month.task \
tasks/remind.6month.task \
tasks/remind.9month.task \
tasks/remind.monthly.task \
tasks/remind.yearly.task \
tasks/sync_include.ttl.task \
web_tt2/active_lists.tt2 \
web_tt2/admin.tt2 \
web_tt2/ajax.tt2 \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion po/sympa/Makefile.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
default/web_tt2/*.tt2 default/mail_tt2/*.tt2 \
default/mhonarc-ressources.tt2 default/topics.conf \
default/scenari/* \
default/global_task_models/* default/list_task_models/* \
default/tasks/* \
default/create_list_templates/*/* \
ext/*/lib/Sympa/*.pm \
ext/*/lib/Sympa/*/tt2/*.tt2 ext/*/lib/Sympa/*/*/tt2/*.tt2;\
Expand Down
32 changes: 16 additions & 16 deletions po/sympa/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ default/create_list_templates/private_working_group/comment.tt2
default/create_list_templates/private_working_group/config.tt2
default/create_list_templates/public_web_forum/comment.tt2
default/create_list_templates/public_web_forum/config.tt2
#default/global_task_models/chk_cert_expiration.daily.task
#default/global_task_models/crl_update.daily.task
default/global_task_models/eval_bouncers.daily.task
default/global_task_models/expire_bounce.daily.task
default/global_task_models/process_bouncers.weekly.task
default/global_task_models/purge_logs_table.daily.task
default/global_task_models/purge_one_time_ticket_table.daily.task
default/global_task_models/purge_orphan_bounces.monthly.task
default/global_task_models/purge_session_table.daily.task
default/global_task_models/purge_tables.daily.task
default/global_task_models/purge_user_table.monthly.task
#default/list_task_models/expire.yearly.task
default/list_task_models/remind.2month.task
default/list_task_models/remind.monthly.task
default/list_task_models/remind.yearly.task
default/list_task_models/sync_include.ttl.task
##default/global_task_models/chk_cert_expiration.daily.task
##default/global_task_models/crl_update.daily.task
#default/global_task_models/eval_bouncers.daily.task
#default/global_task_models/expire_bounce.daily.task
#default/global_task_models/process_bouncers.weekly.task
#default/global_task_models/purge_logs_table.daily.task
#default/global_task_models/purge_one_time_ticket_table.daily.task
#default/global_task_models/purge_orphan_bounces.monthly.task
#default/global_task_models/purge_session_table.daily.task
#default/global_task_models/purge_tables.daily.task
#default/global_task_models/purge_user_table.monthly.task
##default/list_task_models/expire.yearly.task
#default/list_task_models/remind.2month.task
#default/list_task_models/remind.monthly.task
#default/list_task_models/remind.yearly.task
#default/list_task_models/sync_include.ttl.task
default/mhonarc-ressources.tt2
default/scenari/archive_web_access.closed
default/scenari/archive_web_access.intranet
Expand Down
3 changes: 1 addition & 2 deletions src/cgi/wwsympa.fcgi.in
Original file line number Diff line number Diff line change
Expand Up @@ -11069,8 +11069,7 @@ sub _do_edit_list_request {
}
$pitem->{format} = $list_of_scenario;
} elsif ($pitem->{task}) {
my $list_of_task =
$list->load_task_list($pitem->{task}, $robot);
my $list_of_task = $list->load_task_list($pitem->{task});
$pitem->{format} = $list_of_task;
} elsif ($pitem->{datasource}) {
my $list_of_data_sources = $list->load_data_sources_list($robot);
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Sympa/List.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4312,13 +4312,13 @@ sub load_scenario_list {
}

sub load_task_list {
my ($self, $action, $robot) = @_;
$log->syslog('debug2', '(%s, %s)', $action, $robot);
$log->syslog('debug2', '(%s, %s)', @_);
my $self = shift;
my $action = shift;

my %list_of_task;

foreach my $dir (
@{Sympa::get_search_path($self, subdir => 'list_task_models')}) {
foreach my $dir (@{Sympa::get_search_path($self, subdir => 'tasks')}) {
next unless (-d $dir);

LOOP_FOREACH_FILE:
Expand Down
13 changes: 3 additions & 10 deletions src/lib/Sympa/Task.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ sub new {
die 'bug in logic. Ask developer'
unless defined $options{model} and length $options{model};
$options{context} = '*'
unless ref $options{context} eq 'Sympa::List'; #FIXME
unless ref $options{context} eq 'Sympa::List'; #FIXME
$options{date} = time
unless defined $options{date};
$options{label} = ($options{model} eq 'sync_include') ? 'INIT' : ''
Expand Down Expand Up @@ -105,15 +105,8 @@ sub new {
}

my $model_name = sprintf '%s.%s.task', $model, $name;
my $model_file = Sympa::search_fullpath(
$that,
$model_name,
subdir => (
(ref $that eq 'Sympa::List')
? 'list_task_models'
: 'global_task_models'
)
);
my $model_file =
Sympa::search_fullpath($that, $model_name, subdir => 'tasks');
unless ($model_file) {
$log->syslog('err', 'Unable to find task file %s for %s',
$model_name, $that);
Expand Down
28 changes: 28 additions & 0 deletions src/lib/Sympa/Upgrade.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,34 @@ sub upgrade {
}
}

# Task files are moved.
if (lower_version($previous_version, '6.2.35b.1')) {
my $sitedir = $Conf::Conf{'etc'};
my @robotdirs =
map { $Conf::Conf{'etc'} . '/' . $_ } Sympa::List::get_robots();
my @listdirs =
map { $_->{'dir'} } @{Sympa::List::get_lists('*') || []};

my $model_dir = $sitedir . '/global_task_models';
if (-e $model_dir) {
my $task_dir = $sitedir . '/tasks';
unless (Sympa::Tools::File::copy_dir($model_dir, $task_dir)) {
$log->syslog('err', 'Unable to copy %s to %s',
$model_dir, $task_dir);
}
}
foreach my $dir (($sitedir, @robotdirs, @listdirs)) {
my $model_dir = $dir . '/list_task_models';
if (-e $model_dir) {
my $task_dir = $dir . '/tasks';
unless (Sympa::Tools::File::copy_dir($model_dir, $task_dir)) {
$log->syslog('err', 'Unable to copy %s to %s',
$model_dir, $task_dir);
}
}
}
}

return 1;
}

Expand Down
21 changes: 9 additions & 12 deletions t/parse_templates.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,33 @@ use XML::LibXML;
use Sympa::Template;

my $params = {
all_lists => {size => 2},
languages => {size => 2},
total_group => 2,
rows => 2,
reply_to_header => {value => 'all', other_email => 'xxx@xxx',},
all_lists => {size => 2},
languages => {size => 2},
total_group => 2,
rows => 2,
reply_to_header => {value => 'all', other_email => 'xxx@xxx',},
list_request_date_epoch => 0,
tpl_lang => 'en',
current_subscriber => {lang => 'en'},
current_subscriber => {lang => 'en'},
};

my @def_tt2 = _templates('default', '*.tt2 sympa.wsdl');
my @list_tt2 = _templates('default/create_list_templates', '*/*.tt2');
my @mail_tt2 = _templates('default/mail_tt2', '*.tt2 */*.tt2');
my @web_tt2 = _templates('default/web_tt2', '*.tt2 */*.tt2');
my @g_task = _templates('default/global_task_models', '*.task');
my @l_task = _templates('default/list_task_models', '*.task');
my @tasks = _templates('default/tasks', '*.task');

plan tests => scalar @def_tt2 +
scalar @list_tt2 +
scalar @mail_tt2 +
scalar @web_tt2 +
scalar @g_task +
scalar @l_task;
scalar @tasks;

map { is _do_test('default', $_), '', $_ } @def_tt2;
map { is _do_test('default/create_list_templates', $_), '', $_ } @list_tt2;
map { is _do_test('default/mail_tt2', $_), '', $_ } @mail_tt2;
map { is _do_test('default/web_tt2', $_), '', $_ } @web_tt2;
map { is _do_test('default/global_task_models', $_, '[ ]'), '', $_ } @g_task;
map { is _do_test('default/list_task_models', $_, '[ ]'), '', $_ } @l_task;
map { is _do_test('default/tasks', $_, '[ ]'), '', $_ } @tasks;

sub _templates {
my $dir = shift;
Expand Down

0 comments on commit 1beb36b

Please sign in to comment.