def post(self, request, room): room = Chat_group.objects.get(pk=room) form = GroupRoomEditForm(request.POST, instance=room) if form.is_valid(): form.save() return redirect('chat:group_with_id', group_roomID=str(room.pk)) return redirect('chat:home')
def post(self, request): form = GroupRoomEditForm(request.POST) if form.is_valid(): form.save() the_last_chat = Chat_group.objects.last() return redirect('chat:group_with_id', group_roomID=str(the_last_chat.pk)) return redirect('chat:home')
def get(self, request, room): if room == '0': return redirect('chat:home') else: room = Chat_group.objects.get(pk=room) form = GroupRoomEditForm(user=request.user, instance=room) friend = Friend.objects.get(current_user=request.user) friends = friend.users.all() args = {"form": form, 'friends': friends} return render(request, 'chat/edit_group_room.html', args)
def get(self, request): form = GroupRoomEditForm(user=request.user, initial={'chat_admin': request.user}) args = {"form": form} return render(request, 'chat/create_group_chat.html', args)
def get(self, request): form = GroupRoomEditForm() args = {"form": form} return render(request, 'chat/create_group_chat.html', args)