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

Function Patterns #234

Open
ryaustin opened this issue Feb 29, 2024 · 0 comments
Open

Function Patterns #234

ryaustin opened this issue Feb 29, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@ryaustin
Copy link
Collaborator

HI Jeff, here's a snap of what we discussed last regarding function patterns.

@login_required
def tune_list(request):
    user = request.user
    tunes = RepertoireTune.objects.select_related("tune").filter(player=user)
    tune_count = len(tunes)
    template_name = "tune/list.html"

    if request.method == "POST":
        search_form = SearchForm(request.POST)
        if search_form.is_valid():
            search_terms = search_form.cleaned_data["search_term"].split(" ")
            results = return_search_results(request, search_terms, tunes, search_form)
            tunes = results.get("tunes")
            tune_count = results.get("tune_count")

    else:
        search_form = SearchForm()
    data_dict = {"tunes": tunes, "search_form": search_form, "tune_count": tune_count}
    request.session["tune_count"] = tune_count
    return render(
        request,
        template_name=template_name,
        context=data_dict,
    )
@ryaustin ryaustin added the documentation Improvements or additions to documentation label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants