-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add tags/roles and tags/collections endpoints #1931
Merged
jerabekjiri
merged 13 commits into
ansible:master
from
jerabekjiri:feature/roles-and-collections-tags-endpoint
Nov 1, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0df841b
add sorting and filtering tags api
jerabekjiri 21edbdb
add tags/collections int test
jerabekjiri 6d36539
add tags roles endpoint
jerabekjiri d2c2a88
add test
jerabekjiri a578810
add changelog
jerabekjiri 34de347
remove unused test
jerabekjiri e6beed6
must be single line
jerabekjiri 98a389b
fix gettext problem
jerabekjiri cc078fd
add django command to populate roles tags
jerabekjiri 0ff8f1f
add command unit test
jerabekjiri fc5a28e
refactor role tags endpoint test
jerabekjiri 7e7f008
rebase and add command output
jerabekjiri 44989af
add more info about command
jerabekjiri 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 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 @@ | ||
Add _ui/v1/tags/collections and _ui/v1/tags/roles endpoints. Add sorting by name and count, and enable filtering by name (exact, partial and startswith match). |
This file contains 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 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 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 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 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 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,36 @@ | ||
from gettext import gettext as _ | ||
|
||
import django_guid | ||
from django.core.management.base import BaseCommand | ||
|
||
# from galaxy_ng.app.api.v1.tasks import legacy_sync_from_upstream | ||
from galaxy_ng.app.api.v1.models import LegacyRole, LegacyRoleTag | ||
|
||
|
||
# Set logging_uid, this does not seem to get generated when task called via management command | ||
django_guid.set_guid(django_guid.utils.generate_guid()) | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Django management command for populating role tags ('_ui/v1/tags/roles/') within the system. | ||
This command is run nightly on galaxy.ansible.com. | ||
""" | ||
|
||
help = _("Populate the 'LegacyRoleTag' model with tags from LegacyRole 'full_metadata__tags'.") | ||
|
||
def handle(self, *args, **options): | ||
created_tags = [] | ||
roles = LegacyRole.objects.all() | ||
for role in roles: | ||
for name in role.full_metadata["tags"]: | ||
tag, created = LegacyRoleTag.objects.get_or_create(name=name) | ||
tag.legacyrole.add(role) | ||
|
||
if created: | ||
created_tags.append(tag) | ||
|
||
self.stdout.write( | ||
"Successfully populated {} tags " | ||
"from {} roles.".format(len(created_tags), len(roles)) | ||
) |
31 changes: 31 additions & 0 deletions
31
galaxy_ng/app/migrations/0043_legacyroletag_legacyrole_tags.py
This file contains 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,31 @@ | ||
# Generated by Django 4.2.6 on 2023-10-25 21:26 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("galaxy", "0042_namespace_created_namespace_updated"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="LegacyRoleTag", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
("name", models.CharField(editable=False, max_length=64, unique=True)), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name="legacyrole", | ||
name="tags", | ||
field=models.ManyToManyField( | ||
editable=False, related_name="legacyrole", to="galaxy.legacyroletag" | ||
), | ||
), | ||
] |
Oops, something went wrong.
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.
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.
does it really need to use the
crossrepo
index? for community we have only one repo and it would be faster to just take the is_highest from the single repo.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.
That's true, but then this wouldn't work for PAH and CRC