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 notes in API #375

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

TA: Re-implement team notes in API #375

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 frontend UI or frontend work

Comments

@Jayden876212
Copy link
Collaborator

Team Notes

URL Patterns (in urls.py)

    path("teams/misc/<int:id>", teams.team_misc, name="misc"),

Code (in teams_utils.py)

def is_member(user, team_id) -> bool:
    """ Determines if the user is a member of the team before accessing its contents """

    team = Relationship.objects.filter(team=Team.objects.get(id=team_id))

    # Boolean determines if viewer is in this team
    for rel in team:
        if rel.user == user:
            return True

Code (in teams.py)

@login_required
def team_misc(request, id):
    """Teams Miscellaneous/Notes page"""
    if is_member(user=request.user, team_id=id):
        team = Team.objects.get(id=id)

        notes = CreateTeamForm(instance=team)

        # TODO: Add a field to each team with a notes section - (for now it's just the teams description)

        if "value" in request.GET:
            team.notes = request.GET["value"]
            team.save()

        desc = team.description
        notes = team.notes

        return render(
            request, "teams/misc.html", {"team": team, "desc": desc, "notes": notes}
        )
    return redirect("dashboard")

Description

The button already exists in the page when you press "View" on a team you are in, it just does nothing when you click it:

image

image

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 frontend UI or frontend work
Projects
None yet
Development

No branches or pull requests

1 participant