Как сделать то же самое занятие, но для каждой комнаты, а не для всех комнат. В этом случае, когда эта часть работает, если user.has_perm ('pass_perm', комната), она создает этот сеанс request.session ['join'] = True, но это работает для всех комнат
views.py
def auth_join(request, room, uuid):
room = get_object_or_404(Room, invite_url=uuid)
if request.session.get('joined', False):
join_room(request,uuid)
return HttpResponseRedirect(Room.get_absolute_url(room))
else:
try:
room_type = getattr(Room.objects.get(invite_url=uuid), 'room_type')
except ValueError:
raise Http404
if room_type == 'private':
if request.method == 'POST':
user = request.user.username
form_auth = AuthRoomForm(request.POST)
if form_auth.is_valid():
try:
room_pass = getattr(Room.objects.get(invite_url=uuid), 'room_pass')
except ValueError:
raise Http404
password2 = form_auth.cleaned_data.get('password2')
if room_pass != password2:
messages.error(request, 'Doesn\'t match')
return HttpResponseRedirect(request.get_full_path())
else:
user = CustomUser.objects.get(username=user)
try:
room = get_object_or_404(Room, invite_url=uuid)
except ValueError:
raise Http404
assign_perm('pass_perm',user, room)
if user.has_perm('pass_perm', room):
request.session['joined'] = True
join_room(request,uuid)
return HttpResponseRedirect(Room.get_absolute_url(room))
else:
return HttpResponse('Problem issues')
else:
form_auth = AuthRoomForm()
return render(request,'rooms/auth_join.html', {'form_auth':form_auth})
else:
try:
room = get_object_or_404(Room, invite_url=uuid)
except ValueError:
raise Http404
join_room(request,uuid)
return HttpResponseRedirect(Room.get_absolute_url(room))