-
Notifications
You must be signed in to change notification settings - Fork 26
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
[#4396] Objects API prefill plugin #4566
Conversation
5ea6f6c
to
31caea8
Compare
31caea8
to
a912c98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vaszig looked over the code briefly, from what I can see I think it's going in the right direction 👍
class PluginObjectsAPIObjecttypeListView(ListMixin, APIView): | ||
""" | ||
List the available prefill objecttypes for Objects API plugin. | ||
""" | ||
|
||
authentication_classes = (authentication.SessionAuthentication,) | ||
permission_classes = (permissions.IsAdminUser,) | ||
serializer_class = PrefillObjectsAPIObjecttypeSerializer | ||
|
||
def get_objects(self) -> list[dict[str, Any]]: | ||
input_serializer = ObjectsAPIGroupInputSerializer( | ||
data=self.request.query_params | ||
) | ||
input_serializer.is_valid(raise_exception=True) | ||
|
||
config_group = input_serializer.validated_data["objects_api_group"] | ||
|
||
with get_objecttypes_client(config_group) as client: | ||
return client.list_objecttypes() | ||
|
||
|
||
@extend_schema_view( | ||
get=extend_schema(summary=_("List available objecttype versions for Objects API")), | ||
parameters=[OBJECTS_API_GROUP_QUERY_PARAMETER], | ||
) | ||
class PluginObjectsAPIObjecttypeVersionListView(ListMixin, APIView): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these views do already seem to exist for registrations, so we might be able to use those instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I can use them as the base class and have the new one here for the different urls as well. I guess you mean I have to do the same for the serializers since some of them are the same with the ones in registrations.
permission_classes = (permissions.IsAdminUser,) | ||
serializer_class = PrefillObjectsAPIAttributeSerializer | ||
|
||
def get_objects(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method should return a list of tuples with each a label and value (e.g. choices)?
EDIT: I just saw parse_schema_properties
and that returns a list of tuples, so I think that's right
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class ObjectsAPIAttributes(models.TextChoices): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we'll need this, this was probably from your initial changes that you made before? @vaszig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably not
FYI @stevenbal , as we discussed with Sergei during standup, I will split this PR in order to be easier for you as well. So I will close this and I will create 2 new ones. |
Closes #4396
Changes
Checklist
Check off the items that are completed or not relevant.
Impact on features
Release management
I have updated the translations assets (you do NOT need to provide translations)
./bin/makemessages_js.sh
./bin/compilemessages_js.sh
Commit hygiene