Allow users to join their own team's projects

Fix #56

Looked into this for a while, but I think it was simply an oversight in
the logic-as-programmed; if you're part of a team, you should be able
to just click 'join' on any of that team's projects and be a project-member
This commit is contained in:
Klaas van Schelven
2025-04-03 16:28:35 +02:00
parent 427a2a341e
commit 8fc6f752cf
2 changed files with 4 additions and 5 deletions

View File

@@ -8,7 +8,7 @@ from bugsink.app_settings import get_settings
from compat.dsn import build_dsn
from teams.models import TeamMembership, TeamRole
from teams.models import TeamMembership
class ProjectRole(models.IntegerChoices):
@@ -104,9 +104,8 @@ class Project(models.Model):
if user is not None:
# take the user's team membership into account
try:
tm = TeamMembership.objects.get(team=self.team, user=user)
if tm.role == TeamRole.ADMIN:
return True
TeamMembership.objects.get(team=self.team, user=user)
return True
except TeamMembership.DoesNotExist:
pass

View File

@@ -137,7 +137,7 @@
</div>
{% endif %}
{% else %}
{% if project.is_joinable or request.user.is_superuser %}
{% if ownership_filter == "teams" or project.is_joinable or request.user.is_superuser %}{# ownership_filter check: you can always join your own team's projects, so if you're looking at a list of them... #}
<div>
<button name="action" value="join:{{ project.id }}" class="font-bold text-slate-500 border-slate-300 pl-4 pr-4 pb-2 pt-2 ml-1 border-2 hover:bg-slate-200 active:ring rounded-md">Join</button>
</div>