Skip to content

Instantly share code, notes, and snippets.

@DanyF-github
Created March 24, 2022 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanyF-github/e75356971f62598cff46cd911586b579 to your computer and use it in GitHub Desktop.
Save DanyF-github/e75356971f62598cff46cd911586b579 to your computer and use it in GitHub Desktop.
django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseForbidden
from django.core.exceptions import PermissionDenied
from lead_manager.models import Lead
@login_required
def lead_conversation_room(request, lead_id):
if not hasattr(request.user, 'agent'):
return PermissionDenied
agent = request.user.agent
try:
lead = agent.leads.get(id=lead_id)
except Lead.DoesNotExist:
return HttpResponseForbidden()
context = {"lead": lead}
return render(request, "conversation/room.html", context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment