From 1d3c1d6e4c7a3d0258d63f20440b5c55459916f1 Mon Sep 17 00:00:00 2001 From: sshermat Date: Thu, 21 Nov 2024 13:08:13 +0500 Subject: [PATCH] updated --- .gitignore | 1 + {essential_words => config}/__init__.py | 0 essential_words/asgi.py | 16 --- essential_words/settings.py | 143 ------------------------ essential_words/urls.py | 18 --- essential_words/wsgi.py | 16 --- quiz/static/JS/script.js | 30 ----- 7 files changed, 1 insertion(+), 223 deletions(-) rename {essential_words => config}/__init__.py (100%) delete mode 100644 essential_words/asgi.py delete mode 100644 essential_words/settings.py delete mode 100644 essential_words/urls.py delete mode 100644 essential_words/wsgi.py diff --git a/.gitignore b/.gitignore index 8643177..d32ed6f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ __pycache__/ #Ignore VS Code settings .vscode/ +.env diff --git a/essential_words/__init__.py b/config/__init__.py similarity index 100% rename from essential_words/__init__.py rename to config/__init__.py diff --git a/essential_words/asgi.py b/essential_words/asgi.py deleted file mode 100644 index b594a42..0000000 --- a/essential_words/asgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -ASGI config for essential_words 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/5.0/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'essential_words.settings') - -application = get_asgi_application() diff --git a/essential_words/settings.py b/essential_words/settings.py deleted file mode 100644 index 96c7146..0000000 --- a/essential_words/settings.py +++ /dev/null @@ -1,143 +0,0 @@ -# settings.py -import pymysql -pymysql.install_as_MySQLdb() -import os -from pathlib import Path -from dotenv import load_dotenv - - -load_dotenv() -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = os.getenv('SECRET_KEY') - - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = os.getenv('DEBUG') == 'True' - -ALLOWED_HOSTS = [os.getenv('DATABASE_HOST'), 'essential-words.com'] - - -# Application definition - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'rest_framework', - 'quiz', - 'debug_toolbar', -] - -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', - 'debug_toolbar.middleware.DebugToolbarMiddleware', -] - -ROOT_URLCONF = 'essential_words.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'quiz', 'templates')], - '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 = 'essential_words.wsgi.application' - - -# Database -# https://docs.djangoproject.com/en/5.0/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': os.getenv('DATABASE_NAME'), - 'USER': os.getenv('DATABASE_USER'), - 'PASSWORD': os.getenv('DATABASE_PASSWORD'), - 'HOST': os.getenv('DATABASE_HOST'), - 'PORT': os.getenv('DATABASE_PORT'), - } -} - - -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'handlers': { - 'console': { - 'level': 'DEBUG', - 'class': 'logging.StreamHandler', - }, - }, - 'loggers': { - 'django.db.backends': { - 'handlers': ['console'], - 'level': 'DEBUG', - }, - }, -} - -# Password validation -# https://docs.djangoproject.com/en/5.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/5.0/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) - -STATIC_URL = 'static/' -STATICFILES_DIRS = [ - os.path.join(BASE_DIR, 'quiz', 'static'), -] - -# Default primary key field type -# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/essential_words/urls.py b/essential_words/urls.py deleted file mode 100644 index 9677bce..0000000 --- a/essential_words/urls.py +++ /dev/null @@ -1,18 +0,0 @@ -# essential_words/urls.py -from django.contrib import admin -from django.urls import path, include -from quiz import views -from django.conf import settings -from django.conf.urls import include - - -urlpatterns = [ - path('admin/', admin.site.urls), - path('', include('quiz.urls')), -] - -if settings.DEBUG: - import debug_toolbar - urlpatterns = [ - path('__debug__/', include('debug_toolbar.urls')) - ] + urlpatterns diff --git a/essential_words/wsgi.py b/essential_words/wsgi.py deleted file mode 100644 index 8e4fc1e..0000000 --- a/essential_words/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for essential_words 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/5.0/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'essential_words.settings') - -application = get_wsgi_application() diff --git a/quiz/static/JS/script.js b/quiz/static/JS/script.js index 6400144..04be0df 100644 --- a/quiz/static/JS/script.js +++ b/quiz/static/JS/script.js @@ -341,33 +341,3 @@ document.addEventListener('dblclick',function(e){ e.preventDefault(); }); - -// 1. Use URL parameters -// Modify your JavaScript to update the URL when changing pages -function updateURL(page) { - history.pushState(null, '', `?page=${page}`); - } - - // Check URL parameters on page load - window.addEventListener('load', () => { - const urlParams = new URLSearchParams(window.location.search); - const page = urlParams.get('page'); - if (page) { - // Load the appropriate page based on the URL parameter - loadPage(page); - } - }); - - // 2. Use localStorage -// Save the current page state -// function savePage(page) { -// localStorage.setItem('currentPage', page); -// } - -// // Load the saved page on refresh -// window.addEventListener('load', () => { -// const savedPage = localStorage.getItem('currentPage'); -// if (savedPage) { -// loadPage(savedPage); -// } -// }); \ No newline at end of file