3liz / qgis-pgmetadata-plugin

QGIS Plugin to manage some metadata from PostgreSQL layer
GNU General Public License v2.0
12 stars 10 forks source link

"Metadata:Created at" not autopopulating in QGIS 3.20.2 (but is in QGIS 3.18.0) #75

Closed everydayduffy closed 2 years ago

everydayduffy commented 3 years ago

Hello,

Firstly, thank you very much for making a very useful and well designed QGIS plugin!

When using the plugin on QGIS 3.20.2 the "Created At" field in Metdata will not autopopulate and therefore not allow me save the edits.

image

In comparison, loading the exact same administrator project from the same database in QGIS 3.18.0 causes no issues.

Given it is the more recent version that is misbehaving, I thought I would let you know.

Thanks.

everydayduffy commented 3 years ago

In the process of updating from 3.20.0 to 3.20.2 I think I updated some dependencies... 3.18.0 then had the same issue with the metadata.

I uninstalled both, and from scratch installed the 3.16 LTR version with OSGEO4W. The same issue persists. Here is a screenshot of my "About" Info:

image

Gustry commented 3 years ago

Can you update the QGIS project, layer properties of Dataset, Forms for at least the "Created" field ? You can set the default expression now() for the default value.

Screenshot from 2021-09-01 14-18-57

I don't understand why we don't have a default value set, while we have a constraint.

diff --git a/pg_metadata/resources/projects/pg_metadata_administration.qgs b/pg_metadata/resources/projects/pg_metadata_administration.qgs
index a0abb27..0b4d850 100644
--- a/pg_metadata/resources/projects/pg_metadata_administration.qgs
+++ b/pg_metadata/resources/projects/pg_metadata_administration.qgs
@@ -1060,8 +1060,8 @@ def my_form_open(dialog, layer, feature):
         <default applyOnUpdate="0" expression="" field="projection_name"></default>
         <default applyOnUpdate="0" expression="" field="projection_authid"></default>
         <default applyOnUpdate="0" expression="" field="spatial_extent"></default>
-        <default applyOnUpdate="0" expression="" field="creation_date"></default>
-        <default applyOnUpdate="0" expression="" field="update_date"></default>
+        <default applyOnUpdate="0" expression="now()" field="creation_date"></default>
+        <default applyOnUpdate="1" expression="now()" field="update_date"></default>
         <default applyOnUpdate="0" expression="" field="data_last_update"></default>
         <default applyOnUpdate="0" expression="" field="themes"></default>
       </defaults>
everydayduffy commented 3 years ago

Thanks for the quick response. Manually setting the values of both creation_date and update_date to now() (and checking apply to value on update for update_date, then saving the project has worked. I tried closing Q and reloading and those settings have stayed in the project.

I think it's fixed for me. Thank you.

Gustry commented 3 years ago

This needs to be fixed in plugin.

You can see the discussion about this fix in #77