diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml index 3b63a76b..2a800418 100644 --- a/docs/api/openapi.yml +++ b/docs/api/openapi.yml @@ -6218,6 +6218,52 @@ paths: name: id__not_isnull schema: type: boolean + - in: query + name: pi + schema: + type: string + - in: query + name: pi__contains + schema: + type: string + - in: query + name: pi__endswith + schema: + type: string + - in: query + name: pi__in + schema: + type: array + items: + type: string + description: Multiple values may be separated by commas. + explode: false + style: form + - in: query + name: pi__isnull + schema: + type: boolean + - in: query + name: pi__not_contains + schema: + type: string + - in: query + name: pi__not_in + schema: + type: array + items: + type: string + description: Multiple values may be separated by commas. + explode: false + style: form + - in: query + name: pi__not_isnull + schema: + type: boolean + - in: query + name: pi__startswith + schema: + type: string - in: query name: start_date schema: @@ -7534,6 +7580,52 @@ paths: name: id__not_isnull schema: type: boolean + - in: query + name: pi + schema: + type: string + - in: query + name: pi__contains + schema: + type: string + - in: query + name: pi__endswith + schema: + type: string + - in: query + name: pi__in + schema: + type: array + items: + type: string + description: Multiple values may be separated by commas. + explode: false + style: form + - in: query + name: pi__isnull + schema: + type: boolean + - in: query + name: pi__not_contains + schema: + type: string + - in: query + name: pi__not_in + schema: + type: array + items: + type: string + description: Multiple values may be separated by commas. + explode: false + style: form + - in: query + name: pi__not_isnull + schema: + type: boolean + - in: query + name: pi__startswith + schema: + type: string - in: query name: start_date schema: @@ -11618,12 +11710,17 @@ components: agency: type: string maxLength: 100 + pi: + type: string + nullable: true + maxLength: 100 amount: type: string format: decimal pattern: ^-?\d{0,12}(?:\.\d{0,2})?$ grant_number: type: string + nullable: true maxLength: 250 start_date: type: string @@ -11646,6 +11743,7 @@ components: - end_date - grant_number - id + - pi - start_date - team - title @@ -11661,13 +11759,17 @@ components: type: string minLength: 1 maxLength: 100 + pi: + type: string + nullable: true + maxLength: 100 amount: type: string format: decimal pattern: ^-?\d{0,12}(?:\.\d{0,2})?$ grant_number: type: string - minLength: 1 + nullable: true maxLength: 250 start_date: type: string @@ -11684,7 +11786,6 @@ components: required: - agency - amount - - grant_number - start_date - team - title @@ -11746,12 +11847,17 @@ components: agency: type: string maxLength: 100 + pi: + type: string + nullable: true + maxLength: 100 amount: type: string format: decimal pattern: ^-?\d{0,12}(?:\.\d{0,2})?$ grant_number: type: string + nullable: true maxLength: 250 start_date: type: string @@ -11769,7 +11875,6 @@ components: required: - agency - amount - - grant_number - id - start_date - team @@ -11786,13 +11891,17 @@ components: type: string minLength: 1 maxLength: 100 + pi: + type: string + nullable: true + maxLength: 100 amount: type: string format: decimal pattern: ^-?\d{0,12}(?:\.\d{0,2})?$ grant_number: type: string - minLength: 1 + nullable: true maxLength: 250 start_date: type: string @@ -11807,7 +11916,6 @@ components: required: - agency - amount - - grant_number - start_date - title JobExecutionError: @@ -12633,13 +12741,17 @@ components: type: string minLength: 1 maxLength: 100 + pi: + type: string + nullable: true + maxLength: 100 amount: type: string format: decimal pattern: ^-?\d{0,12}(?:\.\d{0,2})?$ grant_number: type: string - minLength: 1 + nullable: true maxLength: 250 start_date: type: string diff --git a/keystone_api/apps/research_products/migrations/0010_grant_pi_alter_grant_grant_number.py b/keystone_api/apps/research_products/migrations/0010_grant_pi_alter_grant_grant_number.py new file mode 100644 index 00000000..547658d7 --- /dev/null +++ b/keystone_api/apps/research_products/migrations/0010_grant_pi_alter_grant_grant_number.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2.14 on 2026-06-08 14:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('research_products', '0009_grant_description_alter_grant_end_date_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='grant', + name='pi', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='grant', + name='grant_number', + field=models.CharField(blank=True, max_length=250, null=True), + ), + ] diff --git a/keystone_api/apps/research_products/models.py b/keystone_api/apps/research_products/models.py index 50e4a95a..55396c81 100644 --- a/keystone_api/apps/research_products/models.py +++ b/keystone_api/apps/research_products/models.py @@ -37,8 +37,9 @@ class Meta: title = models.CharField(max_length=250) agency = models.CharField(max_length=100) + pi = models.CharField(max_length=100, null=True, blank=True) amount = models.DecimalField(decimal_places=2, max_digits=14) - grant_number = models.CharField(max_length=250) + grant_number = models.CharField(max_length=250, null=True, blank=True) start_date = models.DateField() end_date = models.DateField(null=True, blank=True) description = models.TextField(null=True, blank=True) diff --git a/keystone_api/apps/research_products/views.py b/keystone_api/apps/research_products/views.py index 28728ceb..e0fa482e 100644 --- a/keystone_api/apps/research_products/views.py +++ b/keystone_api/apps/research_products/views.py @@ -76,7 +76,7 @@ class GrantViewSet(TeamScopedListMixin, viewsets.ModelViewSet): team_field = "team" permission_classes = [IsAuthenticated, IsAdminUser | IsTeamMember] - search_fields = ["title", "agency", "team__name"] + search_fields = ["title", "agency", "team__name", "pi"] serializer_class = GrantSerializer queryset = Grant.objects.prefetch_related( "history",