├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── agents ├── __init__.py ├── admin.py ├── apps.py ├── migrations │ └── __init__.py ├── models.py ├── tests.py └── views.py ├── core ├── __init__.py ├── admin.py ├── apps.py ├── migrations │ └── __init__.py ├── models.py ├── tests.py └── views.py ├── djcrm ├── __init__.py ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py ├── frontend ├── 404.html └── second_page.html ├── help.txt ├── leads ├── __init__.py ├── admin.py ├── apps.py ├── forms.py ├── migrations │ ├── 0001_initial.py │ └── __init__.py ├── models.py ├── templates │ └── leads │ │ ├── lead_create.html │ │ ├── lead_detail.html │ │ ├── lead_list.html │ │ └── lead_update.html ├── tests.py ├── urls.py └── views.py ├── manage.py ├── requirements.txt └── runtime.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at susyswdg@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2022, Jumayev Ubaydullo 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/README.md -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | Security Policy 2 | 3 | The SUSYS team and community take security issues seriously. To report a security issue, write to tommyjumayev@gmail.com 4 | 5 | You can help us make SUSYS and all it's users more secure by following the Reporting guidelines. 6 | 7 | We appreciate your efforts to responsibly disclose your findings. We'll endeavor to respond quickly, and will keep you updated throughout the process. -------------------------------------------------------------------------------- /agents/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/agents/__init__.py -------------------------------------------------------------------------------- /agents/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /agents/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AgentsConfig(AppConfig): 5 | name = 'agents' 6 | -------------------------------------------------------------------------------- /agents/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/agents/migrations/__init__.py -------------------------------------------------------------------------------- /agents/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /agents/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /agents/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/core/__init__.py -------------------------------------------------------------------------------- /core/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /core/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CoreConfig(AppConfig): 5 | name = 'core' 6 | -------------------------------------------------------------------------------- /core/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/core/migrations/__init__.py -------------------------------------------------------------------------------- /core/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /core/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /core/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /djcrm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/djcrm/__init__.py -------------------------------------------------------------------------------- /djcrm/asgi.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from django.core.asgi import get_asgi_application 4 | 5 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djcrm.settings') 6 | 7 | application = get_asgi_application() 8 | -------------------------------------------------------------------------------- /djcrm/settings.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | BASE_DIR = Path(__file__).resolve().parent.parent 4 | 5 | SECRET_KEY = 'ufpsuf=#xm*afaeaur1b8!)jdqq%jlv^fv%zn^yj=a+63)!z6z' 6 | 7 | DEBUG = True 8 | 9 | ALLOWED_HOSTS = [] 10 | 11 | INSTALLED_APPS = [ 12 | 'django.contrib.admin', 13 | 'django.contrib.auth', 14 | 'django.contrib.contenttypes', 15 | 'django.contrib.sessions', 16 | 'django.contrib.messages', 17 | 'django.contrib.staticfiles', 18 | 'leads', 19 | ] 20 | 21 | MIDDLEWARE = [ 22 | 'django.middleware.security.SecurityMiddleware', 23 | 'django.contrib.sessions.middleware.SessionMiddleware', 24 | 'django.middleware.common.CommonMiddleware', 25 | 'django.middleware.csrf.CsrfViewMiddleware', 26 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 27 | 'django.contrib.messages.middleware.MessageMiddleware', 28 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 29 | ] 30 | 31 | ROOT_URLCONF = 'djcrm.urls' 32 | 33 | TEMPLATES = [ 34 | { 35 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 36 | 'DIRS': [ BASE_DIR / "frontend" ], 37 | 'APP_DIRS': True, 38 | 'OPTIONS': { 39 | 'context_processors': [ 40 | 'django.template.context_processors.debug', 41 | 'django.template.context_processors.request', 42 | 'django.contrib.auth.context_processors.auth', 43 | 'django.contrib.messages.context_processors.messages', 44 | ], 45 | }, 46 | }, 47 | ] 48 | 49 | WSGI_APPLICATION = 'djcrm.wsgi.application' 50 | 51 | DATABASES = { 52 | 'default': { 53 | 'ENGINE': 'django.db.backends.sqlite3', 54 | 'NAME': BASE_DIR / 'db.sqlite3', 55 | } 56 | } 57 | AUTH_USER_MODEL = "leads.User" 58 | 59 | AUTH_PASSWORD_VALIDATORS = [ 60 | { 61 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 62 | }, 63 | { 64 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 65 | }, 66 | { 67 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 68 | }, 69 | { 70 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 71 | }, 72 | ] 73 | 74 | LANGUAGE_CODE = 'en-us' 75 | 76 | TIME_ZONE = 'UTC' 77 | 78 | USE_I18N = True 79 | 80 | USE_L10N = True 81 | 82 | USE_TZ = True 83 | 84 | 85 | STATIC_URL = '/static/' 86 | -------------------------------------------------------------------------------- /djcrm/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path, include 3 | 4 | urlpatterns = [ 5 | path('admin/', admin.site.urls), 6 | path('leads/', include('leads.urls', namespace="leads")) 7 | ] 8 | -------------------------------------------------------------------------------- /djcrm/wsgi.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from django.core.wsgi import get_wsgi_application 4 | 5 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djcrm.settings') 6 | 7 | application = get_wsgi_application() 8 | -------------------------------------------------------------------------------- /frontend/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | Not found 11 | 12 | -------------------------------------------------------------------------------- /frontend/second_page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |

