[PULP-1496] Add repository-specific package blocklist#1187
[PULP-1496] Add repository-specific package blocklist#1187
Conversation
closes pulp#1166 Assisted By: Claude Opus 4.6
| } | ||
| ``` | ||
|
|
||
| TODO: blocklist docs |
There was a problem hiding this comment.
This is still todo
| blocked.append(pkg.filename) | ||
| break | ||
| if blocked: | ||
| raise ValidationError( |
There was a problem hiding this comment.
This needs to be reworked to avoid the deprecations check
| added_content = PythonPackageContent.objects.filter( | ||
| pk__in=new_version.added().values_list("pk", flat=True) | ||
| ) |
There was a problem hiding this comment.
| added_content = PythonPackageContent.objects.filter( | |
| pk__in=new_version.added().values_list("pk", flat=True) | |
| ) | |
| added_content = PythonPackageContent.objects.filter( | |
| pk__in=new_version.added().values_list("pk", flat=True) | |
| ).only("name_normalized", "version", "filename") |
|
|
||
| blocked = [] | ||
| for pkg in packages: | ||
| pkg_name_normalized = canonicalize_name(pkg.name) if pkg.name else "" |
There was a problem hiding this comment.
| pkg_name_normalized = canonicalize_name(pkg.name) if pkg.name else "" |
Use pkg.name_normalized, it's a required field.
| name = models.TextField(null=True, default=None) | ||
| version = models.TextField(null=True, default=None) | ||
| filename = models.TextField(null=True, default=None) | ||
| added_by = models.TextField(blank=True, default="") |
There was a problem hiding this comment.
Why have this one be blank=True, does that even do anything?
| pulp_href = _NestedIdentityField( | ||
| view_name="blocklist_entries-detail", | ||
| parent_lookup_kwargs={"repository_pk": "repository__pk"}, | ||
| ) |
There was a problem hiding this comment.
Just do what you did for the repository's serializer field and make it a serializer method.
| add_content_units = request.data.get("add_content_units", []) | ||
| if not add_content_units: | ||
| return None | ||
| content_ids = [extract_pk(x) for x in add_content_units] |
There was a problem hiding this comment.
Let's not rerun the extract_pk method multiple times. Find a way for this to already be calculated.
| """ | ||
| Set the repository FK from the URL before saving the entry. | ||
| """ | ||
| serializer.save(repository=self.get_parent_object()) |
There was a problem hiding this comment.
The serializer should already have the repository set inside its context. In validate I would just set the field there and then this method wouldn't be needed.
closes #1166
📜 Checklist
See: Pull Request Walkthrough