├── customer ├── __init__.py ├── migrations │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ └── 0001_initial.cpython-310.pyc │ └── 0001_initial.py ├── admin.py ├── tests.py ├── apps.py ├── __pycache__ │ ├── urls.cpython-310.pyc │ ├── admin.cpython-310.pyc │ ├── forms.cpython-310.pyc │ ├── models.cpython-310.pyc │ ├── views.cpython-310.pyc │ └── __init__.cpython-310.pyc ├── forms.py ├── models.py ├── urls.py └── views.py ├── insurance ├── __init__.py ├── migrations │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ ├── 0001_initial.cpython-310.pyc │ │ ├── 0002_policy.cpython-310.pyc │ │ ├── 0004_question.cpython-310.pyc │ │ └── 0003_policyrecord.cpython-310.pyc │ ├── 0001_initial.py │ ├── 0004_question.py │ ├── 0003_policyrecord.py │ └── 0002_policy.py ├── admin.py ├── tests.py ├── apps.py ├── __pycache__ │ ├── admin.cpython-310.pyc │ ├── forms.cpython-310.pyc │ ├── views.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ └── models.cpython-310.pyc ├── forms.py ├── models.py └── views.py ├── insurancemanagement ├── __init__.py ├── __pycache__ │ ├── urls.cpython-310.pyc │ ├── wsgi.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ └── settings.cpython-310.pyc ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── templates ├── insurance │ ├── footer.html │ ├── logout.html │ ├── index.html │ ├── contactussuccess.html │ ├── admin_view_category.html │ ├── admin_view_approved_policy_holder.html │ ├── admin_view_disapproved_policy_holder.html │ ├── admin_view_waiting_policy_holder.html │ ├── admin_add_category.html │ ├── admin_delete_category.html │ ├── admin_update_category.html │ ├── admin_view_policy.html │ ├── update_category.html │ ├── admin_update_policy.html │ ├── admin_delete_policy.html │ ├── update_question.html │ ├── navbar.html │ ├── admin_question.html │ ├── admin_add_policy.html │ ├── admin_view_customer.html │ ├── admin_view_policy_holder.html │ ├── update_policy.html │ ├── update_customer.html │ ├── adminlogin.html │ ├── admin_category.html │ ├── adminbase.html │ ├── admin_policy.html │ └── admin_dashboard.html └── customer │ ├── customerclick.html │ ├── history.html │ ├── question_history.html │ ├── ask_question.html │ ├── apply_policy.html │ ├── customersignup.html │ ├── customer_dashboard.html │ └── customerbase.html ├── db.sqlite3 ├── static ├── image │ ├── admin.png │ └── logout_img.png ├── screenshots │ ├── homepage.jpg │ ├── policy.png │ ├── dashboard.png │ └── policyrecord.png └── profile_pic │ └── Customer │ ├── lazy.PNG │ └── nn.jpg ├── requirements.txt ├── manage.py ├── LICENSE └── README.md /customer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insurance/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /customer/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insurance/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insurancemanagement/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/insurance/footer.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /customer/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /customer/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /insurance/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /insurance/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /static/image/admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/static/image/admin.png -------------------------------------------------------------------------------- /static/image/logout_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/static/image/logout_img.png -------------------------------------------------------------------------------- /static/screenshots/homepage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/static/screenshots/homepage.jpg -------------------------------------------------------------------------------- /static/screenshots/policy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/static/screenshots/policy.png -------------------------------------------------------------------------------- /customer/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CustomerConfig(AppConfig): 5 | name = 'customer' 6 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.2.7 2 | Django==3.0.5 3 | django-widget-tweaks==1.4.8 4 | pytz==2020.1 5 | sqlparse==0.3.1 6 | 7 | -------------------------------------------------------------------------------- /static/screenshots/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/static/screenshots/dashboard.png -------------------------------------------------------------------------------- /insurance/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class InsuranceConfig(AppConfig): 5 | name = 'insurance' 6 | -------------------------------------------------------------------------------- /static/profile_pic/Customer/lazy.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/static/profile_pic/Customer/lazy.PNG -------------------------------------------------------------------------------- /static/profile_pic/Customer/nn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/static/profile_pic/Customer/nn.jpg -------------------------------------------------------------------------------- /static/screenshots/policyrecord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/static/screenshots/policyrecord.png -------------------------------------------------------------------------------- /customer/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/customer/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /customer/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/customer/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /customer/__pycache__/forms.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/customer/__pycache__/forms.cpython-310.pyc -------------------------------------------------------------------------------- /customer/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/customer/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /customer/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/customer/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/__pycache__/forms.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/__pycache__/forms.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /customer/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/customer/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /insurancemanagement/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurancemanagement/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /insurancemanagement/__pycache__/wsgi.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurancemanagement/__pycache__/wsgi.cpython-310.pyc -------------------------------------------------------------------------------- /customer/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/customer/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /insurancemanagement/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurancemanagement/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /insurancemanagement/__pycache__/settings.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurancemanagement/__pycache__/settings.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /customer/migrations/__pycache__/0001_initial.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/customer/migrations/__pycache__/0001_initial.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/migrations/__pycache__/0001_initial.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/migrations/__pycache__/0001_initial.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/migrations/__pycache__/0002_policy.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/migrations/__pycache__/0002_policy.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/migrations/__pycache__/0004_question.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/migrations/__pycache__/0004_question.cpython-310.pyc -------------------------------------------------------------------------------- /insurance/migrations/__pycache__/0003_policyrecord.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/Smart-IMS/HEAD/insurance/migrations/__pycache__/0003_policyrecord.cpython-310.pyc -------------------------------------------------------------------------------- /insurancemanagement/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for insurancemanagement project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'insurancemanagement.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /insurancemanagement/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for insurancemanagement project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'insurancemanagement.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /templates/insurance/logout.html: -------------------------------------------------------------------------------- 1 | {%load static%} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {% include "insurance/navbar.html" %} 10 |




11 | 12 | 13 |




14 |




15 |

16 | {% include "insurance/footer.html" %} 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /customer/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.contrib.auth.models import User 3 | from . import models 4 | 5 | 6 | class CustomerUserForm(forms.ModelForm): 7 | class Meta: 8 | model=User 9 | fields=['first_name','last_name','username','password'] 10 | widgets = { 11 | 'password': forms.PasswordInput() 12 | } 13 | 14 | class CustomerForm(forms.ModelForm): 15 | class Meta: 16 | model=models.Customer 17 | fields=['address','mobile','profile_pic'] 18 | 19 | -------------------------------------------------------------------------------- /customer/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import User 3 | 4 | class Customer(models.Model): 5 | user=models.OneToOneField(User,on_delete=models.CASCADE) 6 | profile_pic= models.ImageField(upload_to='profile_pic/Customer/',null=True,blank=True) 7 | address = models.CharField(max_length=40) 8 | mobile = models.CharField(max_length=20,null=False) 9 | 10 | @property 11 | def get_name(self): 12 | return self.user.first_name+" "+self.user.last_name 13 | @property 14 | def get_instance(self): 15 | return self 16 | def __str__(self): 17 | return self.user.first_name -------------------------------------------------------------------------------- /insurance/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.5 on 2021-03-28 02:42 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Category', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('category_name', models.CharField(max_length=20)), 19 | ('creation_date', models.DateField(auto_now=True)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /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 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'insurancemanagement.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /templates/insurance/index.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 14 | 15 | {% include "insurance/navbar.html" %} 16 |
17 |
18 |
19 |

