Hello world

11 |

Second Page

12 | 13 | 14 | -------------------------------------------------------------------------------- /help.txt: -------------------------------------------------------------------------------- 1 | https://stackoverflow.com/questions/49189402/auth-user-groups-fields-e304-reverse-accessor-for-user-groups-clashes-with 2 | For abstract user 3 | 4 | -------------------------------------------------------------------------------- /leads/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/leads/__init__.py -------------------------------------------------------------------------------- /leads/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from .models import User, Lead, Agent 4 | 5 | admin.site.register(User) 6 | admin.site.register(Lead) 7 | admin.site.register(Agent) 8 | -------------------------------------------------------------------------------- /leads/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class LeadsConfig(AppConfig): 5 | name = 'leads' 6 | -------------------------------------------------------------------------------- /leads/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import Lead 3 | 4 | class LeadModelForm(forms.ModelForm): 5 | class Meta: 6 | model = Lead 7 | fields = ( 8 | 'first_name', 9 | 'last_name', 10 | 'age', 11 | 'agent' 12 | ) 13 | 14 | 15 | class LeadForm(forms.Form): 16 | first_name = forms.CharField() 17 | last_name = forms.CharField() 18 | age = forms.IntegerField(min_value=0) -------------------------------------------------------------------------------- /leads/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.4 on 2021-06-22 16:05 2 | 3 | from django.conf import settings 4 | import django.contrib.auth.models 5 | import django.contrib.auth.validators 6 | from django.db import migrations, models 7 | import django.db.models.deletion 8 | import django.utils.timezone 9 | 10 | 11 | class Migration(migrations.Migration): 12 | 13 | initial = True 14 | 15 | dependencies = [ 16 | ('auth', '0012_alter_user_first_name_max_length'), 17 | ] 18 | 19 | operations = [ 20 | migrations.CreateModel( 21 | name='User', 22 | fields=[ 23 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 24 | ('password', models.CharField(max_length=128, verbose_name='password')), 25 | ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), 26 | ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), 27 | ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), 28 | ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), 29 | ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), 30 | ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), 31 | ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), 32 | ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), 33 | ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), 34 | ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), 35 | ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), 36 | ], 37 | options={ 38 | 'verbose_name': 'user', 39 | 'verbose_name_plural': 'users', 40 | 'abstract': False, 41 | }, 42 | managers=[ 43 | ('objects', django.contrib.auth.models.UserManager()), 44 | ], 45 | ), 46 | migrations.CreateModel( 47 | name='Agent', 48 | fields=[ 49 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 50 | ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 51 | ], 52 | ), 53 | migrations.CreateModel( 54 | name='Lead', 55 | fields=[ 56 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 57 | ('first_name', models.CharField(max_length=20)), 58 | ('last_name', models.CharField(max_length=20)), 59 | ('age', models.IntegerField(default=0)), 60 | ('agent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leads.agent')), 61 | ], 62 | ), 63 | ] 64 | -------------------------------------------------------------------------------- /leads/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/leads/migrations/__init__.py -------------------------------------------------------------------------------- /leads/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import AbstractUser 3 | 4 | class User(AbstractUser): 5 | pass 6 | 7 | class Lead(models.Model): 8 | first_name = models.CharField(max_length=20) 9 | last_name = models.CharField(max_length=20) 10 | age = models.IntegerField(default=0) 11 | agent = models.ForeignKey("Agent", on_delete=models.CASCADE) 12 | 13 | def __str__(self): 14 | return f"{self.first_name} {self.last_name}" 15 | 16 | class Agent(models.Model): 17 | user = models.OneToOneField("User", on_delete=models.CASCADE) 18 | 19 | def __str__(self): 20 | return self.user.username -------------------------------------------------------------------------------- /leads/templates/leads/lead_create.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | Go Back to leads 12 |
13 |

