Changeset 915


Ignore:
Timestamp:
Apr 27, 2018, 3:28:45 PM (3 years ago)
Author:
Kris Deugau
Message:

/trunk

Start adding a generalized in-your-face infonotice space to attach warnings
to a netblock. See #17 and #23, sort of.

  • table to hold the notices, since they're likely to be far fewer than the overall allocation count
  • show any notices for the parent chain for new allocations in the admin tools
Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r913 r915  
    3535        &getBlockRDNS &getRDNSbyIP &getRevID
    3636        &getNodeList &getNodeName &getNodeInfo
     37        &getBlockNotices
    3738        &mailNotify
    3839        );
     
    5152                &getBlockRDNS &getRDNSbyIP &getRevID
    5253                &getNodeList &getNodeName &getNodeInfo
     54                &getBlockNotices
    5355                &mailNotify
    5456                )]
     
    35533555
    35543556
     3557## IPDB::getBlockNotices()
     3558# Retrieve any infonotes for a block and all of its parents
     3559# Takes the block ID to trace down the stack
     3560# Returns an arrayref to the block and all of its parents, containing the CIDR,
     3561# description, and notice (if any) associated to each block.
     3562sub getBlockNotices {
     3563  my $dbh = shift;
     3564  my $bid = shift;
     3565  my $nlist = $dbh->selectall_arrayref(q(
     3566        WITH RECURSIVE blockparents (id, cidr, description, parent_id, notice, depth) AS (
     3567                SELECT a.id, a.cidr, a.description, a.parent_id, bn.notice, 1 AS depth FROM allocations a
     3568                LEFT JOIN blocknotices bn ON a.id = bn.alloc_id
     3569                WHERE a.id = ?
     3570                UNION
     3571                SELECT b.id, b.cidr, b.description, b.parent_id, bn2.notice, t.depth AS depth FROM allocations b
     3572                JOIN blockparents t ON t.parent_id = b.id
     3573                LEFT JOIN blocknotices bn2 ON b.id = bn2.alloc_id
     3574        ) SELECT id, cidr, description, parent_id, notice FROM blockparents ORDER BY depth DESC;
     3575), {Slice=>{}}, $bid);
     3576
     3577  return $nlist;
     3578} # end getBlockNotices()
     3579
     3580
    35553581## IPDB::mailNotify()
    35563582# Sends notification mail to recipients regarding an IPDB operation
  • trunk/cgi-bin/admin.cgi

    r906 r915  
    149149  ($fbid, $fb, $fbparent) = findAllocateFrom($ip_dbh, $maskbits, $webvar{alloctype}, '','',
    150150        (gimme => "$cidr", allowpriv => 1));
     151
     152  # retrieve any notices
     153  my $nlist = getBlockNotices($ip_dbh, $fbparent);
     154  my @notices;
     155  foreach (@$nlist) {
     156    push @notices, $_->{notice} if $_->{notice};
     157  }
     158  my $blockmsg = join("<br>\n", @notices);
     159  $page->param(blockmsg => $blockmsg);
     160
    151161  $page->param(fbid => $fbid);
    152162  $page->param(parid => $fbparent);
     
    205215    goto ERRJUMP;
    206216  }
     217
     218  # retrieve any notices
     219  my $nlist = getBlockNotices($ip_dbh, $webvar{parent});
     220  my @notices;
     221  foreach (@$nlist) {
     222    push @notices, $_->{notice} if $_->{notice};
     223  }
     224  my $blockmsg = join("<br>\n", @notices);
     225  $page->param(blockmsg => $blockmsg);
    207226
    208227  my ($retcode,$msg) = allocateBlock($ip_dbh, cidr => $webvar{cidr}, fbid => $webvar{fbid},
  • trunk/cgi-bin/ipdb.psql

    r865 r915  
    116116ALTER TABLE ONLY freeblocks
    117117    ADD CONSTRAINT freeblocks_pkey PRIMARY KEY (cidr, parent_id);
     118
     119-- Table for arbitrary infonotices tagged to an allocation
     120CREATE TABLE blocknotices (
     121    alloc_id integer NOT NULL,
     122    ipflag boolean DEFAULT false NOT NULL,
     123    notice text DEFAULT ''::text NOT NULL
     124);
     125
     126ALTER TABLE ONLY blocknotices
     127    ADD CONSTRAINT blocknotices_pkey PRIMARY KEY (alloc_id, ipflag);
    118128
    119129-- Network nodes - allows finding customers affected by a broken <x> quickly
  • trunk/templates/admin/alloc.tmpl

    r642 r915  
     1<TMPL_IF blockmsg><br><div class="strongwarning blockcenter w70"><TMPL_VAR NAME=blockmsg></div><br></TMPL_IF>
     2
    13<TMPL_IF errmsg>
    24<TMPL_VAR NAME=errmsg>
  • trunk/templates/admin/confirm.tmpl

    r517 r915  
     1<TMPL_IF blockmsg><br><div class="strongwarning blockcenter w70"><TMPL_VAR NAME=blockmsg></div><br></TMPL_IF>
     2
    13<TMPL_IF locerr>
    24<TMPL_VAR NAME=locerr>
Note: See TracChangeset for help on using the changeset viewer.