20 | 21 |
22 |
23 | 24 | 25 | 26 | {% include "insurance/footer.html" %} 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /customer/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | from django.contrib.auth.views import LoginView 4 | 5 | urlpatterns = [ 6 | path('customerclick', views.customerclick_view,name='customerclick'), 7 | path('customersignup', views.customer_signup_view,name='customersignup'), 8 | path('customer-dashboard', views.customer_dashboard_view,name='customer-dashboard'), 9 | path('customerlogin', LoginView.as_view(template_name='insurance/adminlogin.html'),name='customerlogin'), 10 | 11 | path('apply-policy', views.apply_policy_view,name='apply-policy'), 12 | path('apply/', views.apply_view,name='apply'), 13 | path('history', views.history_view,name='history'), 14 | 15 | path('ask-question', views.ask_question_view,name='ask-question'), 16 | path('question-history', views.question_history_view,name='question-history'), 17 | ] -------------------------------------------------------------------------------- /templates/insurance/contactussuccess.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 19 | 20 | 21 | 22 | 23 | 24 | {% include "insurance/navbar.html" %} 25 |

26 |
27 |

Your message sent successfully !

28 |

We will respond to your feedback soon

29 |
30 |

Check other features of website !

31 |

32 | HOME 33 |

34 |
35 | 36 | {% include "insurance/footer.html" %} 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /insurance/migrations/0004_question.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.5 on 2021-03-28 14:37 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('customer', '0001_initial'), 11 | ('insurance', '0003_policyrecord'), 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='Question', 17 | fields=[ 18 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 19 | ('description', models.CharField(max_length=500)), 20 | ('admin_comment', models.CharField(default='Nothing', max_length=200)), 21 | ('asked_date', models.DateField(auto_now=True)), 22 | ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customer.Customer')), 23 | ], 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /insurance/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.contrib.auth.models import User 3 | from . import models 4 | 5 | class ContactusForm(forms.Form): 6 | Name = forms.CharField(max_length=30) 7 | Email = forms.EmailField() 8 | Message = forms.CharField(max_length=500,widget=forms.Textarea(attrs={'rows': 3, 'cols': 30})) 9 | 10 | 11 | class CategoryForm(forms.ModelForm): 12 | class Meta: 13 | model=models.Category 14 | fields=['category_name'] 15 | 16 | class PolicyForm(forms.ModelForm): 17 | category=forms.ModelChoiceField(queryset=models.Category.objects.all(),empty_label="Category Name", to_field_name="id") 18 | class Meta: 19 | model=models.Policy 20 | fields=['policy_name','sum_assurance','premium','tenure'] 21 | 22 | class QuestionForm(forms.ModelForm): 23 | class Meta: 24 | model=models.Question 25 | fields=['description'] 26 | widgets = { 27 | 'description': forms.Textarea(attrs={'rows': 6, 'cols': 30}) 28 | } -------------------------------------------------------------------------------- /insurance/migrations/0003_policyrecord.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.5 on 2021-03-28 12:42 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('customer', '0001_initial'), 11 | ('insurance', '0002_policy'), 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='PolicyRecord', 17 | fields=[ 18 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 19 | ('status', models.CharField(default='Pending', max_length=100)), 20 | ('creation_date', models.DateField(auto_now=True)), 21 | ('Policy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='insurance.Policy')), 22 | ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customer.Customer')), 23 | ], 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /insurance/migrations/0002_policy.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.5 on 2021-03-28 10:48 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('insurance', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Policy', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('policy_name', models.CharField(max_length=200)), 19 | ('sum_assurance', models.PositiveIntegerField()), 20 | ('premium', models.PositiveIntegerField()), 21 | ('tenure', models.PositiveIntegerField()), 22 | ('creation_date', models.DateField(auto_now=True)), 23 | ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='insurance.Category')), 24 | ], 25 | ), 26 | ] 27 | -------------------------------------------------------------------------------- /customer/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.5 on 2021-03-27 12:32 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Customer', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('profile_pic', models.ImageField(blank=True, null=True, upload_to='profile_pic/Customer/')), 22 | ('address', models.CharField(max_length=40)), 23 | ('mobile', models.CharField(max_length=20)), 24 | ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 25 | ], 26 | ), 27 | ] 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 sumit kumar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /templates/customer/customerclick.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 20 | 21 | 22 | 23 | 24 | 25 | {% include "insurance/navbar.html" %} 26 |

27 |
28 |

Hello, Customer

29 |

Welcome to Insurance Management System

30 |
31 |

You can access various features after Login.

32 |

33 | Create Your Account 34 | Login 35 |

36 |


37 |
38 | 39 | {% include "insurance/footer.html" %} 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /templates/insurance/admin_view_category.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Categories
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | {% for t in categories %} 40 | 41 | 42 | 43 | 44 | 45 | {% endfor %} 46 |
Serial No.Category Name Creation Date
{{ forloop.counter }} {{t.category_name}}{{t.creation_date}}
47 |
48 |
49 | 50 |





51 | {% endblock content %} -------------------------------------------------------------------------------- /insurance/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import User 3 | from customer.models import Customer 4 | class Category(models.Model): 5 | category_name =models.CharField(max_length=20) 6 | creation_date =models.DateField(auto_now=True) 7 | def __str__(self): 8 | return self.category_name 9 | 10 | class Policy(models.Model): 11 | category= models.ForeignKey('Category', on_delete=models.CASCADE) 12 | policy_name=models.CharField(max_length=200) 13 | sum_assurance=models.PositiveIntegerField() 14 | premium=models.PositiveIntegerField() 15 | tenure=models.PositiveIntegerField() 16 | creation_date =models.DateField(auto_now=True) 17 | def __str__(self): 18 | return self.policy_name 19 | 20 | class PolicyRecord(models.Model): 21 | customer= models.ForeignKey(Customer, on_delete=models.CASCADE) 22 | Policy= models.ForeignKey(Policy, on_delete=models.CASCADE) 23 | status = models.CharField(max_length=100,default='Pending') 24 | creation_date =models.DateField(auto_now=True) 25 | def __str__(self): 26 | return self.policy 27 | 28 | class Question(models.Model): 29 | customer= models.ForeignKey(Customer, on_delete=models.CASCADE) 30 | description =models.CharField(max_length=500) 31 | admin_comment=models.CharField(max_length=200,default='Nothing') 32 | asked_date =models.DateField(auto_now=True) 33 | def __str__(self): 34 | return self.description -------------------------------------------------------------------------------- /templates/insurance/admin_view_approved_policy_holder.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Policy Holder Record
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {% for t in policyrecords %} 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {% endfor %} 51 |
Serial No.Policy NameCustomer Name Applied DateStatus
{{ forloop.counter }} {{t.Policy}} {{t.customer}}{{t.creation_date}}{{t.status}}
52 |
53 |
54 | 55 |





