Skip to content
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
50748c2
Update moderation events naming
VadimKovalenkoSNF Dec 11, 2024
4f02341
Apply getting single moderation event
VadimKovalenkoSNF Dec 12, 2024
c265203
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 12, 2024
6743cd4
Minor post-merge fix
VadimKovalenkoSNF Dec 12, 2024
00794c4
Apply potential match search
VadimKovalenkoSNF Dec 13, 2024
0566b50
Refactory completeFetchingPotentialMatches reducer
VadimKovalenkoSNF Dec 13, 2024
8e02734
Refactory routing to moderation record
VadimKovalenkoSNF Dec 13, 2024
feff7b8
Refactor claim button styles and appearance
VadimKovalenkoSNF Dec 13, 2024
b33e7d3
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 13, 2024
219b0cf
Minor style update
VadimKovalenkoSNF Dec 13, 2024
f0c1cb3
Refactor naming, apply status toolbar and style refactoring
VadimKovalenkoSNF Dec 13, 2024
e1a4352
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 13, 2024
a2abec2
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 16, 2024
d7ca8ee
Implement Reject action, refactor claim button
VadimKovalenkoSNF Dec 16, 2024
60d1b8f
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 16, 2024
32f7402
Integrate POST production location from mmoderation event
VadimKovalenkoSNF Dec 16, 2024
517b942
Apply signal for modertion event change
VadimKovalenkoSNF Dec 17, 2024
2fb6232
Apply toastify (partial impl)
VadimKovalenkoSNF Dec 17, 2024
7deb327
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 18, 2024
9770572
Minor refactoring, add render condition while making request
VadimKovalenkoSNF Dec 18, 2024
c52ddc1
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 18, 2024
019db55
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 18, 2024
77fcbf5
Finish confirmPotentialMatchFromModerationEvent action
VadimKovalenkoSNF Dec 19, 2024
fa5f868
Refactor moderation event statuses using constants
VadimKovalenkoSNF Dec 19, 2024
ed4f53b
Wrap confirm button with the tooltip
VadimKovalenkoSNF Dec 19, 2024
54f1386
Add Backdrop component on moderation event update
VadimKovalenkoSNF Dec 19, 2024
4edb789
Fix flake8 issues
VadimKovalenkoSNF Dec 19, 2024
7eccc8d
Add OS ID link, higlight confirmed match
VadimKovalenkoSNF Dec 20, 2024
fc49fae
Minor test improvements (partila impl)
VadimKovalenkoSNF Dec 20, 2024
31c9a54
Update FE tests
VadimKovalenkoSNF Dec 23, 2024
6c55356
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 23, 2024
df582fc
Add proptypes
VadimKovalenkoSNF Dec 23, 2024
e5ebcc4
Fix DashboardModerationQueueListTable.test.js
VadimKovalenkoSNF Dec 23, 2024
9e02130
Fix lint issues
VadimKovalenkoSNF Dec 23, 2024
ac38da5
Add BE tests (partial impl)
VadimKovalenkoSNF Dec 24, 2024
6b41fce
Update test suite
VadimKovalenkoSNF Dec 24, 2024
9e3370c
Update integration tests
VadimKovalenkoSNF Dec 25, 2024
69fe5e2
Fix flake8 issues
VadimKovalenkoSNF Dec 25, 2024
311254c
Reduce integration ticket scope
VadimKovalenkoSNF Dec 25, 2024
acb6351
Update Release notes
VadimKovalenkoSNF Dec 25, 2024
d15ae46
Omit rate limiter test
VadimKovalenkoSNF Dec 25, 2024
7b0acf1
Revert make_token file
VadimKovalenkoSNF Dec 25, 2024
6e5fa44
Remove integration test
VadimKovalenkoSNF Dec 25, 2024
8e17399
Disable signal propagation to unit tests
VadimKovalenkoSNF Dec 26, 2024
bdb7bae
Bring back first part of integration test
VadimKovalenkoSNF Dec 26, 2024
181a5b5
Upd made token file
VadimKovalenkoSNF Dec 26, 2024
278de27
Extend integration tests
VadimKovalenkoSNF Dec 26, 2024
e83ca42
Minor test update
VadimKovalenkoSNF Dec 26, 2024
3e65e21
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 26, 2024
000ebb2
Update DashboardModerationQueueListTable test suite
VadimKovalenkoSNF Dec 26, 2024
1846009
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Dec 26, 2024
6a23c67
Minor refactoring of integration test
VadimKovalenkoSNF Dec 26, 2024
cab8a47
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Jan 7, 2025
f3d5c83
Remove redundant logs, update release notes
VadimKovalenkoSNF Jan 7, 2025
74c3a43
Move release notes to v.1.28.0
VadimKovalenkoSNF Jan 7, 2025
01bdfdc
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Jan 7, 2025
c94cce8
Upd release notes
VadimKovalenkoSNF Jan 7, 2025
96d06f2
Merge branch 'main' into OSDEV-1117-contribution-record-integration
VadimKovalenkoSNF Jan 8, 2025
e82282e
Remove async keyword, fix proptypes for TooltipDialog, remove redunda…
VadimKovalenkoSNF Jan 9, 2025
5ea1f43
Remove redundant shouldDisabledWhileRequest state prop
VadimKovalenkoSNF Jan 9, 2025
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
38 changes: 38 additions & 0 deletions doc/release/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,44 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). The format is based on the `RELEASE-NOTES-TEMPLATE.md` file.

## Release 1.28.0

## Introduction
* Product name: Open Supply Hub
* Release date: January 25, 2025

### Database changes
#### Migrations:
* *Describe migrations here.*

#### Scheme changes
* *Describe scheme changes here.*

### Code/API changes
* *Describe code/API changes here.*

