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

TA: Re-implement Team Name Similarity Check in the API #373

Open
Jayden876212 opened this issue Jul 4, 2024 · 0 comments
Open

TA: Re-implement Team Name Similarity Check in the API #373

Jayden876212 opened this issue Jul 4, 2024 · 0 comments
Labels
backend API or backend work feature: teams structure feature New business value from new capabilities

Comments

@Jayden876212
Copy link
Collaborator

Team Name Similarity Check

Conversation

#367 (comment)

Code (in forms.py)

def name_similarity(self) -> float:
"""Returns float between 0 and 1 depending on the similarity
of the current name compared to existing team names. Returns
NoneType if there are no similarities."""
teams = Team.objects.all()
for team in teams:
similarity = SequenceMatcher(None, self["name"].value(), team.name).ratio()
if similarity >= 0.9:
return similarity

Code (when accessing the from from forms.py in a view)

This includes views like create_team().

        form = CreateTeamForm(request.POST)
        if form.name_similarity():
            # TODO: write code to tell the user that their team name is similar and to give them
            # options to change the team name.
            return HttpResponse(
                "Debug: Did not create form because the name is too similar to another team name"
            )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend API or backend work feature: teams structure feature New business value from new capabilities
Projects
None yet
Development

No branches or pull requests

1 participant