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

fix: environment webhooks shows current date, not created date #2555

Merged
merged 4 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions api/organisations/migrations/0043_auto_20230801_0914.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2023-08-01 09:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('organisations', '0042_alter_subscription_payment_method'),
]

operations = [
migrations.AddField(
model_name='organisationwebhook',
name='created_at',
field=models.DateTimeField(auto_now_add=True, null=True),
),
migrations.AddField(
model_name='organisationwebhook',
name='updated_at',
field=models.DateTimeField(auto_now=True, null=True),
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified (perhaps just with python manage.py sqlmigrate organisations 0043) that it doesn't update existing webhooks?

]
2 changes: 2 additions & 0 deletions api/organisations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ class OrganisationWebhook(AbstractBaseExportableWebhookModel):
organisation = models.ForeignKey(
Organisation, on_delete=models.CASCADE, related_name="webhooks"
)
created_at = models.DateTimeField(null=True, auto_now_add=True)
updated_at = models.DateTimeField(null=True, auto_now=True)

class Meta:
ordering = ("id",) # explicit ordering to prevent pagination warnings
Expand Down
2 changes: 1 addition & 1 deletion api/organisations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class PortalUrlSerializer(serializers.Serializer):
class OrganisationWebhookSerializer(serializers.ModelSerializer):
class Meta:
model = OrganisationWebhook
fields = ("id", "url", "enabled", "secret")
fields = ("id", "url", "enabled", "secret", "created_at", "updated_at")
read_only_fields = ("id",)


Expand Down
2 changes: 1 addition & 1 deletion frontend/web/components/pages/EnvironmentSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ const EnvironmentSettingsPage = class extends Component {
<Button theme='text'>{webhook.url}</Button>
<div className='list-item-footer faint'>
Created{' '}
{moment(webhook.created_date).format(
{moment(webhook.created_at).format(
'DD/MMM/YYYY',
)}
</div>
Expand Down
14 changes: 8 additions & 6 deletions frontend/web/components/pages/OrganisationSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1248,12 +1248,14 @@ const OrganisationSettingsPage = class extends Component {
<Button theme='text'>
{webhook.url}
</Button>
<div className='list-item-footer faint'>
Created{' '}
{moment(webhook.created_date).format(
'DD/MMM/YYYY',
)}
</div>
{webhook.created_at ? (
<div className='list-item-footer faint'>
Created{' '}
{moment(webhook.created_at).format(
'DD/MMM/YYYY',
)}
</div>
) : null}
</div>
<Row>
<Switch checked={webhook.enabled} />
Expand Down