### Architecture/Environment changes
* *Describe architecture/environment changes here.*

### Bugfix
* *Describe bugfix here.*

### What's new
* [OSDEV-1117](https://opensupplyhub.atlassian.net/browse/OSDEV-1117) - Implemented integration of Contribution Record Page (`/dashboard/moderation-queue/contribution-record/{moderation_id}`):
- Connected GET `api/v1/moderation-events/{moderation_id}/`.
- Connected GET `api/v1/production-locations?name={productionLocationName}&country={countryCode}&address={address}` to get potential matches using OpenSearch engine.
- Connected PATCH `/v1/moderation-events/{moderation_id}/` (for Reject button).
- Connected POST `/v1/moderation-events/{moderation_id}/production-locations/` (for Create New Location button).
- Connected PATCH `/v1/moderation-events/{moderation_id}/production-locations/{os_id}/` (for Confirm potential match button).
- UI improvements:
- Added a toast component to display notifications during moderation event updates.
- Introduced a backdrop to prevent accidental clicks on other buttons during the update process.
- Applied Django Signal for moderation-events OpenSearch index.

### Release instructions:
* *Provide release instructions here.*


## Release 1.27.0

## Introduction
Expand Down
24 changes: 16 additions & 8 deletions src/django/api/management/commands/make_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@

class Command(BaseCommand):
help = ('Usage: Create an API token for the user during the database '
'reset.')
'reset, and set admin rights.')

def handle(self, *args, **options):
call_command('shell',
'-c',
("from rest_framework.authtoken.models import Token; "
"from api.models import User; token = "
"Token.objects.create(user=User.objects.get(id=2),"
"key='1d18b962d6f976b0b7e8fcf9fcc39b56cf278051'); "
"print('Token for [email protected]'); print(token)"))
call_command(
'shell',
'-c',
(
"from rest_framework.authtoken.models import Token;"
"from api.models import User;"
"user = User.objects.get(id=2);"
"user.is_staff = True;"
"user.is_superuser = True;"
"user.save();"
"token = Token.objects.create(user=user,"
"key='1d18b962d6f976b0b7e8fcf9fcc39b56cf278051');"
"print(f'Token for {user.email}: {token.key}')"
)
)
80 changes: 61 additions & 19 deletions src/django/api/signals.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import logging
import json

from django.db.models.signals import post_delete
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from opensearchpy.exceptions import ConnectionError

from api.models.facility.facility import Facility
from api.models.moderation_event import ModerationEvent
from api.services.opensearch.opensearch import OpenSearchServiceConnection
from oar.rollbar import report_error_to_rollbar
from api.views.v1.index_names import OpenSearchIndexNames
Expand All @@ -14,31 +15,72 @@
log = logging.getLogger(__name__)


def signal_error_notifier(error_log_message, response):
log.error(error_log_message)
report_error_to_rollbar(
message=error_log_message,
extra_data={
'response_result': json.dumps(response),
}
)


@receiver(post_delete, sender=Facility)
def location_post_delete_handler_for_opensearch(sender, **kwargs):
def location_post_delete_handler_for_opensearch(instance, **kwargs):
opensearch = OpenSearchServiceConnection()
location_instance = kwargs.get('instance')
try:
response = opensearch.client.delete(
index=OpenSearchIndexNames.PRODUCTION_LOCATIONS_INDEX,
id=location_instance.id
id=instance.id,
)
except ConnectionError:
log.error(
'[Location Deletion] Lost connection to OpenSearch cluster.'
)
raise

if response and response.get('result') == 'not_found':
error_log_message = (
"[Location Deletion] Facility not found "
"in OpenSearch, indicating "
"data inconsistency."
)
signal_error_notifier(error_log_message, response)


@receiver(post_save, sender=ModerationEvent)
def moderation_event_update_handler_for_opensearch(
instance,
created,
**kwargs
):
if created:
return

opensearch = OpenSearchServiceConnection()
try:
response = opensearch.client.update(
index=OpenSearchIndexNames.MODERATION_EVENTS_INDEX,
id=str(instance.uuid),
body={
"doc": {
"uuid": str(instance.uuid),
"status": str(instance.status),
"os": instance.os.id if instance.os else None
}
},
)
except ConnectionError:
log.error(('[Location Deletion] The Django app lost the connection '
'with the OpenSearch cluster.'))
log.error(
"[Moderation Event Updating] "
"Lost connection to OpenSearch cluster."
)
raise

if (response and response.get('result') == 'not_found'):
log.error(("[Location Deletion] The same location wasn't found in the "
'OpenSearch data store, indicating critical data '
'inconsistency.'))
report_error_to_rollbar(
message=(
"[Location Deletion] The same location wasn't found in the "
'OpenSearch data store, indicating critical data '
'inconsistency.'
),
extra_data={
'response_result': json.dumps(response),
}
if response and response.get('result') == 'not_found':
error_log_message = (
"[Moderation Event Updating] "
"ModerationEvent not found in OpenSearch, "
"indicating data inconsistency."
)
signal_error_notifier(error_log_message, response)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.test import override_settings
from django.utils.timezone import now
from django.db.models.signals import post_save

from rest_framework.test import APITestCase

Expand All @@ -10,11 +11,20 @@
from api.models.nonstandard_field import NonstandardField
from api.models.source import Source

from api.signals import moderation_event_update_handler_for_opensearch


@override_settings(DEBUG=True)
class BaseModerationEventsProductionLocationTest(APITestCase):
def setUp(self):
super().setUp()
# Disconnect moderation event save propagation to
# OpenSearch cluster, as it is outside the scope
# of Django unit testing.
post_save.disconnect(
moderation_event_update_handler_for_opensearch,
ModerationEvent
)

self.email = "[email protected]"
self.password = "example123"
Expand Down
Loading