-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-2356] Add PartnerFieldGroup model and API endpoint
#891
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
Merged
protsack-stephan
merged 11 commits into
main
from
OSDEV-2356-add-partner-field-groups-endpoint
Feb 27, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
793cd2d
Add initial data model setup
protsack-stephan 3c7fb22
Add created and updated at fields and change the file to image
protsack-stephan 29f4978
Add fields groups API endpoint to the system
protsack-stephan 9d9ce5c
Fix the description for the PartnerFieldGroupsViewSet
protsack-stephan 6af3dd0
Remove the icon name due to potential performance issues
protsack-stephan 31fd515
Add cache for the endpoints
protsack-stephan 1e74c72
Fix linting and add unit tests
protsack-stephan 69fb543
Add release notes
protsack-stephan 91fb8fc
Remove unused imports in the tests
protsack-stephan f86552a
Fix the variable names and tests
protsack-stephan d58a9ef
Update the docstrings to be more descriptive
protsack-stephan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/django/api/migrations/0201_add_partnerfieldgroup_alter_partnerfield.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Generated by Django 5.2.10 on 2026-02-26 13:28 | ||
|
|
||
| import django.db.models.deletion | ||
| import django_ckeditor_5.fields | ||
| import uuid | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("api", "0200_introduce_indexing_of_the_creation_date_of_the_claim_request"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="PartnerFieldGroup", | ||
| fields=[ | ||
| ( | ||
| "uuid", | ||
| models.UUIDField( | ||
| default=uuid.uuid4, | ||
| editable=False, | ||
| help_text="Unique identifier for the partner field group.", | ||
| primary_key=True, | ||
| serialize=False, | ||
| ), | ||
| ), | ||
| ( | ||
| "name", | ||
| models.CharField( | ||
| help_text="The partner field group name.", | ||
| max_length=200, | ||
| unique=True, | ||
| ), | ||
| ), | ||
| ( | ||
| "order", | ||
| models.IntegerField( | ||
| default=0, | ||
| help_text="Order for the partner field group in the UI.", | ||
| ), | ||
| ), | ||
| ( | ||
| "icon_file", | ||
| models.ImageField( | ||
| blank=True, | ||
| help_text="Upload an icon image.", | ||
| null=True, | ||
| upload_to="partner_field_groups/icons/", | ||
| ), | ||
| ), | ||
| ( | ||
| "description", | ||
| django_ckeditor_5.fields.CKEditor5Field( | ||
| blank=True, | ||
| help_text="Rich text description of the partner field group.", | ||
| null=True, | ||
| ), | ||
| ), | ||
| ( | ||
| "helper_text", | ||
| django_ckeditor_5.fields.CKEditor5Field( | ||
| blank=True, | ||
| help_text="Rich text helper text for the partner field group.", | ||
| null=True, | ||
| ), | ||
| ), | ||
| ( | ||
| "created_at", | ||
| models.DateTimeField(auto_now_add=True), | ||
| ), | ||
| ( | ||
| "updated_at", | ||
| models.DateTimeField(auto_now=True), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name_plural": "Partner field groups", | ||
| "ordering": ["order"], | ||
| }, | ||
| ), | ||
| migrations.AddField( | ||
| model_name="partnerfield", | ||
| name="group", | ||
| field=models.ForeignKey( | ||
| blank=True, | ||
| help_text="The group this partner field belongs to.", | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="partner_fields", | ||
| to="api.partnerfieldgroup", | ||
| ), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import uuid | ||
| from django.db import models | ||
| from django_ckeditor_5.fields import CKEditor5Field | ||
|
|
||
|
|
||
| class PartnerFieldGroup(models.Model): | ||
| """ | ||
| Group for partner fields. | ||
| """ | ||
|
|
||
| uuid = models.UUIDField( | ||
| default=uuid.uuid4, | ||
| primary_key=True, | ||
| editable=False, | ||
| help_text="Unique identifier for the partner field group.", | ||
| ) | ||
| name = models.CharField( | ||
| max_length=200, | ||
| unique=True, | ||
| null=False, | ||
| help_text="The partner field group name.", | ||
| ) | ||
| order = models.IntegerField( | ||
| default=0, | ||
| help_text="Order for the partner field group in the UI.", | ||
| ) | ||
| icon_file = models.ImageField( | ||
| upload_to="partner_field_groups/icons/", | ||
| blank=True, | ||
| null=True, | ||
| help_text="Upload an icon image.", | ||
| ) | ||
| description = CKEditor5Field( | ||
| blank=True, | ||
| null=True, | ||
| help_text="Rich text description of the partner field group.", | ||
| ) | ||
| helper_text = CKEditor5Field( | ||
| blank=True, | ||
| null=True, | ||
| help_text="Rich text helper text for the partner field group.", | ||
| ) | ||
| created_at = models.DateTimeField(auto_now_add=True) | ||
| updated_at = models.DateTimeField(auto_now=True) | ||
|
|
||
| class Meta: | ||
| verbose_name_plural = "Partner field groups" | ||
| ordering = ["order"] | ||
|
|
||
| def __str__(self): | ||
| return self.name |
41 changes: 41 additions & 0 deletions
41
src/django/api/serializers/partner_field_group/partner_field_group_serializer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """ | ||
| Serializer for partner field groups. | ||
| Specifies the fields that are returned by | ||
| the GET /api/partner-field-groups/ API endpoint. | ||
| """ | ||
VadimKovalenkoSNF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| from rest_framework import serializers | ||
| from rest_framework.serializers import ModelSerializer | ||
| from api.models.partner_field_group import PartnerFieldGroup | ||
|
|
||
|
|
||
| class PartnerFieldGroupSerializer(ModelSerializer): | ||
| """ | ||
| Serializer for the PartnerFieldGroup model. | ||
| Serializes the fields and related partner_fields for the API response. | ||
| """ | ||
|
|
||
| partner_fields = serializers.SlugRelatedField( | ||
| many=True, | ||
| read_only=True, | ||
| slug_field="name", | ||
| ) | ||
|
|
||
| class Meta: | ||
| """ | ||
| Meta class for partner field group serializer. | ||
| Specifies the fields that are returned by the API response. | ||
| """ | ||
|
|
||
| model = PartnerFieldGroup | ||
| fields = [ | ||
| "uuid", | ||
| "name", | ||
| "order", | ||
| "icon_file", | ||
| "description", | ||
| "helper_text", | ||
| "partner_fields", | ||
| "created_at", | ||
| "updated_at", | ||
| ] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.