Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
settings.py
db_project/db_project/settings.py
requirements.txt
dbportal
Binary file added db_project/db.sqlite3
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
141 changes: 141 additions & 0 deletions db_project/db_project/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
"""
Django settings for db_project project.

Generated by 'django-admin startproject' using Django 2.2.6.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
TEMPLATE_DIR = os.path.join(BASE_DIR, "templates")
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '6!ijkl#2#l*emudsy#3k5^kzg#yrqg_*)bufj&*ic7+jbdbn!8'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'staff',
########
'rest_framework',
'rest_framework.authtoken',
#######
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'db_project.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATE_DIR],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
FILE_UPLOAD_HANDLERS = ("django_excel.ExcelMemoryFileUploadHandler",
"django_excel.TemporaryExcelFileUploadHandler")
WSGI_APPLICATION = 'db_project.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10,
# 'DEFAULT_AUTHENTICATION_CLASSES': ['rest_framework.authentication.BasicAuthentication',
# 'rest_framework.authentication.SessionAuthentication']
# 'rest_framework.authentication.TokenAuthentication', # <-- And here

}

# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
# {
# 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
# },
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
# {
# 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
# },
# {
# 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
# },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'



# Mail is sent using the SMTP host and port specified in the EMAIL_HOST and EMAIL_PORT settings. The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD settings, if set, are used to authenticate to the SMTP server, and the EMAIL_USE_TLS and EMAIL_USE_SSL settings control whether a secure connection is used.
24 changes: 24 additions & 0 deletions db_project/db_project/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""db_project URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include


urlpatterns = [
path('admin/', admin.site.urls),
path('',include('staff.urls'))
]
16 changes: 16 additions & 0 deletions db_project/db_project/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for db_project project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'db_project.settings')

application = get_wsgi_application()
21 changes: 21 additions & 0 deletions db_project/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'db_project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Binary file added db_project/media/excel_sheets/dber.xlsx
Binary file not shown.
Binary file added db_project/media/excel_sheets/dber_3LpzvXE.xlsx
Binary file not shown.
Binary file added db_project/media/excel_sheets/dber_67yvvnP.xlsx
Binary file not shown.
Binary file added db_project/media/excel_sheets/dber_eExDqQi.xlsx
Binary file not shown.
Binary file added db_project/media/excel_sheets/sample_excel.xlsx
Binary file not shown.
Empty file added db_project/staff/__init__.py
Empty file.
Binary file added db_project/staff/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added db_project/staff/__pycache__/admin.cpython-37.pyc
Binary file not shown.
Binary file added db_project/staff/__pycache__/extras.cpython-37.pyc
Binary file not shown.
Binary file added db_project/staff/__pycache__/forms.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added db_project/staff/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file added db_project/staff/__pycache__/views.cpython-37.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions db_project/staff/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib import admin
from .models import *


admin.site.register(user_profile)
admin.site.register(user_excel)
admin.site.register(State)
admin.site.register(Staff)
admin.site.register(City)

# Register your models here.
5 changes: 5 additions & 0 deletions db_project/staff/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class StaffConfig(AppConfig):
name = 'staff'
27 changes: 27 additions & 0 deletions db_project/staff/extras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def getquery_name(name,query,objs):
if (query == "all"):
return objs
list = []
for obj in objs:
if obj.user_profile.name == query:
list.append(obj)
return list

def getquery_state(state,query,objs):
if (query == "all"):
return objs
list = []
for obj in objs:
if obj.user_profile.state.name == query:
list.append(obj)
return list

def getquery_city(city,query,objs):
if (query == "all"):
return objs
list = []
for obj in objs:
if obj.user_profile.city.name == query:
list.append(obj)

return list
56 changes: 56 additions & 0 deletions db_project/staff/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from .models import *
from django import forms
from django.contrib.auth.models import User


class excel_form(forms.ModelForm):
class Meta:
model = user_excel
fields = ['sheet']


class user_form(forms.ModelForm):
class Meta:
model = user_profile
exclude = ['adhaar_linked','Password','username','email','user']



class staff_form(forms.ModelForm):
class Meta:
model = Staff
fields = '__all__'
# def __init__(self, *args, **kwargs):
# super().__init__(*args, **kwargs)
# self.fields['city'].queryset = City.objects.none()

class register_form(forms.Form):
Adhaar = forms.IntegerField(label='adhaar_no')
username = forms.CharField(max_length=200,label = 'user-name')
password = forms.CharField(max_length=200,label = 'password')
email = forms.EmailField(label='email')


class login_form(forms.Form):
username = forms.CharField(max_length=200,label = 'user-name')
password = forms.CharField(max_length=200,label = 'password')

class profileForm(forms.ModelForm):
class Meta:
model = user_profile
fields = ['Password','name','email','state','city','DOB']

class staffprofileForm(forms.ModelForm):
class Meta:
model = Staff
fields = ['Password','name','email','state','city']

class email_form(forms.Form):
subject = forms.CharField(max_length =500,label = 'Subject')
content = forms.CharField(widget=forms.Textarea)
send_to = forms.EmailField(label='Send To')


class staff_email_form(forms.Form):
subject = forms.CharField(max_length =500,label = 'Subject')
content = forms.CharField(widget=forms.Textarea)
33 changes: 33 additions & 0 deletions db_project/staff/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 2.2.6 on 2019-12-17 05:44

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='staff_excel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sheet', models.FileField(upload_to='')),
],
),
migrations.CreateModel(
name='Staff_profile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('adhaar_no', models.IntegerField()),
('name', models.CharField(max_length=100)),
('DOB', models.DateTimeField()),
('gender', models.CharField(choices=[('Male', 'Male'), ('Female', 'Female')], max_length=10)),
('city', models.CharField(max_length=100)),
('state', models.CharField(max_length=100)),
],
),
]
21 changes: 21 additions & 0 deletions db_project/staff/migrations/0002_staff_excel_uploaded_by.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 2.2.6 on 2019-12-17 05:53

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('staff', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='staff_excel',
name='uploaded_by',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]
17 changes: 17 additions & 0 deletions db_project/staff/migrations/0003_remove_staff_excel_uploaded_by.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.2.6 on 2019-12-17 06:36

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('staff', '0002_staff_excel_uploaded_by'),
]

operations = [
migrations.RemoveField(
model_name='staff_excel',
name='uploaded_by',
),
]
Loading