Skip to content
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

🧹 Tags: remove double get, sort tags #5620

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ describe("Tags of adventures", () => {
}).as("deleteTag")

cy.wait(500)
cy.get("#tag_2")
cy.get("#tag_1")
.should("be.visible")
.should("include.text", "statements")
cy.get("#tag_2 .fa-circle-xmark")
cy.get("#tag_1 .fa-circle-xmark")
.click()
cy.wait("@deleteTag").should('have.nested.property', 'response.statusCode', 200)
cy.get("#tags_list li")
Expand Down
2 changes: 1 addition & 1 deletion website/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def get_public_tags(self, user, adventure_id):
adventure_id = request.args.get("adventure_id")
adventure = self.db.get_adventure(adventure_id)
if adventure:
adventure = self.db.get_adventure(adventure_id)
# exclude current adventure's tags
public_tags = list(filter(lambda t: t["name"] not in adventure.get("tags", []), public_tags))

Expand Down Expand Up @@ -58,6 +57,7 @@ def create(self, user, adventure_id, new_tag=None):
adventure_tags = db_adventure.get("tags", [])
if tag_name not in adventure_tags:
adventure_tags.append(tag_name)
adventure_tags = sorted(adventure_tags, key=lambda tag: tag)
self.db.update_adventure(adventure_id, {"tags": adventure_tags})
else:
return make_response(gettext("tag_in_adventure"), 400)
Expand Down
Loading