summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-09-20 15:12:05 +0200
committerYorhel <git@yorhel.nl>2015-09-20 15:12:05 +0200
commitbb7a7cc178144457d401c3c6479a41788cf681dd (patch)
tree40bd705081da74c2e665d0c7552dad2c34bcb43c
parent28681f6b12b1d8958ae1d792bb831120530de15a (diff)
formValidate: Created templates for gtin and editsum fields
-rw-r--r--data/lang.txt36
-rw-r--r--lib/VNDB/Handler/Chars.pm3
-rw-r--r--lib/VNDB/Handler/Producers.pm3
-rw-r--r--lib/VNDB/Handler/Releases.pm6
-rw-r--r--lib/VNDB/Handler/Staff.pm3
-rw-r--r--lib/VNDB/Handler/VNEdit.pm3
-rw-r--r--lib/VNDB/Util/FormHTML.pm9
-rwxr-xr-xutil/vndb.pl3
8 files changed, 40 insertions, 26 deletions
diff --git a/data/lang.txt b/data/lang.txt
index b830712f..281b388d 100644
--- a/data/lang.txt
+++ b/data/lang.txt
@@ -16202,18 +16202,6 @@ tr : 24 saat içinde en fazla 5 başlık açabilirsiniz
uk : За 24 години можна створювати не більше, ніж 5 тредів
it : Puoi creare solo 5 discussioni al giorno
-:_formerr_e_badeditsum
-en : Please read [url,/d5.4,the guidelines] on how to use the edit summary.
-ru : Пожалуйста, прочтите [url,/d5.4,руководство] о том, как использовать поле "Суммарно о правке".
-cs : Prosíme, přečtěte si [url,/d5.4,doporučení] ohledně užívání úprav shrnutí.
-hu : Légyszíves olvasdd el a szerkesztési összegzés [url,/d5.4, útmutatóját].
-nl : Lees a.u.b. [url,/d5.4,de richtlijnen] over het gebruik van de samenvatting.
-de : Bitte lies [url,/d5.4,die Richtlinien] darüber, wie man die Zusammenfassung bearbeitet.
-es : Por favor lee [url,/d5.4,las normas] sobre como editar el mensaje.
-tr : Düzenleme özetinin kullanımı için lütfen [url,/d5.4,kılavuz] sayfasını okuyun.
-uk : Будь ласка, прочитайте [url,/d5.4,вказівки] про те, як використовувати «Сумарно по редагуванню»
-it : Leggi la [url,/d5.4,guida] su come usare il riepilogo modifica
-
:_formerr_e_mainchar
en : Invalid main character. Make sure the ID is correct, that the main character itself is not an instance of an other character, and that this entry is not used as a main character elsewhere.
ru : Неверный главный персонаж. Проверьте, что ID персонажа верный, сам персонаж не является воплощением какого-либо другого персонажа, и этот персонаж не используется в качестве главного где-нибудь ещё.
@@ -16394,6 +16382,30 @@ tr*: [_1] sadece küçük harfler, rakamlar ve tire içerebilir; ve bir harf ile
uk*: Поле [_1] може складатися лише з маленьких літер латинки, цифр і рисок, і має починатися з літери
it*: [_1] può avere solo caratteri minuscoli e trattini, e deve iniziare con una lettera
+:_formerr_tpl_gtin
+en : Invalid JAN/UPC/EAN
+ru*:
+cs*:
+hu*:
+nl*:
+de*:
+es*:
+tr*:
+uk*:
+it*:
+
+:_formerr_tpl_editsum
+en : Please read [url,/d5.4,the guidelines] on how to use the edit summary.
+ru : Пожалуйста, прочтите [url,/d5.4,руководство] о том, как использовать поле "Суммарно о правке".
+cs : Prosíme, přečtěte si [url,/d5.4,doporučení] ohledně užívání úprav shrnutí.
+hu : Légyszíves olvasdd el a szerkesztési összegzés [url,/d5.4, útmutatóját].
+nl : Lees a.u.b. [url,/d5.4,de richtlijnen] over het gebruik van de samenvatting.
+de : Bitte lies [url,/d5.4,die Richtlinien] darüber, wie man die Zusammenfassung bearbeitet.
+es : Por favor lee [url,/d5.4,las normas] sobre como editar el mensaje.
+tr : Düzenleme özetinin kullanımı için lütfen [url,/d5.4,kılavuz] sayfasını okuyun.
+uk : Будь ласка, прочитайте [url,/d5.4,вказівки] про те, як використовувати «Сумарно по редагуванню»
+it : Leggi la [url,/d5.4,guida] su come usare il riepilogo modifica
+
:_formerr_tpl_json
en : [_1]: Malformed staff data
ru*:
diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm
index b02bce5c..7171d506 100644
--- a/lib/VNDB/Handler/Chars.pm
+++ b/lib/VNDB/Handler/Chars.pm
@@ -302,11 +302,10 @@ sub edit {
{ post => 'main_spoil', required => 0, default => 0, enum => [ 0..2 ] },
{ post => 'traits', required => 0, default => '', regex => [ qr/^(?:[1-9]\d*-[0-2])(?: +[1-9]\d*-[0-2])*$/, 'Incorrect trait format.' ] },
{ post => 'vns', required => 0, default => '', regex => [ qr/^(?:[1-9]\d*-\d+-[0-2]-[a-z]+)(?: +[1-9]\d*-\d+-[0-2]-[a-z]+)*$/, 'Incorrect VN format.' ] },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{desc});
# handle image upload
$frm->{image} = _uploadimage($self, $frm);
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 8314af48..6369d4d1 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -226,11 +226,10 @@ sub edit {
{ post => 'l_wp', required => 0, maxlength => 150, default => '' },
{ post => 'desc', required => 0, maxlength => 5000, default => '' },
{ post => 'prodrelations', required => 0, maxlength => 5000, default => '' },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{desc});
if(!$frm->{_err}) {
# parse
my $relations = [ map { /^([a-z]+),([0-9]+),(.+)$/ && (!$pid || $2 != $pid) ? [ $1, $2, $3 ] : () } split /\|\|\|/, $frm->{prodrelations} ];
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 4c4e7d54..b06a62f3 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -304,8 +304,7 @@ sub edit {
{ post => 'doujin', required => 0, default => 0 },
{ post => 'title', maxlength => 250 },
{ post => 'original', required => 0, default => '', maxlength => 250 },
- { post => 'gtin', required => 0, default => '0',
- func => [ \&gtintype, 'Not a valid JAN/UPC/EAN code' ] },
+ { post => 'gtin', required => 0, default => '0', template => 'gtin' },
{ post => 'catalog', required => 0, default => '', maxlength => 50 },
{ post => 'languages', multi => 1, enum => $self->{languages} },
{ post => 'website', required => 0, default => '', maxlength => 250, template => 'weburl' },
@@ -320,12 +319,11 @@ sub edit {
{ post => 'ani_ero', required => 0, default => 0, enum => $self->{animated} },
{ post => 'producers', required => 0, default => '' },
{ post => 'vn', maxlength => 5000 },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{notes});
push @{$frm->{_err}}, [ 'released', 'required', 1 ] if !$frm->{released};
my($media, $producers, $new_vn);
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index 75a1a97e..52b2e1f1 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -210,11 +210,10 @@ sub edit {
{ post => 'l_twitter', required => 0, maxlength => 16, default => '', regex => [ qr/^\S+$/, mt('_staffe_form_tw_err') ] },
{ post => 'l_anidb', required => 0, template => 'id', default => undef },
{ post => 'aliases', required => 0, maxlength => 5000, default => '' },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{desc});
my $aliases = json_validate($frm, 'aliases',
{ field => 'name', required => 1, maxlength => 200 },
{ field => 'orig', required => 0, maxlength => 200, default => '' },
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index 5757f830..409c80cb 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -121,11 +121,10 @@ sub edit {
{ post => 'seiyuu', required => 0, default => '[]', maxlength => 5000 },
{ post => 'vnrelations', required => 0, default => '', maxlength => 5000 },
{ post => 'screenshots', required => 0, default => '', maxlength => 1000 },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', required => !$nosubmit, template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$nosubmit && (!$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{desc}));
my $raw_c = !$frm->{_err} && json_validate($frm, 'credits',
{ field => 'aid', required => 1, template => 'id' },
{ field => 'role', required => 1, enum => $self->{staff_roles} },
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index b994792e..a319ba42 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -31,13 +31,18 @@ sub htmlFormError {
next;
}
my($field, $type, $rule) = @$e;
- li mt '_formerr_required', $field if $type eq 'required';
+ if($type eq 'required') {
+ li; lit mt $field eq 'editsum' ?'_formerr_tpl_editsum' : '_formerr_required', $field; end;
+ }
li mt '_formerr_minlength', $field, $rule if $type eq 'minlength';
li mt '_formerr_maxlength', $field, $rule if $type eq 'maxlength';
li mt '_formerr_enum', $field, join ', ', @$rule if $type eq 'enum';
li mt '_formerr_wrongboard', $rule if $type eq 'wrongboard';
li $rule->[1] if $type eq 'func' || $type eq 'regex';
- li mt "_formerr_tpl_$rule", $field if $type eq 'template';
+ if($type eq 'template') {
+ $rule = 'int' if $rule eq 'num' || $rule eq 'uint';
+ li; lit mt "_formerr_tpl_$rule", $field; end;
+ }
if($type eq 'tagexists') {
li; lit mt '_formerr_tagexists', "/g$rule->{id}", $rule->{name}; end;
}
diff --git a/util/vndb.pl b/util/vndb.pl
index 88281da9..9a3663a9 100755
--- a/util/vndb.pl
+++ b/util/vndb.pl
@@ -17,6 +17,7 @@ use lib $ROOT.'/lib';
use TUWF ':html';
use VNDB::L10N;
+use VNDBUtil 'gtintype';
use SkinFile;
@@ -51,6 +52,8 @@ TUWF::set(
id => { template => 'uint', min => 1, max => 1<<40 },
page => { template => 'uint', max => 1000 },
uname => { regex => qr/^[a-z0-9-]*$/, minlength => 2, maxlength => 15 },
+ gtin => { func => \&gtintype },
+ editsum => { maxlength => 5000, minlength => 2 },
},
);
TUWF::load_recursive('VNDB::Util', 'VNDB::DB', 'VNDB::Handler');