diff options
author | Yorhel <git@yorhel.nl> | 2019-11-02 11:09:38 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-11-02 11:25:55 +0100 |
commit | f4253cd0472fd077d33f536a78f6d255907b1cfc (patch) | |
tree | 5b75e44ff4ede3f3052c10219f98b72eac9134de /lib/VNDB | |
parent | 2cd005791529c6501901ac2bc0a7752f88fa7481 (diff) |
Add character age field + conversion
Diffstat (limited to 'lib/VNDB')
-rw-r--r-- | lib/VNDB/DB/Chars.pm | 6 | ||||
-rw-r--r-- | lib/VNDB/Handler/Chars.pm | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/VNDB/DB/Chars.pm b/lib/VNDB/DB/Chars.pm index d5078a1d..a93ad28c 100644 --- a/lib/VNDB/DB/Chars.pm +++ b/lib/VNDB/DB/Chars.pm @@ -71,7 +71,7 @@ sub dbCharGet { ); my @select = (qw|c.id c.name c.original c.gender|); - push @select, qw|c.hidden c.locked c.alias c.desc c.image c.b_month c.b_day c.s_bust c.s_waist c.s_hip c.height c.weight c.bloodt c.cup_size c.main c.main_spoil| if $o{what} =~ /extended/; + push @select, qw|c.hidden c.locked c.alias c.desc c.image c.b_month c.b_day c.s_bust c.s_waist c.s_hip c.height c.weight c.bloodt c.cup_size c.age c.main c.main_spoil| if $o{what} =~ /extended/; my($r, $np) = $self->dbPage(\%o, q| SELECT !s @@ -94,7 +94,7 @@ sub dbCharGetRev { my $select = 'c.itemid AS id, ch.name, ch.original, ch.gender'; $select .= ', extract(\'epoch\' from c.added) as added, c.comments, c.rev, c.ihid, c.ilock, '.VNWeb::DB::sql_user(); $select .= ', c.id AS cid, NOT EXISTS(SELECT 1 FROM changes c2 WHERE c2.type = c.type AND c2.itemid = c.itemid AND c2.rev = c.rev+1) AS lastrev'; - $select .= ', ch.alias, ch.desc, ch.image, ch.b_month, ch.b_day, ch.s_bust, ch.s_waist, ch.s_hip, ch.height, ch.weight, ch.bloodt, ch.cup_size, ch.main, ch.main_spoil, co.hidden, co.locked' if $o{what} =~ /extended/; + $select .= ', ch.alias, ch.desc, ch.image, ch.b_month, ch.b_day, ch.s_bust, ch.s_waist, ch.s_hip, ch.height, ch.weight, ch.bloodt, ch.cup_size, ch.age, ch.main, ch.main_spoil, co.hidden, co.locked' if $o{what} =~ /extended/; my $r = $self->dbAll(q| SELECT !s @@ -177,7 +177,7 @@ sub dbCharRevisionInsert { my($self, $o) = @_; my %set = map exists($o->{$_}) ? (qq|"$_" = ?|, $o->{$_}) : (), - qw|name original alias desc image b_month b_day s_bust s_waist s_hip height weight bloodt cup_size gender main main_spoil|; + qw|name original alias desc image b_month b_day s_bust s_waist s_hip height weight bloodt cup_size age gender main main_spoil|; $self->dbExec('UPDATE edit_chars !H', \%set) if keys %set; if($o->{traits}) { diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm index 1fb0feb6..656dda04 100644 --- a/lib/VNDB/Handler/Chars.pm +++ b/lib/VNDB/Handler/Chars.pm @@ -57,6 +57,7 @@ sub page { [ weight => 'Weight', serialize => sub { $_[0]//'[empty]' } ], [ bloodt => 'Blood type', serialize => sub { $BLOOD_TYPE{$_[0]} } ], [ cup_size => 'Cup size', serialize => sub { $CUP_SIZE{$_[0]} } ], + [ age => 'Age', serialize => sub { $_[0]//'[empty]' } ], [ main => 'Main character',htmlize => sub { $_[0] ? sprintf '<a href="/c%d">c%d</a>', $_[0], $_[0] : '[empty]' } ], [ main_spoil=> 'Spoiler', serialize => \&fmtspoil ], [ image => 'Image', htmlize => sub { @@ -189,6 +190,12 @@ sub charTable { td $r->{b_day}.' '.[qw{January February March April May June July August September October November December}]->[$r->{b_month}-1]; end; } + if(defined $r->{age}) { + Tr; + td class => 'key', 'Age'; + td $r->{age}; + end; + } # traits my %groups; @@ -305,7 +312,7 @@ sub edit { || $id && (($r->{locked} || $r->{hidden}) && !$self->authCan('dbmod')); my %b4 = !$id ? () : ( - (map +($_ => $r->{$_}), qw|name original alias desc image ihid ilock s_bust s_waist s_hip height weight bloodt cup_size gender main_spoil|), + (map +($_ => $r->{$_}), qw|name original alias desc image ihid ilock s_bust s_waist s_hip height weight bloodt cup_size age gender main_spoil|), main => $r->{main}||0, bday => $r->{b_month} ? sprintf('%02d-%02d', $r->{b_month}, $r->{b_day}) : '', traits => join(' ', map sprintf('%d-%d', $_->{tid}, $_->{spoil}), sort { $a->{tid} <=> $b->{tid} } @{$r->{traits}}), @@ -331,6 +338,7 @@ sub edit { { post => 'weight', required => 0, default => undef, template => 'uint', max => 32767 }, { post => 'bloodt', required => 0, default => 'unknown', enum => [ keys %BLOOD_TYPE ] }, { post => 'cup_size', required => 0, default => '', enum => [ keys %CUP_SIZE ] }, + { post => 'age', required => 0, default => undef, template => 'uint', max => 32767 }, { post => 'main', required => 0, default => 0, template => 'id' }, { 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.' ] }, @@ -410,6 +418,7 @@ sub edit { [ select => name => 'Sex', short => 'gender', options => [ map [ $_, $GENDER{$_} ], keys %GENDER ] ], [ input => name => 'Birthday', short => 'bday', width => 100,post => ' MM-DD (e.g. "01-26" for the 26th of January)' ], + [ input => name => 'Age', short => 'age', width => 50, post => ' years', allow0 => 1 ], [ input => name => 'Bust', short => 's_bust', width => 50, post => ' cm' ], [ input => name => 'Waist', short => 's_waist',width => 50, post => ' cm' ], [ input => name => 'Hips', short => 's_hip', width => 50, post => ' cm' ], |