From dbd92108557f5d818715d6fd203e23d089695502 Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Thu, 5 Dec 2024 21:37:04 -0600 Subject: [PATCH] WP-796 - registration list needs to update on modal edits (#391) --- .../templates/create_submitter_error.html | 18 --- .../templates/create_submitter_modal.html | 76 ------------ .../templates/create_submitter_success.html | 13 -- .../templates/edit_registration_error.html | 16 --- .../templates/edit_registration_modal.html | 26 ---- .../templates/edit_registration_success.html | 13 -- .../templates/view_registration_modal.html | 117 ------------------ apcd_cms/src/apps/admin_regis_table/views.py | 2 - apcd_cms/src/apps/utils/apcd_database.py | 4 +- .../client/src/hooks/registrations/useForm.ts | 11 +- 10 files changed, 12 insertions(+), 284 deletions(-) delete mode 100644 apcd_cms/src/apps/admin_regis_table/templates/create_submitter_error.html delete mode 100644 apcd_cms/src/apps/admin_regis_table/templates/create_submitter_modal.html delete mode 100644 apcd_cms/src/apps/admin_regis_table/templates/create_submitter_success.html delete mode 100644 apcd_cms/src/apps/admin_regis_table/templates/edit_registration_error.html delete mode 100644 apcd_cms/src/apps/admin_regis_table/templates/edit_registration_modal.html delete mode 100644 apcd_cms/src/apps/admin_regis_table/templates/edit_registration_success.html delete mode 100644 apcd_cms/src/apps/admin_regis_table/templates/view_registration_modal.html diff --git a/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_error.html b/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_error.html deleted file mode 100644 index 086f44f3..00000000 --- a/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_error.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "standard.html" %} -{% block content %} - -{# TUP-175: Move to Core, Remove from Here #} -{% include 'snippets/tup-175-css-alerts-messages-ui-pattern.html' %} - -
- {% include "nav_cms_breadcrumbs.html" %} - -

Create Submitter

-
-

- An error occurred during submission. For help, submit a ticket. -

- Back to List Registrations -
- -{% endblock %} diff --git a/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_modal.html b/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_modal.html deleted file mode 100644 index b6c0be35..00000000 --- a/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_modal.html +++ /dev/null @@ -1,76 +0,0 @@ - diff --git a/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_success.html b/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_success.html deleted file mode 100644 index 02ddfb0a..00000000 --- a/apcd_cms/src/apps/admin_regis_table/templates/create_submitter_success.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "standard.html" %} -{% block content %} -
- {% include "nav_cms_breadcrumbs.html" %} - -

Create Submitter

-
-

- Creation of this submitter was successful. -

- Back to List Registrations -
-{% endblock %} diff --git a/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_error.html b/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_error.html deleted file mode 100644 index a1ca78d4..00000000 --- a/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_error.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "standard.html" %} -{% block content %} - -{% include 'snippets/tup-175-css-alerts-messages-ui-pattern.html' %} - -
- {% include "nav_cms_breadcrumbs.html" %} - -

Edit Registration

-
-

- An error occurred while updating this registration. For help, submit a ticket. -

- Back to List Registrations -
-{% endblock %} diff --git a/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_modal.html b/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_modal.html deleted file mode 100644 index 743efe82..00000000 --- a/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_modal.html +++ /dev/null @@ -1,26 +0,0 @@ -{% load static %} - - - - - -{% include "submission_form/registration_form_scripts.html" %} diff --git a/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_success.html b/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_success.html deleted file mode 100644 index 803596bb..00000000 --- a/apcd_cms/src/apps/admin_regis_table/templates/edit_registration_success.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "standard.html" %} -{% block content %} -
- {% include "nav_cms_breadcrumbs.html" %} - -

Edit Registration

-
-

- Updating this registration was successful. -

- Back to List Registrations -
-{% endblock %} diff --git a/apcd_cms/src/apps/admin_regis_table/templates/view_registration_modal.html b/apcd_cms/src/apps/admin_regis_table/templates/view_registration_modal.html deleted file mode 100644 index cfbbc04c..00000000 --- a/apcd_cms/src/apps/admin_regis_table/templates/view_registration_modal.html +++ /dev/null @@ -1,117 +0,0 @@ - diff --git a/apcd_cms/src/apps/admin_regis_table/views.py b/apcd_cms/src/apps/admin_regis_table/views.py index 7834264e..65784685 100644 --- a/apcd_cms/src/apps/admin_regis_table/views.py +++ b/apcd_cms/src/apps/admin_regis_table/views.py @@ -44,8 +44,6 @@ def post(self, request, reg_id): updated_entity_ids = {reg['entity_id'] for reg in reg_entities if 'entity_id' in reg and reg['entity_id'] >= 0} updated_contact_ids = {con['contact_id'] for con in reg_contacts if 'contact_id' in con and con['contact_id'] >= 0} # Retrieve existing IDs - for reg in get_registration_entities(reg_id): - logger.error(reg) existing_entity_ids = {reg[3] for reg in get_registration_entities(reg_id)} existing_contact_ids = {contact[0] for contact in get_registration_contacts(reg_id)} # Find the deleted ones. diff --git a/apcd_cms/src/apps/utils/apcd_database.py b/apcd_cms/src/apps/utils/apcd_database.py index 2beab80e..924a3532 100644 --- a/apcd_cms/src/apps/utils/apcd_database.py +++ b/apcd_cms/src/apps/utils/apcd_database.py @@ -179,7 +179,9 @@ def get_registrations(reg_id=None, submitter_code=None): registrations.registration_year FROM registrations {f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''} - {f"LEFT JOIN registration_submitters on registrations.registration_id = registration_submitters.registration_id LEFT JOIN submitters ON registration_submitters.submitter_id = submitters.submitter_id WHERE submitter_code = ANY(%s) ORDER BY registrations.registration_id" if submitter_code is not None else ''}""" + {f"LEFT JOIN registration_submitters on registrations.registration_id = registration_submitters.registration_id LEFT JOIN submitters ON registration_submitters.submitter_id = submitters.submitter_id WHERE submitter_code = ANY(%s) ORDER BY registrations.registration_id" if submitter_code is not None else ''} + ORDER BY registrations.registration_id desc""" + cur = conn.cursor() if submitter_code: cur.execute(query, (submitter_code,)) diff --git a/apcd_cms/src/client/src/hooks/registrations/useForm.ts b/apcd_cms/src/client/src/hooks/registrations/useForm.ts index bbc653e9..187f6e55 100644 --- a/apcd_cms/src/client/src/hooks/registrations/useForm.ts +++ b/apcd_cms/src/client/src/hooks/registrations/useForm.ts @@ -50,8 +50,15 @@ export function usePostRegistration() { console.log(err); }, onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: ['submitter-registrations', 'admin-registrations'], + const keysToInvalidate = [ + 'admin-registrations', + 'submitter-registrations', + ]; + keysToInvalidate.forEach((key) => { + queryClient.invalidateQueries({ + queryKey: [key], + exact: false, // we do not know the parameters, so all keys are invalidated + }); }); }, });