Skip to content

Commit

Permalink
Addressing PR comments
Browse files Browse the repository at this point in the history
- Updated the success message to user
- cleaned up some print statements
- updated the form max_length to match the taggit model
- updated the form html to extend the base so the styling matched
  • Loading branch information
guel-codes committed Jul 18, 2024
1 parent cbf9bd2 commit d0fe810
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions taggit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ def merge_tags_view(self, request):
TaggedItem.objects.filter(tag=tag).update(tag=new_tag)

Check warning on line 62 in taggit/admin.py

View check run for this annotation

Codecov / codecov/patch

taggit/admin.py#L61-L62

Added lines #L61 - L62 were not covered by tests
# tag.delete() #this will delete the selected tags after merge...leaving out for now

self.message_user(request, "Tags have been merged")
self.message_user(request, "Tags have been merged", level="success")

Check warning on line 65 in taggit/admin.py

View check run for this annotation

Codecov / codecov/patch

taggit/admin.py#L65

Added line #L65 was not covered by tests
# clear the selected_tag_ids from session after merge is complete
request.session.pop("selected_tag_ids", None)

Check warning on line 67 in taggit/admin.py

View check run for this annotation

Codecov / codecov/patch

taggit/admin.py#L67

Added line #L67 was not covered by tests

return redirect("..")

Check warning on line 69 in taggit/admin.py

View check run for this annotation

Codecov / codecov/patch

taggit/admin.py#L69

Added line #L69 was not covered by tests
else:
print(f"Form errors: {form.errors}")
self.message_user(request, "Form is invalid.", level="error")

Check warning on line 71 in taggit/admin.py

View check run for this annotation

Codecov / codecov/patch

taggit/admin.py#L71

Added line #L71 was not covered by tests

context = {

Check warning on line 73 in taggit/admin.py

View check run for this annotation

Codecov / codecov/patch

taggit/admin.py#L73

Added line #L73 was not covered by tests
"form": MergeTagsForm(),
"selected_tag_ids": selected_tag_ids,
}

return render(request, "admin/taggit/merge_tags_form.html", context)

Check warning on line 77 in taggit/admin.py

View check run for this annotation

Codecov / codecov/patch

taggit/admin.py#L77

Added line #L77 was not covered by tests
2 changes: 1 addition & 1 deletion taggit/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ def has_changed(self, initial_value, data_value):
class MergeTagsForm(forms.Form):
new_tag_name = forms.CharField(
label="New Tag Name",
max_length=255,
max_length=100,
widget=forms.TextInput(attrs={"id": "id_new_tag_name"}),
)
4 changes: 3 additions & 1 deletion taggit/templates/admin/taggit/merge_tags_form.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% extends "admin/base.html" %} {% block content %}
<div id="mergeTagsModal">
<div>
<div>
Expand All @@ -20,10 +21,11 @@
{% endfor %}

<div>
<button type="submit" class="btn btn-primary">Merge Tags</button>
<input type="submit" class="btn btn-primary"></input>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

0 comments on commit d0fe810

Please sign in to comment.