@@ -0,0 +1,16 @@ | |||||
""" | |||||
ASGI config for Hello project. | |||||
It exposes the ASGI callable as a module-level variable named ``application``. | |||||
For more information on this file, see | |||||
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ | |||||
""" | |||||
import os | |||||
from django.core.asgi import get_asgi_application | |||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Hello.settings') | |||||
application = get_asgi_application() |
@@ -0,0 +1,141 @@ | |||||
""" | |||||
Django settings for Hello project. | |||||
Generated by 'django-admin startproject' using Django 4.0.6. | |||||
For more information on this file, see | |||||
https://docs.djangoproject.com/en/4.0/topics/settings/ | |||||
For the full list of settings and their values, see | |||||
https://docs.djangoproject.com/en/4.0/ref/settings/ | |||||
""" | |||||
from pathlib import Path | |||||
import os #manual | |||||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | |||||
BASE_DIR = Path(__file__).resolve().parent.parent | |||||
# Quick-start development settings - unsuitable for production | |||||
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ | |||||
# SECURITY WARNING: keep the secret key used in production secret! | |||||
SECRET_KEY = 'django-insecure-+a2^9tz2x4lv$-p@ya%ekby8v7v13@^j6%o(226-t^$bk-ah=t' | |||||
# SECURITY WARNING: don't run with debug turned on in production! | |||||
DEBUG = True | |||||
ALLOWED_HOSTS = [] | |||||
# Application definition | |||||
INSTALLED_APPS = [ | |||||
'jazzmin', #manually added | |||||
'django.contrib.admin', | |||||
'django.contrib.auth', | |||||
'django.contrib.contenttypes', | |||||
'django.contrib.sessions', | |||||
'django.contrib.messages', | |||||
'django.contrib.staticfiles', | |||||
'Info' | |||||
] | |||||
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 = 'Hello.urls' | |||||
TEMPLATES = [ | |||||
{ | |||||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |||||
'DIRS': [], | |||||
'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', | |||||
], | |||||
}, | |||||
}, | |||||
] | |||||
WSGI_APPLICATION = 'Hello.wsgi.application' | |||||
# Database | |||||
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases | |||||
DATABASES = { | |||||
'default': { | |||||
'ENGINE': 'django.db.backends.mysql', | |||||
'NAME': 'mydatabase', | |||||
'USER': 'root', | |||||
'PASSWORD': '1234', | |||||
'HOST': 'localhost', # Or an IP Address that your DB is hosted on | |||||
'PORT': '3306', | |||||
} | |||||
} | |||||
# Password validation | |||||
# https://docs.djangoproject.com/en/4.0/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/4.0/topics/i18n/ | |||||
LANGUAGE_CODE = 'en-us' | |||||
TIME_ZONE = 'UTC' | |||||
USE_I18N = True | |||||
USE_TZ = True | |||||
# Static files (CSS, JavaScript, Images) | |||||
# https://docs.djangoproject.com/en/4.0/howto/static-files/ | |||||
STATIC_URL = 'static/' | |||||
# Default primary key field type | |||||
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field | |||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' | |||||
#Manually added everything below | |||||
# EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" | |||||
# EMAIL_USE_TLS = True | |||||
# EMAIL_HOST = "smtp.gmail.com" | |||||
# EMAIL_PORT = 25 | |||||
# EMAIL_HOST_USER = os.environ.get("EMAIL_USER") | |||||
# EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_PASSWORD") | |||||
# DEFAULT_FROM_EMAIL = EMAIL_HOST_USER | |||||
@@ -0,0 +1,4 @@ | |||||
from django.core.mail import EmailMessage | |||||
email = EmailMessage('Subject here', 'Here is the message.',['siddharthsrivastava77@gmail.com']) | |||||
email.send() | |||||
@@ -0,0 +1,33 @@ | |||||
"""Hello URL Configuration | |||||
The `urlpatterns` list routes URLs to views. For more information please see: | |||||
https://docs.djangoproject.com/en/4.0/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, include #include manually added | |||||
from django.contrib.auth import views as auth_views #Manually added | |||||
# from Info import views #Manually added | |||||
#Manually added (20,21,22) | |||||
admin.site.site_header = "UMSRA Admin" | |||||
admin.site.site_title = "UMSRA Admin Portal" | |||||
admin.site.index_title = "Welcome to UMSRA Researcher Portal" | |||||
urlpatterns = [ | |||||
#Everything below is manually added | |||||
path('admin/password_reset/', auth_views.PasswordResetView.as_view(), name='admin_password_reset'), | |||||
path('admin/password_reset/done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'), | |||||
path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'), | |||||
path('reset/done/', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'), | |||||
path('admin/', admin.site.urls) | |||||
] |
@@ -0,0 +1,16 @@ | |||||
""" | |||||
WSGI config for Hello 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/4.0/howto/deployment/wsgi/ | |||||
""" | |||||
import os | |||||
from django.core.wsgi import get_wsgi_application | |||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Hello.settings') | |||||
application = get_wsgi_application() |
@@ -0,0 +1,15 @@ | |||||
from django.contrib import admin | |||||
from django.contrib.auth.models import Group, User | |||||
from .models import UserDeviceInformation | |||||
# Register your models here. | |||||
class UserDeviceInformationAdmin(admin.ModelAdmin): | |||||
list_display = ('device', 'browser', 'date', 'session_id') | |||||
list_display_links = None | |||||
admin.site.register(UserDeviceInformation, UserDeviceInformationAdmin) | |||||
admin.site.unregister(Group) | |||||
admin.site.unregister(User) |
@@ -0,0 +1,7 @@ | |||||
from django.apps import AppConfig | |||||
class InfoConfig(AppConfig): | |||||
default_auto_field = "django.db.models.BigAutoField" | |||||
name = "Info" | |||||
verbose_name = "" |
@@ -0,0 +1,24 @@ | |||||
from django.db import models | |||||
# Create your models here. | |||||
# This is an auto-generated Django model module. | |||||
# You'll have to do the following manually to clean this up: | |||||
# * Rearrange models' order | |||||
# * Make sure each model has one field with primary_key=True | |||||
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior | |||||
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table | |||||
# Feel free to rename the models, but don't rename db_table values or field names. | |||||
from django.db import models | |||||
class UserDeviceInformation(models.Model): | |||||
device = models.CharField(db_column='Device', max_length=255, blank=True, null=True) # Field name made lowercase. | |||||
browser = models.CharField(db_column='Browser', max_length=255, blank=True, null=True) # Field name made lowercase. | |||||
date = models.CharField(db_column='Date', max_length=255, blank=True, null=True) # Field name made lowercase. | |||||
session_id = models.CharField(db_column='Session_ID', max_length=255, blank=True, primary_key=True) # Field name made lowercase. | |||||
class Meta: | |||||
managed = False | |||||
db_table = 'user_device_information' | |||||
verbose_name_plural = "User Information" | |||||
ordering = ['date'] |
@@ -0,0 +1,3 @@ | |||||
from django.test import TestCase | |||||
# Create your tests here. |
@@ -0,0 +1,3 @@ | |||||
from django.shortcuts import render | |||||
# Create your views here. |
@@ -0,0 +1,22 @@ | |||||
#!/usr/bin/env python | |||||
"""Django's command-line utility for administrative tasks.""" | |||||
import os | |||||
import sys | |||||
def main(): | |||||
"""Run administrative tasks.""" | |||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Hello.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() |