Create a new lead

14 |
15 | {% csrf_token %} 16 | {{ form.as_p }} 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /leads/templates/leads/lead_detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 19 | 20 | 21 | 22 | Go Back to leads 23 |
24 |

This is all details of {{ lead.first_name }}

25 |

This person age: {{ lead.age }}

26 |
27 | Update 28 | Delete 29 | 30 | -------------------------------------------------------------------------------- /leads/templates/leads/lead_list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 19 | 20 | 21 | 22 | Create a new Lead 23 |
24 |

This is all of our leads

25 | {% for lead in leads %} 26 |
27 | {{ lead.first_name }} {{ lead.last_name }} Age: {{ lead.age }} 28 |
29 | {% endfor %} 30 | 31 | -------------------------------------------------------------------------------- /leads/templates/leads/lead_update.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | Go Back to leads 12 |
13 |

Update lead: {{ lead.first_name }} {{ lead.last_name }}

14 |
15 | {% csrf_token %} 16 | {{ form.as_p }} 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /leads/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | -------------------------------------------------------------------------------- /leads/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from .views import * 3 | 4 | app_name = "leads" 5 | 6 | urlpatterns = [ 7 | path('', lead_list), 8 | path('/', lead_detail), 9 | path('/update/', lead_update), 10 | path('/delete/', lead_delete), 11 | path('create/', lead_create), 12 | ] 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /leads/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, redirect 2 | from django.http import HttpResponse 3 | from .models import Lead, Agent 4 | from .forms import LeadForm, LeadModelForm 5 | 6 | def lead_list(request): 7 | leads = Lead.objects.all() 8 | context = { 9 | "leads": leads 10 | } 11 | return render(request, "leads/lead_list.html", context) 12 | 13 | def lead_detail(request, pk): 14 | lead = Lead.objects.get(id=pk) 15 | context = { 16 | "lead": lead 17 | } 18 | return render(request, "leads/lead_detail.html", context) 19 | 20 | def lead_create(request): 21 | form = LeadModelForm() 22 | if request.method == "POST": 23 | form = LeadModelForm(request.POST) 24 | if form.is_valid(): 25 | form.save() 26 | return redirect("/leads") 27 | context = { 28 | "form": form 29 | } 30 | return render(request, "leads/lead_create.html", context) 31 | 32 | def lead_update(request, pk): 33 | lead = Lead.objects.get(id=pk) 34 | form = LeadModelForm(instance=lead) 35 | if request.method == "POST": 36 | form = LeadModelForm(request.POST, instance=lead) 37 | if form.is_valid(): 38 | form.save() 39 | return redirect("/leads") 40 | context = { 41 | "form": form, 42 | "lead": lead 43 | } 44 | return render(request, "leads/lead_update.html", context) 45 | 46 | def lead_delete(request, pk): 47 | lead = Lead.objects.get(id=pk) 48 | lead.delete() 49 | return redirect("/leads") 50 | 51 | 52 | 53 | 54 | 55 | # def lead_update(request, pk): 56 | # lead = Lead.objects.get(id=pk) 57 | # form = LeadForm() 58 | # if request.method == "POST": 59 | # form = LeadForm(request.POST) 60 | # if form.is_valid(): 61 | # first_name = form.cleaned_data['first_name'] 62 | # last_name = form.cleaned_data['last_name'] 63 | # age = form.cleaned_data['age'] 64 | # lead.first_name = first_name 65 | # lead.last_name = last_name 66 | # lead.age = age 67 | # lead.save() 68 | # return redirect("/leads") 69 | # context = { 70 | # "form": form, 71 | # "lead": lead 72 | # } 73 | # return render(request, "leads/lead_update.html", context) 74 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djcrm.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/django_crm/c2e7c13bcc30f1878594228f01e15c186455a097/requirements.txt -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.10.8 --------------------------------------------------------------------------------