summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-03-23 16:35:02 +0100
committerYorhel <git@yorhel.nl>2021-03-23 16:35:04 +0100
commit72ae93702f23083d54cb2e1922cbee1caebe7252 (patch)
treecdbb80132cdb6749da061d55b936537fe08c4d24
parent5914360c90ee0a8bf6adc365ba8e80abcae0cf89 (diff)
HTML: Use hiddenmsg for tags/traits and to display awaiting moderation state
This also fixes the issue that the reason for deletion is not displayed if it's in the message of the last change, which is the case for newly rejected tags/traits. The edit message is not displayed if the entry was deleted in the first revision, as that's most likely an import.
-rw-r--r--lib/VNWeb/HTML.pm31
-rw-r--r--lib/VNWeb/TT/TagPage.pm18
-rw-r--r--lib/VNWeb/TT/TraitPage.pm18
3 files changed, 26 insertions, 41 deletions
diff --git a/lib/VNWeb/HTML.pm b/lib/VNWeb/HTML.pm
index ae615d02..92e976d6 100644
--- a/lib/VNWeb/HTML.pm
+++ b/lib/VNWeb/HTML.pm
@@ -439,11 +439,26 @@ sub _board_id {
sub _hidden_msg_ {
my $o = shift;
- die "Can't use hiddenmsg on an object that is missing 'entry_hidden'" if !exists $o->{dbobj}{entry_hidden};
+ die "Can't use hiddenmsg on an object that is missing 'entry_hidden' or 'entry_locked'"
+ if !exists $o->{dbobj}{entry_hidden} || !exists $o->{dbobj}{entry_locked};
+
return 0 if !$o->{dbobj}{entry_hidden};
- my $msg = tuwf->dbVali(
- 'SELECT comments
+ # Awaiting moderation
+ if(!$o->{dbobj}{entry_locked}) {
+ div_ class => 'mainbox', sub {
+ h1_ $o->{title};
+ div_ class => 'notice', sub {
+ h2_ 'Waiting for approval';
+ p_ 'This entry is waiting for a moderator to approve it.';
+ }
+ };
+ return 0;
+ }
+
+ # Deleted.
+ my $msg = tuwf->dbRowi(
+ 'SELECT comments, rev
FROM changes
WHERE itemid =', \$o->{dbobj}{id},
'ORDER BY id DESC LIMIT 1'
@@ -462,13 +477,15 @@ sub _hidden_msg_ {
txt_ 'This item has been deleted from the database. You may file a request on the ';
a_ href => '/t/'._board_id($o->{type}, $o->{dbobj}), "discussion board";
txt_ ' if you believe that this entry should be restored.';
- br_;
- br_;
- lit_ bb_format $msg;
+ if($msg->{rev} > 1) {
+ br_;
+ br_;
+ lit_ bb_format $msg->{comments};
+ }
}
}
};
- !auth->permDbmod # dbmods can still see the page
+ $o->{dbobj}{id} !~ /^[gi]/ && !auth->permDbmod # tags/traits are still visible, dbmods can still see all pages
}
diff --git a/lib/VNWeb/TT/TagPage.pm b/lib/VNWeb/TT/TagPage.pm
index 42c1546a..819a6bd1 100644
--- a/lib/VNWeb/TT/TagPage.pm
+++ b/lib/VNWeb/TT/TagPage.pm
@@ -34,22 +34,6 @@ sub infobox_ {
h1_ "Tag: $t->{name}";
debug_ $t;
- div_ class => 'warning', sub {
- h2_ 'Tag deleted';
- p_ sub {
- txt_ 'This tag has been removed from the database, and cannot be used or re-added.';
- br_;
- txt_ 'File a request on the ';
- a_ href => '/t/db', 'discussion board';
- txt_ ' if you disagree with this.';
- }
- } if $t->{hidden} && $t->{locked};
-
- div_ class => 'notice', sub {
- h2_ 'Waiting for approval';
- p_ 'This tag is waiting for a moderator to approve it. You can still use it to tag VNs as you would with a normal tag.';
- } if $t->{hidden} && !$t->{locked};
-
parents_ g => $t;
div_ class => 'description', sub {
@@ -159,7 +143,7 @@ TUWF::get qr{/$RE{grev}}, sub {
my $t = db_entry tuwf->captures('id', 'rev');
return tuwf->resNotFound if !$t->{id};
- framework_ index => !tuwf->capture('rev'), title => "Tag: $t->{name}", dbobj => $t, sub {
+ framework_ index => !tuwf->capture('rev'), title => "Tag: $t->{name}", dbobj => $t, hiddenmsg => 1, sub {
rev_ $t if tuwf->capture('rev');
div_ class => 'mainbox', sub { infobox_ $t; };
tree_ g => $t->{id};
diff --git a/lib/VNWeb/TT/TraitPage.pm b/lib/VNWeb/TT/TraitPage.pm
index bb72b755..a759eb6b 100644
--- a/lib/VNWeb/TT/TraitPage.pm
+++ b/lib/VNWeb/TT/TraitPage.pm
@@ -35,22 +35,6 @@ sub infobox_ {
h1_ "Trait: $t->{name}";
debug_ $t;
- div_ class => 'warning', sub {
- h2_ 'Trait deleted';
- p_ sub {
- txt_ 'This trait has been removed from the database, and cannot be used or re-added.';
- br_;
- txt_ 'File a request on the ';
- a_ href => '/t/db', 'discussion board';
- txt_ ' if you disagree with this.';
- }
- } if $t->{hidden} && $t->{locked};
-
- div_ class => 'notice', sub {
- h2_ 'Waiting for approval';
- p_ 'This trait is waiting for a moderator to approve it.';
- } if $t->{hidden} && !$t->{locked};
-
parents_ i => $t;
div_ class => 'description', sub {
@@ -143,7 +127,7 @@ TUWF::get qr{/$RE{irev}}, sub {
my $t = db_entry tuwf->captures('id', 'rev');
return tuwf->resNotFound if !$t->{id};
- framework_ index => !$t->{hidden}, title => "Trait: $t->{name}", dbobj => $t, sub {
+ framework_ index => !$t->{hidden}, title => "Trait: $t->{name}", dbobj => $t, hiddenmsg => 1, sub {
rev_ $t if tuwf->capture('rev');
div_ class => 'mainbox', sub { infobox_ $t; };
tree_ i => $t->{id};