Exemple #1
0
    def clean(self):
        if not user_without_team(self.user):
            raise ValidationError('User is already a team member')

        if self.status == 'P' and self.user.userteamrequest_set.filter(
                status='P').exists():
            raise ValidationError('Other pending request exists')

        if self.status == 'P' and self.user.userteamrequest_set.filter(
                status='A').exists():
            raise ValidationError('Other accepted request exists')
Exemple #2
0
def no_team_view(request, create_form=TeamCreateForm(), join_form=UserTeamRequestCreateForm()):
    # TODO: use permissions
    if not user_without_team(request.user):
        return redirect('index')

    pending_request = request.user.userteamrequest_set.pending().first()
    if pending_request:
        return render(request, 'accounts/pending_request.html', dict(join_request=pending_request))

    return render(request, 'accounts/no_team.html', dict(
        team_create_form=create_form,
        team_join_form=join_form,
        teams=Team.objects.all(),
        join_request_rejected=request.user.userteamrequest_set.rejected().exists()
    ))
Exemple #3
0
 def has_permission(self, request, view):
     return user_without_team(request.user)
Exemple #4
0
 def custom_filter(self, request):
     return user_without_team(request.user)