summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/Producers.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-11-13 20:35:13 +0100
committerYorhel <git@yorhel.nl>2008-11-13 20:35:13 +0100
commit84c702bab88b4cdf6e74381ea228faf2672195fa (patch)
tree38b364e430bd04a5e126bf0c81361eaa245264f9 /lib/VNDB/Handler/Producers.pm
parenta6934dcc72b6723fefa2f1401e66fe6a97f3ec43 (diff)
W00t, producer editing works!
Though there's no diff viewer or revision browser yet, so you can't really see the changelog itself
Diffstat (limited to 'lib/VNDB/Handler/Producers.pm')
-rw-r--r--lib/VNDB/Handler/Producers.pm19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 5bd8d782..c221dc0b 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -8,14 +8,14 @@ use VNDB::Func;
YAWF::register(
- qr{p([1-9]\d*)} => \&page,
- qr{p([1-9]\d*)/edit} => \&edit,
- qr{p([1-9]\d*)/(lock|hide)} => \&mod,
+ qr{p([1-9]\d*)(?:\.([1-9]\d*))} => \&page,
+ qr{p([1-9]\d*)/edit} => \&edit,
+ qr{p([1-9]\d*)/(lock|hide)} => \&mod,
);
sub page {
- my($self, $pid) = @_;
+ my($self, $pid, $rev) = @_;
my $p = $self->dbProducerGet(id => $pid, what => 'vn')->[0];
return 404 if !$p->{id};
@@ -72,6 +72,7 @@ sub edit {
my %b4 = map { $_ => $p->{$_} } qw|type name original lang website desc|;
my $frm;
+
if($self->reqMethod eq 'POST') {
$frm = $self->formValidate(
{ name => 'type', enum => [ keys %{$self->{producer_types}} ] },
@@ -82,6 +83,16 @@ sub edit {
{ name => 'desc', required => 0, maxlength => 5000, default => '' },
{ name => 'editsum', maxlength => 5000 },
);
+ if(!$frm->{_err}) {
+ return $self->resRedirect("/p$pid", 'post')
+ if !grep $frm->{$_} ne $b4{$_}, keys %b4;
+
+ my($rev) = $self->dbProducerEdit($pid, %$frm);
+
+ # TODO: message Multi with an ircnotify
+
+ return $self->resRedirect("/p$pid.$rev", 'post');
+ }
}
!defined $frm->{$_} && ($frm->{$_} = $b4{$_}) for keys %b4;