mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Merge pull request #4643 from merkato/master
[FEATURE] Add role logging for PostGIS versioning.
This commit is contained in:
commit
cbde32f0fc
@ -126,6 +126,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>User role</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="editUser">
|
||||
<property name="text">
|
||||
<string>time_end</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -173,6 +190,7 @@
|
||||
<tabstop>editPkey</tabstop>
|
||||
<tabstop>editStart</tabstop>
|
||||
<tabstop>editEnd</tabstop>
|
||||
<tabstop>editUser</tabstop>
|
||||
<tabstop>txtSql</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
|
@ -61,6 +61,7 @@ class DlgVersioning(QDialog, Ui_DlgVersioning):
|
||||
self.editPkey.textChanged.connect(self.updateSql)
|
||||
self.editStart.textChanged.connect(self.updateSql)
|
||||
self.editEnd.textChanged.connect(self.updateSql)
|
||||
self.editUser.textChanged.connect(self.updateSql)
|
||||
|
||||
self.updateSql()
|
||||
|
||||
@ -114,6 +115,7 @@ class DlgVersioning(QDialog, Ui_DlgVersioning):
|
||||
self.colPkey = self.db.connector.quoteId(self.editPkey.text())
|
||||
self.colStart = self.db.connector.quoteId(self.editStart.text())
|
||||
self.colEnd = self.db.connector.quoteId(self.editEnd.text())
|
||||
self.colUser = self.db.connector.quoteId(self.editUser.text())
|
||||
|
||||
self.columns = [self.db.connector.quoteId(x.name) for x in self.table.fields()]
|
||||
|
||||
@ -173,8 +175,8 @@ class DlgVersioning(QDialog, Ui_DlgVersioning):
|
||||
QMessageBox.information(self, "Help", helpText)
|
||||
|
||||
def sql_alterTable(self):
|
||||
return u"ALTER TABLE %s ADD %s serial, ADD %s timestamp, ADD %s timestamp;" % (
|
||||
self.schematable, self.colPkey, self.colStart, self.colEnd)
|
||||
return u"ALTER TABLE %s ADD %s serial, ADD %s timestamp, ADD %s timestamp, ADD %s varchar;" % (
|
||||
self.schematable, self.colPkey, self.colStart, self.colEnd, self.colUser)
|
||||
|
||||
def sql_setPkey(self):
|
||||
return u"ALTER TABLE %s DROP CONSTRAINT %s, ADD PRIMARY KEY (%s);" % (
|
||||
@ -209,6 +211,7 @@ BEGIN
|
||||
IF NEW.%(end)s IS NULL THEN
|
||||
INSERT INTO %(schematable)s (%(cols)s, %(start)s, %(end)s) VALUES (%(oldcols)s, OLD.%(start)s, current_timestamp);
|
||||
NEW.%(start)s = current_timestamp;
|
||||
NEW.%(user)s = current_user;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
@ -222,12 +225,13 @@ BEGIN
|
||||
if NEW.%(start)s IS NULL then
|
||||
NEW.%(start)s = now();
|
||||
NEW.%(end)s = null;
|
||||
NEW.%(user)s = current_user;
|
||||
end if;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql';""" % {'view': self.view, 'schematable': self.schematable, 'cols': cols, 'oldcols': old_cols,
|
||||
'start': self.colStart, 'end': self.colEnd, 'func_at_time': self.func_at_time,
|
||||
'start': self.colStart, 'end': self.colEnd, 'user': self.colUser, 'func_at_time': self.func_at_time,
|
||||
'func_update': self.func_update, 'func_insert': self.func_insert}
|
||||
return sql
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user