-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8a1dd1
commit 932d9e9
Showing
83 changed files
with
1,367 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AgentsConfig(AppConfig): | ||
name = 'agents' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django import forms | ||
|
||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.forms import UserCreationForm | ||
|
||
|
||
User=get_user_model() | ||
class AgentModelForm(forms.ModelForm): | ||
class Meta: | ||
model=User | ||
fields={ | ||
'email', | ||
'username', | ||
'first_name', | ||
'last_name' | ||
} |
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.contrib.auth.mixins import AccessMixin | ||
from django.shortcuts import redirect | ||
|
||
|
||
class OrganiserandLoginRequiredMixin(AccessMixin): | ||
def dispatch(self,request,*args,**kwargs): | ||
if not request.user.is_authenticated or not request.user.is_organiser: | ||
return redirect("leads:lead-list") | ||
return super().dispatch(request,*args,**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<a href="{% url 'agents:agent-list' %}">Go back to agents</a> | ||
<hr> | ||
<!--[if lt IE 7]> | ||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p> | ||
<![endif]--> | ||
<h1>Create a new Agent </h1> | ||
<form method="POST" action="."> | ||
{% csrf_token %} | ||
{{form.as_p }} | ||
<button type="submit">Submit</button> | ||
</form> | ||
<script src="" async defer></script> | ||
{%endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<a href="{% url 'agents:agent-list' %}">Go back to agents</a> | ||
<hr> | ||
<!--[if lt IE 7]> | ||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p> | ||
<![endif]--> | ||
<h1>Are you sure you want to delete this agent </h1> | ||
<form method="POST" action="."> | ||
{% csrf_token %} | ||
{{form.as_p }} | ||
<button type="submit">Submit</button> | ||
</form> | ||
<script src="" async defer></script> | ||
{%endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<body> | ||
|
||
<section class="text-gray-600 body-font overflow-hidden"> | ||
<div class="container px-5 py-24 mx-auto"> | ||
<div class="lg:w-4/5 mx-auto flex flex-wrap"> | ||
<div class="lg:w-1/2 w-full lg:pr-10 lg:py-6 mb-6 lg:mb-0"> | ||
<h2 class="text-sm title-font text-gray-500 tracking-widest">AGENT</h2> | ||
<h1 class="text-gray-900 text-3xl title-font font-medium mb-4">{{agent.user.username}}</h1> | ||
<div class="flex mb-4"> | ||
<a class="flex-grow text-indigo-500 border-b-2 border-indigo-500 py-2 text-lg px-1">Description</a> | ||
<a class="flex-grow border-b-2 border-gray-300 py-2 text-lg px-1">Reviews</a> | ||
<a href="{% url 'agents:agent-update' agent.pk %}" class="flex-grow border-b-2 border-gray-300 py-2 text-lg px-1">Details</a> | ||
</div> | ||
<p class="leading-relaxed mb-4">Fam locavore kickstarter distillery. Mixtape chillwave tumeric sriracha taximy chia microdosing tilde DIY. XOXO fam inxigo juiceramps cornhole raw denim forage brooklyn. Everyday carry +1 seitan poutine tumeric. Gastropub blue bottle austin listicle pour-over, neutra jean.</p> | ||
<div class="flex border-t border-gray-200 py-2"> | ||
<span class="text-gray-500">Age</span> | ||
<span class="ml-auto text-gray-900">{{ lead.age }}</span> | ||
</div> | ||
<div class="flex border-t border-gray-200 py-2"> | ||
<span class="text-gray-500">Location</span> | ||
<span class="ml-auto text-gray-900">Dummy Location</span> | ||
</div> | ||
<div class="flex border-t border-b mb-6 border-gray-200 py-2"> | ||
<span class="text-gray-500">Cell Phone</span> | ||
<span class="ml-auto text-gray-900">+123123123</span> | ||
</div> | ||
<div class="flex"> | ||
<span class="title-font font-medium text-2xl text-gray-900">$58.00</span> | ||
<button class="flex ml-auto text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded">Button</button> | ||
<button class="rounded-full w-10 h-10 bg-gray-200 p-0 border-0 inline-flex items-center justify-center text-gray-500 ml-4"> | ||
<svg fill="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-5 h-5" viewBox="0 0 24 24"> | ||
<path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z"></path> | ||
</svg> | ||
</button> | ||
</div> | ||
</div> | ||
<img alt="ecommerce" class="lg:w-1/2 w-full lg:h-auto h-64 object-cover object-center rounded" src="https://dummyimage.com/400x400"> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
|
||
<section class="text-gray-600 body-font"> | ||
<div class="container px-5 py-24 mx-auto flex flex-wrap"> | ||
<div class= "w-full mb-6 py-6 flex justify-between items-center border-b border-gray-200"> | ||
<div> | ||
<h1>Agents</h1> | ||
</div> | ||
<div> | ||
<a class="text-gray-500 hover:text-blue-500" href="{% url 'agents:agent-create' %}">Create a new Agent</a> | ||
</div> | ||
</div> | ||
<div class="flex flex-wrap -m-4"> | ||
{% for agent in object_list %} | ||
<div class="p-4 lg:w-1/2 md:w-full"> | ||
<div class="flex border-2 rounded-lg border-gray-200 border-opacity-50 p-8 sm:flex-row flex-col"> | ||
<div class="w-16 h-16 sm:mr-8 sm:mb-0 mb-4 inline-flex items-center justify-center rounded-full bg-indigo-100 text-indigo-500 flex-shrink-0"> | ||
<svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-8 h-8" viewBox="0 0 24 24"> | ||
<path d="M22 12h-4l-3 9L9 3l-3 9H2"></path> | ||
</svg> | ||
</div> | ||
<div class="flex-grow"> | ||
<h2 class="text-gray-900 text-lg title-font font-medium mb-3"> | ||
{{agent.user.username}} | ||
</h2> | ||
<p class="leading-relaxed text-base"> | ||
Blue bottle crucifix vinyl post-ironic four dollar toast vegan taxidermy. Gastropub indxgo juice poutine.</p> | ||
<a href="{% url 'agents:agent-detail' agent.pk%}" class="mt-3 text-indigo-500 inline-flex items-center">View This Agent | ||
<svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-4 h-4 ml-2" viewBox="0 0 24 24"> | ||
<path d="M5 12h14M12 5l7 7-7 7"></path> | ||
</svg> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</section> | ||
|
||
|
||
|
||
{% endblock content %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
|
||
|
||
<section class="text-gray-600 body-font overflow-hidden"> | ||
<div class="container px-5 py-24 mx-auto"> | ||
<div class="lg:w-4/5 mx-auto flex flex-wrap"> | ||
<div class="lg:w-1/2 w-full lg:pr-10 lg:py-6 mb-6 lg:mb-0"> | ||
<h2 class="text-sm title-font text-gray-500 tracking-widest">agent</h2> | ||
<h1 class="text-gray-900 text-3xl title-font font-medium mb-4">{{agent.user.username}}</h1> | ||
<div class="flex mb-4"> | ||
<a href="{% url 'agents:agent-detail' agent.pk %}" class="flex-grow border-b-2 border-gray-300 py-2 text-lg px-1">Description</a> | ||
<a class="flex-grow border-b-2 border-gray-300 py-2 text-lg px-1">Reviews</a> | ||
<a href="{% url 'agents:agent-update' agent.pk %}" class="flex-grow text-indigo-500 border-b-2 border-indigo-500 py-2 text-lg px-1">Update Details</a> | ||
</div> | ||
<form method="POST" > | ||
{% csrf_token %} | ||
{{form.as_p}} | ||
<button type="submit" action="/agents" class="flex ml-auto text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded">Submit</button> | ||
<a href="{% url 'agents:agent-delete' agent.pk %}" class="w-1/4 mt-3 flex ml-auto text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded">Delete</a> | ||
|
||
</form> | ||
</div> | ||
<img alt="ecommerce" class="lg:w-1/2 w-full lg:h-auto h-64 object-cover object-center rounded" src="https://dummyimage.com/400x400"> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
|
||
|
||
|
||
|
||
<a href="{% url 'agents:agent-detail' agent.pk %}">Go back to {{agent.user.username}}</a> | ||
<hr> | ||
<h1>Update agent: {{agent.first_name}} {{agent.last_name}}</h1> | ||
<!--[if lt IE 7]> | ||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p> | ||
<![endif]--> | ||
|
||
<form method="POST" > | ||
{% csrf_token %} | ||
{{form.as_p}} | ||
<button type="submit" action="/agents">Submit</button> | ||
</form> | ||
<script src="" async defer></script> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.urls import path | ||
from .views import ( | ||
AgentListView,AgentCreateView, | ||
AgentDetailView,AgentUpdateView,AgentDeleteView | ||
|
||
) | ||
app_name='agents' | ||
|
||
urlpatterns=[ | ||
path('',AgentListView.as_view(),name='agent-list'), | ||
path('create/',AgentCreateView.as_view(),name='agent-create'), | ||
path('<int:pk>/',AgentDetailView.as_view(),name='agent-detail'), | ||
path('<int:pk>/update/',AgentUpdateView.as_view(),name='agent-update'), | ||
path('<int:pk>/delete/',AgentDeleteView.as_view(),name='agent-delete') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from django.shortcuts import render | ||
from django.views import generic | ||
import random | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from leads.models import Agent | ||
from django.shortcuts import reverse | ||
from .forms import AgentModelForm | ||
from .mixins import OrganiserandLoginRequiredMixin | ||
from django.core.mail import send_mail | ||
# Create your views here. | ||
|
||
class AgentListView(OrganiserandLoginRequiredMixin,generic.ListView): | ||
template_name="agent_list.html" | ||
|
||
def get_queryset(self): | ||
organisation=self.request.user.userprofile | ||
return Agent.objects.filter(organisation=organisation) | ||
|
||
|
||
class AgentCreateView(OrganiserandLoginRequiredMixin,generic.CreateView): | ||
template_name="agent_create.html" | ||
form_class=AgentModelForm | ||
|
||
|
||
def form_valid(self,form): | ||
user=form.save(commit=False) | ||
user.is_agent=True | ||
user.is_organiser=False | ||
user.set_password(f"{random.randint(0,1000000)}") | ||
user.save() | ||
Agent.objects.create( | ||
user=user, | ||
organisation=self.request.user.userprofile | ||
|
||
) | ||
send_mail( | ||
subject="You are invited to be an Agent", | ||
message="You were added as an agent on CRM", | ||
from_email='[email protected]', | ||
recipient_list=[user.email] | ||
) | ||
return super(AgentCreateView,self).form_valid(form) | ||
def get_success_url(self): | ||
return reverse("agents:agent-list") | ||
|
||
class AgentDetailView(OrganiserandLoginRequiredMixin,generic.DetailView): | ||
template_name="agent_detail.html" | ||
context_object_name='agent' | ||
def get_queryset(self): | ||
return Agent.objects.all() | ||
|
||
|
||
class AgentUpdateView(OrganiserandLoginRequiredMixin,generic.UpdateView): | ||
template_name="agent_update.html" | ||
form_class=AgentModelForm | ||
def get_queryset(self): | ||
return Agent.objects.all() | ||
|
||
def get_success_url(self): | ||
return reverse("agents:agent-list") | ||
|
||
class AgentDeleteView(OrganiserandLoginRequiredMixin,generic.DeleteView): | ||
template_name="agent_delete.html" | ||
context_object_name='agent' | ||
def get_queryset(self): | ||
return Agent.objects.all() | ||
def get_success_url(self): | ||
return reverse("agents:agent-list") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
python manage.py runserver | ||
python manage.py startapp leads | ||
python manage.py makemigrations │ | ||
python manage.py migrate |
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for djcrm project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djcrm.settings') | ||
|
||
application = get_asgi_application() |
Oops, something went wrong.