-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix last update date on existing request
- Loading branch information
Showing
2 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
service_catalog/migrations/0028_set_last_update_on_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 3.2.13 on 2023-09-27 08:53 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def update_requests(apps, schema_editor): | ||
Request = apps.get_model('service_catalog', 'Request') | ||
for request in Request.objects.all(): | ||
Request.objects.filter(pk=request.pk).update(created=request.date_submitted, | ||
last_updated=request.date_submitted) | ||
from service_catalog.models import RequestState | ||
if request.state == RequestState.COMPLETE: | ||
Request.objects.filter(pk=request.pk).update(last_updated=request.date_complete) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('service_catalog', '0027_alter_approvalworkflow_scopes'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(update_requests), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters