BCAP Messaging backend - #1611
Conversation
| CONTRIBUTOR_TYPES = [ | ||
| # (item id, prefLabel value id, label, sortorder, concept uri) | ||
| ( | ||
| "8c4e2933-a97a-5f47-89e7-78d1d8aaad81", | ||
| "c0b10d00-fbfa-58c3-ba46-3dc39d61a87e", | ||
| "Individual", | ||
| 0, | ||
| "http://bcap/bcap8c4e2933-a97a-5f47-89e7-78d1d8aaad81", | ||
| ), | ||
| ( | ||
| "fd2053d3-c010-519a-97e5-52f3c7b508e2", | ||
| "891278e4-5d67-571a-a0c4-414896d36d1c", | ||
| "Organization", | ||
| 1, | ||
| "http://bcap/bcapfd2053d3-c010-519a-97e5-52f3c7b508e2", | ||
| ), | ||
| ] |
There was a problem hiding this comment.
had to add these - we don't have pkg file that load them in
There was a problem hiding this comment.
added some comments as per Brett's suggestion for this
| z.iso.date(), | ||
| z.iso.datetime({ offset: true, local: true }) | ||
| ]).nullable() | ||
| node_value: z.string().regex(/^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}:\d{2}([+-]\d{2}:\d{2}|Z)?)?$/).nullable() |
There was a problem hiding this comment.
Had to do this, arches dates aren't saved as ISO - there is a way to override that but it impacts other dates/datetimes
There was a problem hiding this comment.
if I try to change how arches saves the date it can impact other dates in the system, so I've opted to just make this a bit more flexible on the frontend
| def register_offset_preserving_date_field(): | ||
| """Use the offset-preserving field for date nodes on the REST write path. | ||
| Call from AppConfig.ready(): the imports must be deferred until the app | ||
| registry is loaded.""" | ||
| from django.db.models import DateTimeField | ||
| from arches_querysets.rest_framework.serializers import TileAliasedDataSerializer | ||
|
|
||
| TileAliasedDataSerializer.register_custom_datatype_field( | ||
| DateTimeField, OffsetPreservingDateTimeField | ||
| ) |
There was a problem hiding this comment.
Arches queryset problem I'll create a PR if I have some time
|
we may need a way to get counts not on a dashboard route, but we'll see as you implement |
| def submission_context_ids_for_permits(self, permits, requirements_by_permit=None): | ||
| """Map each permit to the resource ids its unread counts span (the permit | ||
| and its requirements' submission hosts); pass known requirement ids to | ||
| skip a query.""" | ||
| permit_ids = [str(permit.pk) for permit in permits] | ||
| contexts = {pk: {pk} for pk in permit_ids} | ||
|
|
||
| if requirements_by_permit is None: | ||
| requirements_by_permit = self._requirements.requirement_ids_by_permit( | ||
| permit_ids | ||
| ) | ||
| all_requirement_ids = set(chain.from_iterable(requirements_by_permit.values())) | ||
| hosts_by_requirement = self._requirements.host_ids_by_requirement( | ||
| all_requirement_ids | ||
| ) | ||
| for permit_id, requirement_ids in requirements_by_permit.items(): | ||
| for requirement_id in requirement_ids: | ||
| hosts = hosts_by_requirement.get(requirement_id, ()) | ||
| contexts[permit_id].update(hosts) | ||
| return contexts |
There was a problem hiding this comment.
we might need this done at the module level as well (groupings of process requirements)
next PR or another PR
| def _date_node_value(max_length): | ||
| # Accept a bare date or a full datetime; anyOf becomes a zod union. | ||
| return { | ||
| "nullable": True, | ||
| "anyOf": [ | ||
| {"type": "string", "format": "date"}, | ||
| {"type": "string", "format": "date-time"}, | ||
| ], | ||
| } |
There was a problem hiding this comment.
Changed this a bit and moved to zod-validation library. It would work for createdon (on the model) but not for message_created_on (inside the json)
| <script setup lang="ts"> | ||
| import { reactive } from 'vue'; | ||
| import { z } from 'zod'; | ||
| import arches from 'arches'; | ||
| import { | ||
| zApiPermitApplicationCreateResponse, | ||
| zBcapMessage, | ||
| zBcapMessageWritable, | ||
| zPaginatedBcapMessageList, | ||
| zPaginatedContributorList, | ||
| } from '@/bcap/client/zod.gen.ts'; | ||
| import { formatDateTime, getCsrfToken, getDisplayValue } from '@/bcap/util.ts'; | ||
| import type { AliasedNodeData } from '@/arches_component_lab/types.ts'; | ||
|
|
There was a problem hiding this comment.
we'll need to gun this file when Philip is done with it
| { | ||
| id: 'site-visit', | ||
| label: 'Site Visit', | ||
| subtitle: 'Coming soon', | ||
| icon: 'fa fa-location-dot', | ||
| disabled: true, | ||
| }, |
There was a problem hiding this comment.
Site visit as requested in the menu / tiles at the end
| return False | ||
| tile.data[username_node] = username | ||
| tile.save() | ||
| Resource.objects.get(pk=contributor_id).index() |
There was a problem hiding this comment.
we were missing this, we may need to do a simple python script to reindex some users =(
| path: arches.urls.plugin('external-permit-workflows/message-demo'), | ||
| name: 'messageDemo', | ||
| component: () => | ||
| import('@/bcap/apps/Permit/components/MessageDemo.vue'), | ||
| meta: { | ||
| shouldShowNavigation: true, | ||
| requiresAuthentication: true, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Remove, this is temp
| def is_internal_user(user): | ||
| """True if the user is ministry staff (a superuser or holds an internal | ||
| role); everyone else is treated as an external applicant.""" | ||
| if not getattr(user, "is_authenticated", False): | ||
| return False | ||
| if getattr(user, "is_superuser", False): | ||
| return True | ||
| return user.groups.filter(name__in=INTERNAL_ROLES).exists() |
|
Might need some url clean up next PR
|
bferguso
left a comment
There was a problem hiding this comment.
Nice work! This is a great push forward.
If you have time next week lets try to move the queryset patch into the arches-querysets so we don't forget about it and start to drift.
bcgov/arches-zod-validation#3 <-- ideally needs to get merged as well
I didn't try the dashboard counts beyond just loading them - I think they are covered in unit tests though. We should have a function that will work for counts on a process requirement basis.