56 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_view_disapproved_policy_holder.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Policy Holder Record
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {% for t in policyrecords %} 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {% endfor %} 51 |
Serial No.Policy NameCustomer Name Applied DateStatus
{{ forloop.counter }} {{t.Policy}} {{t.customer}}{{t.creation_date}}{{t.status}}
52 |
53 |
54 | 55 |





56 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_view_waiting_policy_holder.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Policy Holder Record
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {% for t in policyrecords %} 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {% endfor %} 51 |
Serial No.Policy NameCustomer Name Applied DateStatus
{{ forloop.counter }} {{t.Policy}} {{t.customer}}{{t.creation_date}}{{t.status}}
52 |
53 |
54 | 55 |





56 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_add_category.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | 19 | 20 |

ADD CATEGORY

21 |
22 | {%csrf_token%} 23 |
24 | 25 | {% render_field categoryForm.category_name class="form-control" placeholder="Life Insurance" %} 26 | 27 |
28 | 29 |
30 | 31 |
32 |

















33 | {% endblock content %} 34 | -------------------------------------------------------------------------------- /templates/insurance/admin_delete_category.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Delete Category
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | {% for t in categories %} 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {% endfor %} 48 |
Serial No.Category Name Creation DateDelete Category
{{ forloop.counter }} {{t.category_name}}{{t.creation_date}}
49 |
50 |
51 | 52 |





53 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_update_category.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Update Category
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | {% for t in categories %} 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {% endfor %} 48 |
Serial No.Category Name Creation DateUpdate Category
{{ forloop.counter }} {{t.category_name}}{{t.creation_date}}
49 |
50 |
51 | 52 |





53 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_view_policy.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Policies
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {% for t in policies %} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | {% endfor %} 54 |
Serial No.Policy Name Category Sum Assurance Premium Tenure Creation Date
{{ forloop.counter }} {{t.policy_name}} {{t.category}} {{t.sum_assurance}} {{t.premium}} {{t.tenure}}{{t.creation_date}}
55 |
56 |
57 | 58 |





59 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/update_category.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 49 | 50 | 51 | 52 | 53 |

54 |

UPDATE CATEGORY

55 |
56 |
57 | {% csrf_token %} 58 | 59 | {% render_field categoryForm.category_name class="form-control" %} 60 | 61 |

62 | 63 |
64 |
65 | 66 | 67 | 68 |







