first push

This commit is contained in:
2025-05-23 14:44:12 +08:00
commit abefd1b19b
817 changed files with 580289 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
import pymysql
pymysql.install_as_MySQLdb()
+16
View File
@@ -0,0 +1,16 @@
"""
ASGI config for AssetManagement 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/3.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'AssetManagement.settings')
application = get_asgi_application()
+2
View File
@@ -0,0 +1,2 @@
[settings]
DEBUG=True
+184
View File
@@ -0,0 +1,184 @@
"""
Django settings for AssetManagement project.
Generated by 'django-admin startproject' using Django 3.2.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from ctypes import cast
from pathlib import Path
from dotenv import load_dotenv
import os
from decouple import config
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
load_dotenv()
LOGIN_REDIRECT_URL = '/'
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# SECRET_KEY = os.environ.get('SECRET_KEY')
SECRET_KEY = "django-insecure-^o6u10km7xey-)n6ng+hh2rxm+ydcvor*)$fnl7)3_i)nu)a&x"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG')
ALLOWED_HOSTS = ['*']
LOCALHOST_URL = 'http:127.0.0.1:8000'
DEV_URL = os.environ.get('DEV_URL') if os.getcwd() == "/app" else None
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'authentication',
'vendors',
'products',
'assets',
'dashboard',
'recycle_bin',
'upload',
'error_handlers',
'smart_selects',
'roles',
'users',
'support',
'notifications',
'simple_history'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'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',
'simple_history.middleware.HistoryRequestMiddleware'
]
ROOT_URLCONF = 'AssetManagement.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / '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 = 'AssetManagement.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'eamtest', # 数据库名字
'USER': 'root',
'PASSWORD': 'guoan123',
'HOST': '127.0.0.1',
'PORT': 3306,
}
}
# Password validation
# https://docs.djangoproject.com/en/3.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/3.2/topics/i18n/
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = False
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'staticfiles'
STATICFILES_DIRS = [
BASE_DIR/'static'
]
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'authentication.User'
LOGIN_URL = 'authentication:login'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.environ.get('EMAIL_HOST')
EMAIL_PORT = os.environ.get('EMAIL_PORT')
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
#Image Processing
DJANGORESIZED_DEFAULT_SIZE = [1024, 768]
DJANGORESIZED_DEFAULT_QUALITY = 75
DJANGORESIZED_DEFAULT_KEEP_META = True
DJANGORESIZED_DEFAULT_FORCE_FORMAT = 'JPEG'
DJANGORESIZED_DEFAULT_FORMAT_EXTENSIONS = {'JPEG': ".jpg"}
DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = True
+69
View File
@@ -0,0 +1,69 @@
"""AssetManagement URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.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, include
from django.contrib.auth import views as auth_views
from django.conf import settings
from django.conf.urls.static import static
from authentication.forms import UserPasswordChangeForm, UserPasswordResetForm, UserPasswordResetRequestForm
from authentication.decorators import unauthenticated_user
urlpatterns = [
path('secret/', admin.site.urls),
path('', include('authentication.urls', namespace='authentication')),
path('vendors/', include('vendors.urls', namespace='vendors')),
path('products/', include('products.urls', namespace='products')),
path('admin/', include('dashboard.urls', namespace='dashboard')),
path('upload/', include('upload.urls', namespace='upload')),
path('recycle-bin/', include('recycle_bin.urls', namespace='recycle_bin')),
path('assets/', include('assets.urls', namespace='assets')),
path('roles/', include('roles.urls', namespace='roles')),
path('support/', include('support.urls', namespace='support')),
path('users/', include('users.urls', namespace='users')),
path('notifications/', include('notifications.urls', namespace='notifications')),
# django smart select urls
path('chaining/', include('smart_selects.urls')),
# Password Change Views
path('change-password/', auth_views.PasswordChangeView.as_view(form_class=UserPasswordChangeForm,
template_name='auth/password/password-change.html'), name='password_change'),
path('change-password/done/', auth_views.PasswordChangeDoneView.as_view(
template_name='auth/password/password-change-done.html'), name='password_change_done'),
# Password Reset Views
path('reset-password/', unauthenticated_user(auth_views.PasswordResetView.as_view(form_class=UserPasswordResetRequestForm,
template_name='auth/password/password-reset.html', html_email_template_name='auth/verification/password_reset_html_email.html')), name="password_reset"),
path('reset-password/done/', unauthenticated_user(auth_views.PasswordResetDoneView.as_view(
template_name='auth/password/password-reset-done.html')), name="password_reset_done"),
path('reset/<uidb64>/<token>', unauthenticated_user(auth_views.PasswordResetConfirmView.as_view(form_class=UserPasswordResetForm,
template_name='auth/password/password-reset-confirm.html')), name="password_reset_confirm"),
path('reset/done/', unauthenticated_user(auth_views.PasswordResetCompleteView.as_view(
template_name='auth/password/password-reset-complete.html')), name="password_reset_complete"),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# Error Handlers
handler403 = 'error_handlers.views.handle_403'
handler404 = 'error_handlers.views.handle_404'
handler500 = 'error_handlers.views.handle_500'
+16
View File
@@ -0,0 +1,16 @@
"""
WSGI config for AssetManagement 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/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'AssetManagement.settings')
application = get_wsgi_application()