Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change document modified_at to only update when uploading a new file #524

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

indigane
Copy link
Contributor

@indigane indigane commented Jan 24, 2025

Hitas Pull Request

Description

Documents have a user-visible timestamp for creation and modification. The modification timestamp currently updates for all documents relating to an apartment or housing company when the documents form is submitted. This is because the React form and DRF by default work so that they always save the fields even if they haven't changed.

This PR solves the issue by explicitly only updating the modified_at when a file is uploaded instead of automatically on every .save(). This could have also been solved by checking for changes in the frontend or backend but currently we are only interested in when the document file itself was last updated. This could also have been a new timestamp field but I decided against that as too much overengineering.

The migration in this PR is no-op:

$ python manage.py sqlmigrate hitas 0017
BEGIN;
--
-- Alter field modified_at on aparmentdocument
--
-- (no-op)
--
-- Alter field modified_at on housingcompanydocument
--
-- (no-op)
COMMIT;

Pull request checklist

Check the boxes for each DoD item that has been completed:

  • Testing
    • Changes have been tested
    • Automatic tests have been added
  • Database
    • Database migrations will work in the DEV & TEST environments

Tickets

HT-769

@indigane indigane force-pushed the feature/HT-769-document-modified-at branch from 8b6e3a3 to a2da37b Compare January 24, 2025 11:38
@indigane indigane merged commit 1082817 into master Jan 24, 2025
5 checks passed
@indigane indigane deleted the feature/HT-769-document-modified-at branch January 24, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant