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/7fe44bc2631182cb3b3e60b964b5ca84 to your computer and use it in GitHub Desktop.
Save DanyF-github/7fe44bc2631182cb3b3e60b964b5ca84 to your computer and use it in GitHub Desktop.
django.contrib.auth.views import LoginView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from django.views.generic.base import TemplateView
class AgentLoginView(LoginView):
template_name = 'lead_manager/agent_login.html'
class AgentDashboardView(LoginRequiredMixin, TemplateView):
template_name = 'lead_manager/agent_dashboard.html'
def dispatch(self, request, *args, **kwargs):
if not hasattr(request.user, 'agent'):
raise PermissionDenied
return super().dispatch(request, *args, **kwargs)
def get(self, request):
assigned_leads = request.user.agent.leads.all()
context = {
'assigned_leads': assigned_leads,
}
return self.render_to_response(context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment