From: Mischa POSLAWSKY Date: Sat, 13 Jun 2020 14:10:53 +0000 (+0200) Subject: word edit: record entry creator and modification time X-Git-Tag: v1.13~216 X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/52b02ea8e347f2849b05828c9e77113c17a3db6e word edit: record entry creator and modification time --- diff --git a/tools/word.pg.sql b/tools/word.pg.sql index 99664c9..101af7a 100644 --- a/tools/word.pg.sql +++ b/tools/word.pg.sql @@ -19,6 +19,8 @@ CREATE TABLE word ( thumb text[], wptitle text, created timestamptz DEFAULT now(), + creator integer REFERENCES login (id), + updated timestamptz, id serial NOT NULL PRIMARY KEY ); @@ -33,6 +35,8 @@ COMMENT ON COLUMN word.cover IS 'highlight if selected'; COMMENT ON COLUMN word.source IS 'URI of downloaded image'; COMMENT ON COLUMN word.thumb IS 'ImageMagick convert options to create thumbnail from source image'; COMMENT ON COLUMN word.wptitle IS 'reference Wikipedia article'; +COMMENT ON COLUMN word.updated IS 'last significant change'; +COMMENT ON COLUMN word.creator IS 'user responsible for initial submit'; CREATE OR REPLACE FUNCTION exportform(word) RETURNS text AS $$ SELECT concat( diff --git a/writer.plp b/writer.plp index fd2fc86..d72ef02 100644 --- a/writer.plp +++ b/writer.plp @@ -189,6 +189,8 @@ elsif ($ENV{REQUEST_METHOD} eq 'POST') {{ eval { my %res = (returning => '*'); + $row->{creator} = $user->{id} unless $find; + $row->{updated} = ['now()']; my $query = $find ? $db->update(word => $row, $find, \%res) : $db->insert(word => $row, \%res); $row = $query->hash;