69 | {% endblock content %} 70 | -------------------------------------------------------------------------------- /templates/customer/history.html: -------------------------------------------------------------------------------- 1 | {% extends 'customer/customerbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 37 | 38 |

39 |
40 |
41 |
42 |
History
43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {% for t in policies %} 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | {% endfor %} 64 |
Serial No.Policy Name Applied Date Status
{{ forloop.counter }} {{t.Policy}}{{t.creation_date}}{{t.status}}
65 |
66 |
67 | 68 |





69 | {% endblock content %} -------------------------------------------------------------------------------- /templates/customer/question_history.html: -------------------------------------------------------------------------------- 1 | {% extends 'customer/customerbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 37 | 38 |

39 |
40 |
41 |
42 |
Asked Question History
43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {% for t in questions %} 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | {% endfor %} 64 |
Serial No.QuestionAdmin Comment Asked Date
{{ forloop.counter }} {{t.description}}{{t.admin_comment}}{{t.asked_date}}
65 |
66 |
67 | 68 |





69 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_update_policy.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Update Policy
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {% for t in policies %} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {% endfor %} 55 |
Serial No.Policy Name Category Sum Assurance Premium Tenure Creation DateUpdate
{{ forloop.counter }} {{t.policy_name}} {{t.category}} {{t.sum_assurance}} {{t.premium}} {{t.tenure}}{{t.creation_date}}
56 |
57 |
58 | 59 |





60 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_delete_policy.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Delete Policy
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {% for t in policies %} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {% endfor %} 56 |
Serial No.Policy Name Category Sum Assurance Premium Tenure Creation DateDelete
{{ forloop.counter }} {{t.policy_name}} {{t.category}} {{t.sum_assurance}} {{t.premium}} {{t.tenure}}{{t.creation_date}}
57 |
58 |
59 | 60 |





61 | {% endblock content %} -------------------------------------------------------------------------------- /templates/customer/ask_question.html: -------------------------------------------------------------------------------- 1 | {% extends 'customer/customerbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | 31 | 32 |

ASK QUESTION

33 |
34 | {%csrf_token%} 35 |
36 | 37 | {% render_field questionForm.description class="form-control" placeholder="Describe your problem here" %} 38 | 39 | 40 |
41 | 42 | 43 | 44 | 45 |
46 |



47 | {% endblock content %} 48 | -------------------------------------------------------------------------------- /templates/insurance/update_question.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 49 | 50 | 51 | 52 | 53 |

54 |

Update Question

55 |
56 |
57 | {% csrf_token %} 58 | 59 | {% render_field questionForm.description class="form-control"%} 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 |
69 | 70 | 71 | 72 |







73 | {% endblock content %} 74 | -------------------------------------------------------------------------------- /templates/insurance/navbar.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | 60 |
61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /templates/insurance/admin_question.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 37 | 38 |

39 |
40 |
41 |
42 |
Questions
43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | {% for t in questions %} 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | {% endfor %} 67 |
Serial No.Customer Name Problem Admin Comment Asked DateUpdate
{{ forloop.counter }} {{t.customer}} {{t.description}} {{t.admin_comment}} {{t.asked_date}}
68 |
69 |
70 | 71 |





72 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_add_policy.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | 19 | 20 |

ADD POLICY

21 |
22 | {%csrf_token%} 23 |
24 | 25 | {% render_field policyForm.category class="form-control" placeholder="Life Insurance" %} 26 | 27 | 28 | {% render_field policyForm.policy_name class="form-control" placeholder="Jeevan Surbhi" %} 29 | 30 | 31 | {% render_field policyForm.sum_assurance class="form-control" placeholder="100000" %} 32 | 33 | 34 | {% render_field policyForm.premium class="form-control" placeholder="5000" %} 35 | 36 | 37 | {% render_field policyForm.tenure class="form-control" placeholder="12" %} 38 | 39 | 40 |
41 | 42 | 43 |
44 | 45 |
46 |



47 | {% endblock content %} 48 | -------------------------------------------------------------------------------- /templates/customer/apply_policy.html: -------------------------------------------------------------------------------- 1 | {% extends 'customer/customerbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 36 | 37 |

38 |
39 |
40 |
41 |
Available Policies
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | {% for t in policies %} 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | {% endfor %} 69 |
Serial No.Policy Name Category Sum Assurance Premium Tenure Creation Date Apply
{{ forloop.counter }} {{t.policy_name}} {{t.category}} {{t.sum_assurance}} {{t.premium}} {{t.tenure}}{{t.creation_date}}Apply
70 |
71 |
72 | 73 |





74 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_view_customer.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 36 | 37 |

38 |
39 |
40 |
41 |
Customers
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | {% for t in customers %} 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | {% endfor %} 68 |
NameProfile PictureMobileAddressUpdateDelete
{{t.get_name}} Profile Pic{{t.mobile}}{{t.address}}
69 |
70 |
71 | 72 |





73 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/admin_view_policy_holder.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% block content %} 3 | {%load static%} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 23 | 24 |

25 |
26 |
27 |
28 |
Policy Holder Record
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {% for t in policyrecords %} 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {% if t.status == 'Pending' %} 51 | 55 | 56 | {% else %} 57 | 59 | 60 | 61 | {% endif %} 62 | 63 | 64 | 65 | {% endfor %} 66 |
Serial No.Policy NameCustomer Name Applied DateStatusAction
{{ forloop.counter }} {{t.Policy}} {{t.customer}}{{t.creation_date}}{{t.status}} 52 | 53 | 54 | 58 | {{t.status}}
67 |
68 |
69 | 70 |





71 | {% endblock content %} -------------------------------------------------------------------------------- /templates/insurance/update_policy.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 49 | 50 | 51 | 52 | 53 |

54 |

UPDATE POLICY

55 |
56 |
57 | {% csrf_token %} 58 | 59 | {% render_field policyForm.category class="form-control" placeholder="Life Insurance" %} 60 | 61 | 62 | {% render_field policyForm.policy_name class="form-control" placeholder="Jeevan Surbhi" %} 63 | 64 | 65 | {% render_field policyForm.sum_assurance class="form-control" placeholder="100000" %} 66 | 67 | 68 | {% render_field policyForm.premium class="form-control" placeholder="5000" %} 69 | 70 | 71 | {% render_field policyForm.tenure class="form-control" placeholder="12" %} 72 | 73 | 74 | 75 |

76 | 77 |
78 |
79 | 80 | 81 | 82 |







83 | {% endblock content %} 84 | -------------------------------------------------------------------------------- /templates/customer/customersignup.html: -------------------------------------------------------------------------------- 1 | 2 | {% load widget_tweaks %} 3 | 4 | 5 | 6 | 14 | 15 | 16 | {% include "insurance/navbar.html" %} 17 | 18 | 19 | 20 |


21 |

CUSTOMER SIGNUP

22 |
23 | {% csrf_token %} 24 |
25 |
26 | 27 | {% render_field userForm.username|attr:'required:true' class="form-control" placeholder="username" %} 28 |
29 |
30 | 31 | {% render_field userForm.password|attr:'required:true' class="form-control" placeholder="password" %} 32 |
33 |
34 | 35 |
36 |
37 | 38 | {% render_field userForm.first_name|attr:'required:true' class="form-control" placeholder="First Name" %} 39 |
40 |
41 | 42 | {% render_field userForm.last_name|attr:'required:true' class="form-control" placeholder="Last Name" %} 43 |
44 |
45 | 46 |
47 |
48 | 49 | {% render_field customerForm.mobile|attr:'required:true' class="form-control" placeholder="Mobile" %} 50 |
51 |
52 | 53 | {% render_field customerForm.address|attr:'required:true' class="form-control" placeholder="Address" %} 54 |
55 |
56 | 57 |
58 |
59 | 60 | {% render_field customerForm.profile_pic|attr:'required:true' class="form-control" placeholder="" %} 61 |
62 | 63 |
64 | 65 | 66 | 67 |
68 | 69 | 70 |

71 | {% include "insurance/footer.html" %} 72 | 73 | 74 | -------------------------------------------------------------------------------- /templates/insurance/update_customer.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 49 | 50 | 51 | 52 | 53 |

54 |

UPDATE CUSTOMER

55 |
56 |
57 | {% csrf_token %} 58 | 59 | {% render_field userForm.first_name class="form-control" placeholder="First Name" %} 60 | 61 | {% render_field userForm.last_name class="form-control" placeholder="Last Name" %} 62 | 63 | {% render_field customerForm.mobile class="form-control" placeholder="Mobile" %} 64 | 65 | {% render_field customerForm.address class="form-control" placeholder="Address" %} 66 | 67 | 68 | {% render_field userForm.username class="form-control" placeholder="Username" %} 69 | 70 | {% render_field userForm.password class="form-control" placeholder="Password" %}

71 | 72 | {% render_field customerForm.profile_pic class="form-control" placeholder="Profile Picture" %} 73 |

74 | 75 |
76 |
77 | 78 | 79 | 80 |







81 | {% endblock content %} 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Insurance Management 2 | ![developer](https://img.shields.io/badge/Developed%20By%20%3A-Mainak%20Chaudhuri-blue) 3 | --- 4 | ## screenshots 5 | ### Homepage 6 | ![homepage snap](https://github.com/sumitkumar1503/insurancemanagement/blob/master/static/screenshots/homepage.png?raw=true) 7 | ### Admin Dashboard 8 | ![dashboard snap](https://github.com/sumitkumar1503/insurancemanagement/blob/master/static/screenshots/dashboard.png?raw=true) 9 | ### Policy Record 10 | ![invoice snap](https://github.com/sumitkumar1503/insurancemanagement/blob/master/static/screenshots/policyrecord.png?raw=true) 11 | ### Policy 12 | ![doctor snap](https://github.com/sumitkumar1503/insurancemanagement/blob/master/static/screenshots/policy.png?raw=true) 13 | --- 14 | ## Functions 15 | ### Admin 16 | - Admin account can be created using createsuperuser command. 17 | - After login, admin can view/update/delete customer 18 | - Can view/add/update/delete policy category like Life, Health, Motor, Travel 19 | - Can view/add/update/delete policy 20 | - Can view total policy holder, approved policy holder, disapproved policy holder 21 | - Can approve policy, applied by customer 22 | - Can answer customer question 23 | 24 | ### Customer 25 | - Create account (no approval required by admin) 26 | - After login, can view all policy that are added by admin. 27 | - If customer likes any policy, then they can apply for it. 28 | - When customer will apply for any policy, it will go into pending status, admin can approve it. 29 | - Customer can check status of his policy under history section 30 | - Customer can ask question from admin. 31 | 32 | --- 33 | 34 | ## HOW TO RUN THIS PROJECT 35 | - Install Python(3.7.6) (Dont Forget to Tick Add to Path while installing Python) 36 | - Open Terminal and Execute Following Commands : 37 | ``` 38 | python -m pip install -r requirements.txt 39 | ``` 40 | - Download This Project Zip Folder and Extract it 41 | - Move to project folder in Terminal. Then run following Commands : 42 | ``` 43 | py manage.py makemigrations 44 | py manage.py migrate 45 | py manage.py runserver 46 | ``` 47 | - Now enter following URL in Your Browser Installed On Your Pc 48 | ``` 49 | http://127.0.0.1:8000/ 50 | ``` 51 | 52 | ## CHANGES REQUIRED FOR CONTACT US PAGE 53 | - In settins.py file, You have to give your email and password 54 | ``` 55 | EMAIL_HOST_USER = 'youremail@gmail.com' 56 | EMAIL_HOST_PASSWORD = 'your email password' 57 | EMAIL_RECEIVING_USER = 'youremail@gmail.com' 58 | ``` 59 | - Login to gmail through host email id in your browser and open following link and turn it ON 60 | ``` 61 | https://myaccount.google.com/lesssecureapps 62 | ``` 63 | 64 | 65 | ## Disclaimer 66 | This project is developed for demo purpose and it's not supposed to be used in real application. 67 | 68 | ## Feedback 69 | Any suggestion and feedback is welcome. You can message me on facebook 70 | - [Contact on Facebook](https://fb.com/sumit.luv) 71 | - [Subscribe my Channel LazyCoder On Youtube](https://youtube.com/lazycoderonline) 72 | -------------------------------------------------------------------------------- /insurancemanagement/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path 4 | from insurance import views 5 | from django.contrib.auth.views import LogoutView,LoginView 6 | from django.urls import path,include 7 | 8 | urlpatterns = [ 9 | path('admin/', admin.site.urls), 10 | 11 | 12 | path('customer/',include('customer.urls')), 13 | path('',views.home_view,name=''), 14 | path('logout', LogoutView.as_view(template_name='insurance/logout.html'),name='logout'), 15 | path('aboutus', views.aboutus_view), 16 | path('contactus', views.contactus_view), 17 | path('afterlogin', views.afterlogin_view,name='afterlogin'), 18 | 19 | 20 | path('adminlogin', LoginView.as_view(template_name='insurance/adminlogin.html'),name='adminlogin'), 21 | path('admin-dashboard', views.admin_dashboard_view,name='admin-dashboard'), 22 | 23 | path('admin-view-customer', views.admin_view_customer_view,name='admin-view-customer'), 24 | path('update-customer/', views.update_customer_view,name='update-customer'), 25 | path('delete-customer/', views.delete_customer_view,name='delete-customer'), 26 | 27 | path('admin-category', views.admin_category_view,name='admin-category'), 28 | path('admin-view-category', views.admin_view_category_view,name='admin-view-category'), 29 | path('admin-update-category', views.admin_update_category_view,name='admin-update-category'), 30 | path('update-category/', views.update_category_view,name='update-category'), 31 | path('admin-add-category', views.admin_add_category_view,name='admin-add-category'), 32 | path('admin-delete-category', views.admin_delete_category_view,name='admin-delete-category'), 33 | path('delete-category/', views.delete_category_view,name='delete-category'), 34 | 35 | 36 | path('admin-policy', views.admin_policy_view,name='admin-policy'), 37 | path('admin-add-policy', views.admin_add_policy_view,name='admin-add-policy'), 38 | path('admin-view-policy', views.admin_view_policy_view,name='admin-view-policy'), 39 | path('admin-update-policy', views.admin_update_policy_view,name='admin-update-policy'), 40 | path('update-policy/', views.update_policy_view,name='update-policy'), 41 | path('admin-delete-policy', views.admin_delete_policy_view,name='admin-delete-policy'), 42 | path('delete-policy/', views.delete_policy_view,name='delete-policy'), 43 | 44 | path('admin-view-policy-holder', views.admin_view_policy_holder_view,name='admin-view-policy-holder'), 45 | path('admin-view-approved-policy-holder', views.admin_view_approved_policy_holder_view,name='admin-view-approved-policy-holder'), 46 | path('admin-view-disapproved-policy-holder', views.admin_view_disapproved_policy_holder_view,name='admin-view-disapproved-policy-holder'), 47 | path('admin-view-waiting-policy-holder', views.admin_view_waiting_policy_holder_view,name='admin-view-waiting-policy-holder'), 48 | path('approve-request/', views.approve_request_view,name='approve-request'), 49 | path('reject-request/', views.disapprove_request_view,name='reject-request'), 50 | 51 | path('admin-question', views.admin_question_view,name='admin-question'), 52 | path('update-question/', views.update_question_view,name='update-question'), 53 | 54 | ] 55 | -------------------------------------------------------------------------------- /templates/insurance/adminlogin.html: -------------------------------------------------------------------------------- 1 | 2 | {% load widget_tweaks %} 3 | 4 | 5 | 6 | 7 | 117 | 118 | 119 | {% include "insurance/navbar.html" %} 120 | 121 | 122 | 123 |
124 |

LOGIN TO YOUR ACCOUNT


125 |
126 | {% csrf_token %} 127 | {% render_field form.username class="form-control" placeholder="Username" %} 128 |
129 | {% render_field form.password class="form-control" placeholder="Password" %} 130 |
131 | 132 | 133 |
134 |
135 | 136 | 137 |








138 |








139 |




140 | {% include "insurance/footer.html" %} 141 | 142 | 143 | -------------------------------------------------------------------------------- /templates/insurance/admin_category.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 71 | 72 | 73 | 74 |
75 |
76 |
77 |
78 |
79 |
view Category
80 |

81 |
82 |
83 |
84 | 85 |
86 |
87 |
88 |
Add Category
89 |

90 |
91 |
92 |
93 | 94 |
95 |
96 |
97 |
Update Category
98 |

99 |
100 |
101 |
102 | 103 |
104 |
105 |
106 |
Delete Category
107 |

108 |
109 |
110 |
111 | 112 | 113 | 114 |
115 |
116 | 117 | 118 |









119 | 120 | 121 | 122 | 123 | {% endblock content %} 124 | -------------------------------------------------------------------------------- /templates/customer/customer_dashboard.html: -------------------------------------------------------------------------------- 1 | {% extends 'customer/customerbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 71 | 72 | 73 | 74 |
75 |
76 |
77 |
78 |
79 |
Available Policy
80 |

{{available_policy}}

81 | 82 |
83 |
84 |
85 | 86 |
87 |
88 |
89 |
Applied Policy
90 |

{{applied_policy}}

91 | 92 |
93 |
94 |
95 | 96 |
97 |
98 |
99 |
Policy Categories
100 |

{{total_category}}

101 | 102 |
103 |
104 |
105 | 106 |
107 |
108 |
109 |
Total Question Asked
110 |

{{total_question}}

111 | 112 |
113 |
114 |
115 | 116 | 117 |
118 |
119 | 120 | 121 |









122 | 123 | 124 | 125 | 126 | {% endblock content %} 127 | -------------------------------------------------------------------------------- /customer/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render,redirect,reverse 2 | from . import forms,models 3 | from django.db.models import Sum 4 | from django.contrib.auth.models import Group 5 | from django.http import HttpResponseRedirect 6 | from django.contrib.auth.decorators import login_required,user_passes_test 7 | from django.conf import settings 8 | from datetime import date, timedelta 9 | from django.db.models import Q 10 | from django.core.mail import send_mail 11 | from insurance import models as CMODEL 12 | from insurance import forms as CFORM 13 | from django.contrib.auth.models import User 14 | 15 | 16 | def customerclick_view(request): 17 | if request.user.is_authenticated: 18 | return HttpResponseRedirect('afterlogin') 19 | return render(request,'customer/customerclick.html') 20 | 21 | 22 | def customer_signup_view(request): 23 | userForm=forms.CustomerUserForm() 24 | customerForm=forms.CustomerForm() 25 | mydict={'userForm':userForm,'customerForm':customerForm} 26 | if request.method=='POST': 27 | userForm=forms.CustomerUserForm(request.POST) 28 | customerForm=forms.CustomerForm(request.POST,request.FILES) 29 | if userForm.is_valid() and customerForm.is_valid(): 30 | user=userForm.save() 31 | user.set_password(user.password) 32 | user.save() 33 | customer=customerForm.save(commit=False) 34 | customer.user=user 35 | customer.save() 36 | my_customer_group = Group.objects.get_or_create(name='CUSTOMER') 37 | my_customer_group[0].user_set.add(user) 38 | return HttpResponseRedirect('customerlogin') 39 | return render(request,'customer/customersignup.html',context=mydict) 40 | 41 | def is_customer(user): 42 | return user.groups.filter(name='CUSTOMER').exists() 43 | 44 | @login_required(login_url='customerlogin') 45 | def customer_dashboard_view(request): 46 | dict={ 47 | 'customer':models.Customer.objects.get(user_id=request.user.id), 48 | 'available_policy':CMODEL.Policy.objects.all().count(), 49 | 'applied_policy':CMODEL.PolicyRecord.objects.all().filter(customer=models.Customer.objects.get(user_id=request.user.id)).count(), 50 | 'total_category':CMODEL.Category.objects.all().count(), 51 | 'total_question':CMODEL.Question.objects.all().filter(customer=models.Customer.objects.get(user_id=request.user.id)).count(), 52 | 53 | } 54 | return render(request,'customer/customer_dashboard.html',context=dict) 55 | 56 | def apply_policy_view(request): 57 | customer = models.Customer.objects.get(user_id=request.user.id) 58 | policies = CMODEL.Policy.objects.all() 59 | return render(request,'customer/apply_policy.html',{'policies':policies,'customer':customer}) 60 | 61 | def apply_view(request,pk): 62 | customer = models.Customer.objects.get(user_id=request.user.id) 63 | policy = CMODEL.Policy.objects.get(id=pk) 64 | policyrecord = CMODEL.PolicyRecord() 65 | policyrecord.Policy = policy 66 | policyrecord.customer = customer 67 | policyrecord.save() 68 | return redirect('history') 69 | 70 | def history_view(request): 71 | customer = models.Customer.objects.get(user_id=request.user.id) 72 | policies = CMODEL.PolicyRecord.objects.all().filter(customer=customer) 73 | return render(request,'customer/history.html',{'policies':policies,'customer':customer}) 74 | 75 | def ask_question_view(request): 76 | customer = models.Customer.objects.get(user_id=request.user.id) 77 | questionForm=CFORM.QuestionForm() 78 | 79 | if request.method=='POST': 80 | questionForm=CFORM.QuestionForm(request.POST) 81 | if questionForm.is_valid(): 82 | 83 | question = questionForm.save(commit=False) 84 | question.customer=customer 85 | question.save() 86 | return redirect('question-history') 87 | return render(request,'customer/ask_question.html',{'questionForm':questionForm,'customer':customer}) 88 | 89 | def question_history_view(request): 90 | customer = models.Customer.objects.get(user_id=request.user.id) 91 | questions = CMODEL.Question.objects.all().filter(customer=customer) 92 | return render(request,'customer/question_history.html',{'questions':questions,'customer':customer}) 93 | 94 | -------------------------------------------------------------------------------- /insurancemanagement/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for insurancemanagement project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | TEMPLATE_DIR = os.path.join(BASE_DIR,'templates') 18 | STATIC_DIR=os.path.join(BASE_DIR,'static') 19 | MEDIA_ROOT=os.path.join(BASE_DIR,'static') 20 | 21 | # Quick-start development settings - unsuitable for production 22 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ 23 | 24 | # SECURITY WARNING: keep the secret key used in production secret! 25 | SECRET_KEY = 'ls@!_(edqp*xy76kvbsst$07at(v^li*2&ew!^$8o(@wa6@a+$' 26 | 27 | # SECURITY WARNING: don't run with debug turned on in production! 28 | DEBUG = True 29 | 30 | ALLOWED_HOSTS = [] 31 | 32 | 33 | # Application definition 34 | 35 | INSTALLED_APPS = [ 36 | 'django.contrib.admin', 37 | 'django.contrib.auth', 38 | 'django.contrib.contenttypes', 39 | 'django.contrib.sessions', 40 | 'django.contrib.messages', 41 | 'django.contrib.staticfiles', 42 | 'widget_tweaks', 43 | 'insurance', 44 | 'customer', 45 | ] 46 | 47 | MIDDLEWARE = [ 48 | 'django.middleware.security.SecurityMiddleware', 49 | 'django.contrib.sessions.middleware.SessionMiddleware', 50 | 'django.middleware.common.CommonMiddleware', 51 | 'django.middleware.csrf.CsrfViewMiddleware', 52 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 53 | 'django.contrib.messages.middleware.MessageMiddleware', 54 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 55 | ] 56 | 57 | ROOT_URLCONF = 'insurancemanagement.urls' 58 | 59 | TEMPLATES = [ 60 | { 61 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 62 | 'DIRS': [TEMPLATE_DIR,], 63 | 'APP_DIRS': True, 64 | 'OPTIONS': { 65 | 'context_processors': [ 66 | 'django.template.context_processors.debug', 67 | 'django.template.context_processors.request', 68 | 'django.contrib.auth.context_processors.auth', 69 | 'django.contrib.messages.context_processors.messages', 70 | ], 71 | }, 72 | }, 73 | ] 74 | 75 | WSGI_APPLICATION = 'insurancemanagement.wsgi.application' 76 | 77 | 78 | # Database 79 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases 80 | 81 | DATABASES = { 82 | 'default': { 83 | 'ENGINE': 'django.db.backends.sqlite3', 84 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 85 | } 86 | } 87 | 88 | 89 | # Password validation 90 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators 91 | 92 | AUTH_PASSWORD_VALIDATORS = [ 93 | { 94 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 95 | }, 96 | { 97 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 98 | }, 99 | { 100 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 101 | }, 102 | { 103 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 104 | }, 105 | ] 106 | 107 | 108 | # Internationalization 109 | # https://docs.djangoproject.com/en/3.0/topics/i18n/ 110 | 111 | LANGUAGE_CODE = 'en-us' 112 | 113 | TIME_ZONE = 'UTC' 114 | 115 | USE_I18N = True 116 | 117 | USE_L10N = True 118 | 119 | USE_TZ = True 120 | 121 | 122 | # Static files (CSS, JavaScript, Images) 123 | # https://docs.djangoproject.com/en/3.0/howto/static-files/ 124 | 125 | STATIC_URL = '/static/' 126 | 127 | 128 | STATICFILES_DIRS=[ 129 | STATIC_DIR, 130 | ] 131 | 132 | LOGIN_REDIRECT_URL='/afterlogin' 133 | 134 | #for contact us give your gmail id and password 135 | EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend' 136 | EMAIL_HOST = 'smtp.gmail.com' 137 | EMAIL_USE_TLS = True 138 | EMAIL_PORT = 587 139 | EMAIL_HOST_USER = 'from@gmail.com' # this email will be used to send emails 140 | EMAIL_HOST_PASSWORD = 'xyz' # host email password required 141 | # now sign in with your host gmail account in your browser 142 | # open following link and turn it ON 143 | # https://myaccount.google.com/lesssecureapps 144 | # otherwise you will get SMTPAuthenticationError at /contactus 145 | # this process is required because google blocks apps authentication by default 146 | EMAIL_RECEIVING_USER = ['to@gmail.com'] # email on which you will receive messages sent from website 147 | -------------------------------------------------------------------------------- /templates/insurance/adminbase.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 |
165 | 168 |
169 |

SMART IMS

170 |
171 |
172 | Logout 173 |
174 |
175 | 176 | 177 | 196 | 197 | 198 | 199 | 200 |
201 |




202 | {% block content %} 203 | 204 | {% endblock content %} 205 | 206 | 207 |


208 | 209 |
210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /templates/customer/customerbase.html: -------------------------------------------------------------------------------- 1 | 2 | {% load static %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 |
163 | 166 |
167 |

Insurance Management

168 |
169 |
170 | Logout 171 |
172 |
173 | 174 | 175 | 191 | 192 | 193 | 194 | 195 |
196 |




197 | {% block content %} 198 | 199 | {% endblock content %} 200 | 201 | 202 |


203 | 204 |
205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /templates/insurance/admin_policy.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 71 | 72 | 73 | 74 |
75 | 76 |
77 |
78 |
79 |
80 |
View Policy
81 |

82 |
83 |
84 |
85 | 86 |
87 |
88 |
89 |
Add policy
90 |

91 |
92 |
93 |
94 | 95 |
96 |
97 |
98 |
Update Policy
99 |

100 |
101 |
102 |
103 | 104 |
105 |
106 |
107 |
Delete Policy
108 |

109 |
110 |
111 |
112 | 113 | 114 | 115 |
116 | 117 |
118 |
119 |
120 |
121 |
Total Applied Policy Holder
122 |

{{total_policy_holder}}

123 | 124 |
125 |
126 |
127 | 128 |
129 |
130 |
131 |
Approved Policy Holder
132 |

{{approved_policy_holder}}

133 | 134 |
135 |
136 |
137 | 138 |
139 |
140 |
141 |
Disapproved Policy Holder
142 |

{{disapproved_policy_holder}}

143 | 144 |
145 |
146 |
147 | 148 |
149 |
150 |
151 |
Policy Holder Waiting For Approval
152 |

{{waiting_policy_holder}}

153 | 154 |
155 |
156 |
157 | 158 | 159 |
160 |
161 | 162 | 163 |









164 | 165 | 166 | 167 | 168 | {% endblock content %} 169 | -------------------------------------------------------------------------------- /templates/insurance/admin_dashboard.html: -------------------------------------------------------------------------------- 1 | {% extends 'insurance/adminbase.html' %} 2 | {% load widget_tweaks %} 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 71 | 72 | 73 | 74 |
75 | 76 | 77 |
78 |
79 |
80 |
81 |
Total Registered User
82 |

{{total_user}}

83 | 84 |
85 |
86 |
87 | 88 |
89 |
90 |
91 |
Listed Policies
92 |

{{total_policy}}

93 | 94 |
95 |
96 |
97 | 98 |
99 |
100 |
101 |
Listed Categories
102 |

{{total_category}}

103 | 104 |
105 |
106 |
107 | 108 |
109 |
110 |
111 |
Total Question
112 |

{{total_question}}

113 | 114 |
115 |
116 |
117 | 118 | 119 |
120 | 121 |
122 |
123 |
124 |
125 |
126 |
Total Applied Policy Holder
127 |

{{total_policy_holder}}

128 | 129 |
130 |
131 |
132 | 133 |
134 |
135 |
136 |
Approved Policy Holder
137 |

{{approved_policy_holder}}

138 | 139 |
140 |
141 |
142 | 143 |
144 |
145 |
146 |
Disapproved Policy Holder
147 |

{{disapproved_policy_holder}}

148 | 149 |
150 |
151 |
152 | 153 |
154 |
155 |
156 |
Waiting For Approval
157 |

{{waiting_policy_holder}}

158 | 159 |
160 |
161 |
162 | 163 | 164 |
165 | 166 | 167 | 168 |
169 | 170 | 171 |





172 | 173 | 174 | 175 | 176 | {% endblock content %} 177 | -------------------------------------------------------------------------------- /insurance/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render,redirect,reverse 2 | from . import forms,models 3 | from django.db.models import Sum 4 | from django.contrib.auth.models import Group 5 | from django.http import HttpResponseRedirect 6 | from django.contrib.auth.decorators import login_required,user_passes_test 7 | from django.conf import settings 8 | from datetime import date, timedelta 9 | from django.db.models import Q 10 | from django.core.mail import send_mail 11 | from django.contrib.auth.models import User 12 | from customer import models as CMODEL 13 | from customer import forms as CFORM 14 | 15 | def home_view(request): 16 | if request.user.is_authenticated: 17 | return HttpResponseRedirect('afterlogin') 18 | return render(request,'insurance/index.html') 19 | 20 | 21 | def is_customer(user): 22 | return user.groups.filter(name='CUSTOMER').exists() 23 | 24 | 25 | def afterlogin_view(request): 26 | if is_customer(request.user): 27 | return redirect('customer/customer-dashboard') 28 | else: 29 | return redirect('admin-dashboard') 30 | 31 | 32 | 33 | def adminclick_view(request): 34 | if request.user.is_authenticated: 35 | return HttpResponseRedirect('afterlogin') 36 | return HttpResponseRedirect('adminlogin') 37 | 38 | 39 | @login_required(login_url='adminlogin') 40 | def admin_dashboard_view(request): 41 | dict={ 42 | 'total_user':CMODEL.Customer.objects.all().count(), 43 | 'total_policy':models.Policy.objects.all().count(), 44 | 'total_category':models.Category.objects.all().count(), 45 | 'total_question':models.Question.objects.all().count(), 46 | 'total_policy_holder':models.PolicyRecord.objects.all().count(), 47 | 'approved_policy_holder':models.PolicyRecord.objects.all().filter(status='Approved').count(), 48 | 'disapproved_policy_holder':models.PolicyRecord.objects.all().filter(status='Disapproved').count(), 49 | 'waiting_policy_holder':models.PolicyRecord.objects.all().filter(status='Pending').count(), 50 | } 51 | return render(request,'insurance/admin_dashboard.html',context=dict) 52 | 53 | 54 | 55 | @login_required(login_url='adminlogin') 56 | def admin_view_customer_view(request): 57 | customers= CMODEL.Customer.objects.all() 58 | return render(request,'insurance/admin_view_customer.html',{'customers':customers}) 59 | 60 | 61 | 62 | @login_required(login_url='adminlogin') 63 | def update_customer_view(request,pk): 64 | customer=CMODEL.Customer.objects.get(id=pk) 65 | user=CMODEL.User.objects.get(id=customer.user_id) 66 | userForm=CFORM.CustomerUserForm(instance=user) 67 | customerForm=CFORM.CustomerForm(request.FILES,instance=customer) 68 | mydict={'userForm':userForm,'customerForm':customerForm} 69 | if request.method=='POST': 70 | userForm=CFORM.CustomerUserForm(request.POST,instance=user) 71 | customerForm=CFORM.CustomerForm(request.POST,request.FILES,instance=customer) 72 | if userForm.is_valid() and customerForm.is_valid(): 73 | user=userForm.save() 74 | user.set_password(user.password) 75 | user.save() 76 | customerForm.save() 77 | return redirect('admin-view-customer') 78 | return render(request,'insurance/update_customer.html',context=mydict) 79 | 80 | 81 | 82 | @login_required(login_url='adminlogin') 83 | def delete_customer_view(request,pk): 84 | customer=CMODEL.Customer.objects.get(id=pk) 85 | user=User.objects.get(id=customer.user_id) 86 | user.delete() 87 | customer.delete() 88 | return HttpResponseRedirect('/admin-view-customer') 89 | 90 | 91 | 92 | def admin_category_view(request): 93 | return render(request,'insurance/admin_category.html') 94 | 95 | def admin_add_category_view(request): 96 | categoryForm=forms.CategoryForm() 97 | if request.method=='POST': 98 | categoryForm=forms.CategoryForm(request.POST) 99 | if categoryForm.is_valid(): 100 | categoryForm.save() 101 | return redirect('admin-view-category') 102 | return render(request,'insurance/admin_add_category.html',{'categoryForm':categoryForm}) 103 | 104 | def admin_view_category_view(request): 105 | categories = models.Category.objects.all() 106 | return render(request,'insurance/admin_view_category.html',{'categories':categories}) 107 | 108 | def admin_delete_category_view(request): 109 | categories = models.Category.objects.all() 110 | return render(request,'insurance/admin_delete_category.html',{'categories':categories}) 111 | 112 | def delete_category_view(request,pk): 113 | category = models.Category.objects.get(id=pk) 114 | category.delete() 115 | return redirect('admin-delete-category') 116 | 117 | def admin_update_category_view(request): 118 | categories = models.Category.objects.all() 119 | return render(request,'insurance/admin_update_category.html',{'categories':categories}) 120 | 121 | @login_required(login_url='adminlogin') 122 | def update_category_view(request,pk): 123 | category = models.Category.objects.get(id=pk) 124 | categoryForm=forms.CategoryForm(instance=category) 125 | 126 | if request.method=='POST': 127 | categoryForm=forms.CategoryForm(request.POST,instance=category) 128 | 129 | if categoryForm.is_valid(): 130 | 131 | categoryForm.save() 132 | return redirect('admin-update-category') 133 | return render(request,'insurance/update_category.html',{'categoryForm':categoryForm}) 134 | 135 | 136 | 137 | def admin_policy_view(request): 138 | return render(request,'insurance/admin_policy.html') 139 | 140 | 141 | def admin_add_policy_view(request): 142 | policyForm=forms.PolicyForm() 143 | 144 | if request.method=='POST': 145 | policyForm=forms.PolicyForm(request.POST) 146 | if policyForm.is_valid(): 147 | categoryid = request.POST.get('category') 148 | category = models.Category.objects.get(id=categoryid) 149 | 150 | policy = policyForm.save(commit=False) 151 | policy.category=category 152 | policy.save() 153 | return redirect('admin-view-policy') 154 | return render(request,'insurance/admin_add_policy.html',{'policyForm':policyForm}) 155 | 156 | def admin_view_policy_view(request): 157 | policies = models.Policy.objects.all() 158 | return render(request,'insurance/admin_view_policy.html',{'policies':policies}) 159 | 160 | 161 | 162 | def admin_update_policy_view(request): 163 | policies = models.Policy.objects.all() 164 | return render(request,'insurance/admin_update_policy.html',{'policies':policies}) 165 | 166 | @login_required(login_url='adminlogin') 167 | def update_policy_view(request,pk): 168 | policy = models.Policy.objects.get(id=pk) 169 | policyForm=forms.PolicyForm(instance=policy) 170 | 171 | if request.method=='POST': 172 | policyForm=forms.PolicyForm(request.POST,instance=policy) 173 | 174 | if policyForm.is_valid(): 175 | 176 | categoryid = request.POST.get('category') 177 | category = models.Category.objects.get(id=categoryid) 178 | 179 | policy = policyForm.save(commit=False) 180 | policy.category=category 181 | policy.save() 182 | 183 | return redirect('admin-update-policy') 184 | return render(request,'insurance/update_policy.html',{'policyForm':policyForm}) 185 | 186 | 187 | def admin_delete_policy_view(request): 188 | policies = models.Policy.objects.all() 189 | return render(request,'insurance/admin_delete_policy.html',{'policies':policies}) 190 | 191 | def delete_policy_view(request,pk): 192 | policy = models.Policy.objects.get(id=pk) 193 | policy.delete() 194 | return redirect('admin-delete-policy') 195 | 196 | def admin_view_policy_holder_view(request): 197 | policyrecords = models.PolicyRecord.objects.all() 198 | return render(request,'insurance/admin_view_policy_holder.html',{'policyrecords':policyrecords}) 199 | 200 | def admin_view_approved_policy_holder_view(request): 201 | policyrecords = models.PolicyRecord.objects.all().filter(status='Approved') 202 | return render(request,'insurance/admin_view_approved_policy_holder.html',{'policyrecords':policyrecords}) 203 | 204 | def admin_view_disapproved_policy_holder_view(request): 205 | policyrecords = models.PolicyRecord.objects.all().filter(status='Disapproved') 206 | return render(request,'insurance/admin_view_disapproved_policy_holder.html',{'policyrecords':policyrecords}) 207 | 208 | def admin_view_waiting_policy_holder_view(request): 209 | policyrecords = models.PolicyRecord.objects.all().filter(status='Pending') 210 | return render(request,'insurance/admin_view_waiting_policy_holder.html',{'policyrecords':policyrecords}) 211 | 212 | def approve_request_view(request,pk): 213 | policyrecords = models.PolicyRecord.objects.get(id=pk) 214 | policyrecords.status='Approved' 215 | policyrecords.save() 216 | return redirect('admin-view-policy-holder') 217 | 218 | def disapprove_request_view(request,pk): 219 | policyrecords = models.PolicyRecord.objects.get(id=pk) 220 | policyrecords.status='Disapproved' 221 | policyrecords.save() 222 | return redirect('admin-view-policy-holder') 223 | 224 | 225 | def admin_question_view(request): 226 | questions = models.Question.objects.all() 227 | return render(request,'insurance/admin_question.html',{'questions':questions}) 228 | 229 | def update_question_view(request,pk): 230 | question = models.Question.objects.get(id=pk) 231 | questionForm=forms.QuestionForm(instance=question) 232 | 233 | if request.method=='POST': 234 | questionForm=forms.QuestionForm(request.POST,instance=question) 235 | 236 | if questionForm.is_valid(): 237 | 238 | admin_comment = request.POST.get('admin_comment') 239 | 240 | 241 | question = questionForm.save(commit=False) 242 | question.admin_comment=admin_comment 243 | question.save() 244 | 245 | return redirect('admin-question') 246 | return render(request,'insurance/update_question.html',{'questionForm':questionForm}) 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | def aboutus_view(request): 255 | return render(request,'insurance/aboutus.html') 256 | 257 | def contactus_view(request): 258 | sub = forms.ContactusForm() 259 | if request.method == 'POST': 260 | sub = forms.ContactusForm(request.POST) 261 | if sub.is_valid(): 262 | email = sub.cleaned_data['Email'] 263 | name=sub.cleaned_data['Name'] 264 | message = sub.cleaned_data['Message'] 265 | send_mail(str(name)+' || '+str(email),message,settings.EMAIL_HOST_USER, settings.EMAIL_RECEIVING_USER, fail_silently = False) 266 | return render(request, 'insurance/contactussuccess.html') 267 | return render(request, 'insurance/contactus.html', {'form':sub}) 268 | 269 | --------------------------------------------------------------------------------