cf153fa8eac13cacc94337R99">99
+ "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
|
|
100
|
+ },
|
|
|
101
|
+ {
|
|
|
102
|
+ "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
|
|
103
|
+ },
|
|
|
104
|
+ {
|
|
|
105
|
+ "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
|
|
106
|
+ },
|
|
|
107
|
+ {
|
|
|
108
|
+ "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
|
|
109
|
+ },
|
|
|
110
|
+]
|
|
|
111
|
+
|
|
|
112
|
+
|
|
|
113
|
+# Internationalization
|
|
|
114
|
+# https://docs.djangoproject.com/en/5.1/topics/i18n/
|
|
|
115
|
+
|
|
|
116
|
+LANGUAGE_CODE = "en-us"
|
|
|
117
|
+
|
|
|
118
|
+TIME_ZONE = "UTC"
|
|
|
119
|
+
|
|
|
120
|
+USE_I18N = True
|
|
|
121
|
+
|
|
|
122
|
+USE_TZ = True
|
|
|
123
|
+
|
|
|
124
|
+
|
|
|
125
|
+# Static files (CSS, JavaScript, Images)
|
|
|
126
|
+# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
|
|
127
|
+
|
|
|
128
|
+STATIC_URL = "static/"
|
|
|
129
|
+
|
|
|
130
|
+# Default primary key field type
|
|
|
131
|
+# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
|
|
132
|
+
|
|
|
133
|
+DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+"""
|
|
|
2
|
+URL configuration for coi project.
|
|
|
3
|
+
|
|
|
4
|
+The `urlpatterns` list routes URLs to views. For more information please see:
|
|
|
5
|
+ https://docs.djangoproject.com/en/5.1/topics/http/urls/
|
|
|
6
|
+Examples:
|
|
|
7
|
+Function views
|
|
|
8
|
+ 1. Add an import: from my_app import views
|
|
|
9
|
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
|
10
|
+Class-based views
|
|
|
11
|
+ 1. Add an import: from other_app.views import Home
|
|
|
12
|
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
|
13
|
+Including another URLconf
|
|
|
14
|
+ 1. Import the include() function: from django.urls import include, path
|
|
|
15
|
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
|
16
|
+"""
|
|
|
17
|
+
|
|
|
18
|
+from django.contrib import admin
|
|
|
19
|
+from django.urls import path
|
|
|
20
|
+
|
|
|
21
|
+urlpatterns = [
|
|
|
22
|
+ path("admin/", admin.site.urls),
|
|
|
23
|
+]
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+"""
|
|
|
2
|
+WSGI config for coi 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/5.1/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", "coi.settings")
|
|
|
15
|
+
|
|
|
16
|
+application = get_wsgi_application()
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+from django.contrib import admin
|
|
|
2
|
+
|
|
|
3
|
+# Register your models here.
|
|
|
4
|
+from django.contrib import admin
|
|
|
5
|
+from .models import Report
|
|
|
6
|
+
|
|
|
7
|
+@admin.register(Report)
|
|
|
8
|
+class ReportAdmin(admin.ModelAdmin):
|
|
|
9
|
+ list_display = ('name', 'created_by', 'created_at', 'updated_at')
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+from django.apps import AppConfig
|
|
|
2
|
+
|
|
|
3
|
+
|
|
|
4
|
+class CoreConfig(AppConfig):
|
|
|
5
|
+ default_auto_field = 'django.db.models.BigAutoField'
|
|
|
6
|
+ name = 'core'
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+# Generated by Django 5.0 on 2024-12-21 13:45
|
|
|
2
|
+
|
|
|
3
|
+import django.db.models.deletion
|
|
|
4
|
+from django.conf import settings
|
|
|
5
|
+from django.db import migrations, models
|
|
|
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='Report',
|
|
|
19
|
+ fields=[
|
|
|
20
|
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
|
21
|
+ ('name', models.CharField(max_length=255)),
|
|
|
22
|
+ ('created_at', models.DateTimeField(auto_now_add=True)),
|
|
|
23
|
+ ('updated_at', models.DateTimeField(auto_now=True)),
|
|
|
24
|
+ ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reports', to=settings.AUTH_USER_MODEL)),
|
|
|
25
|
+ ],
|
|
|
26
|
+ ),
|
|
|
27
|
+ ]
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+from django.db import models
|
|
|
2
|
+
|
|
|
3
|
+# Create your models here.
|
|
|
4
|
+from django.contrib.auth.models import User # Assuming you're using Django's built-in User model
|
|
|
5
|
+
|
|
|
6
|
+class Report(models.Model):
|
|
|
7
|
+ name = models.CharField(max_length=255) # Name of the report
|
|
|
8
|
+ created_by = models.ForeignKey(
|
|
|
9
|
+ User,
|
|
|
10
|
+ on_delete=models.CASCADE,
|
|
|
11
|
+ related_name="reports"
|
|
|
12
|
+ ) # Reference to the user who created the report
|
|
|
13
|
+ created_at = models.DateTimeField(auto_now_add=True) # Automatically set when created
|
|
|
14
|
+ updated_at = models.DateTimeField(auto_now=True) # Automatically updated when modified
|
|
|
15
|
+
|
|
|
16
|
+ def __str__(self):
|
|
|
17
|
+ return self.name
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+from django.test import TestCase
|
|
|
2
|
+
|
|
|
3
|
+# Create your tests here.
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+from django.shortcuts import render
|
|
|
2
|
+
|
|
|
3
|
+# Create your views here.
|
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+ """Run administrative tasks."""
|
|
|
9
|
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "coi.settings")
|
|
|
10
|
+ try:
|
|
|
11
|
+ from django.core.management import execute_from_command_line
|
|
|
12
|
+ except ImportError as exc:
|
|
|
13
|
+ raise ImportError(
|
|
|
14
|
+ "Couldn't import Django. Are you sure it's installed and "
|
|
|
15
|
+ "available on your PYTHONPATH environment variable? Did you "
|
|
|
16
|
+ "forget to activate a virtual environment?"
|
|
|
17
|
+ ) from exc
|
|
|
18
|
+ execute_from_command_line(sys.argv)
|
|
|
19
|
+
|
|
|
20
|
+
|
|
|
21
|
+if __name__ == "__main__":
|
|
|
22
|
+ main()
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'coi_db')
|
|
|
2
|
+BEGIN
|
|
|
3
|
+ CREATE DATABASE coi_db;
|
|
|
4
|
+END;
|
|
|
5
|
+GO
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+version: '3.9'
|
|
|
2
|
+
|
|
|
3
|
+services:
|
|
|
4
|
+ db:
|
|
|
5
|
+ image: mcr.microsoft.com/mssql/server:2019-latest
|
|
|
6
|
+ user: root
|
|
|
7
|
+ container_name: mssql_db
|
|
|
8
|
+ environment:
|
|
|
9
|
+ SA_PASSWORD: "StrongPassw0rd!"
|
|
|
10
|
+ ACCEPT_EULA: "Y"
|
|
|
11
|
+ ports:
|
|
|
12
|
+ - "1433:1433"
|
|
|
13
|
+ volumes:
|
|
|
14
|
+ - db_data:/var/opt/mssql/data
|
|
|
15
|
+ - ./db-init:/init-scripts # Add this line to mount the initialization script
|
|
|
16
|
+ - ./entrypoint.sh:/usr/local/bin/entrypoint.sh
|
|
|
17
|
+ #command: /bin/bash -c "/opt/mssql/bin/sqlservr && sleep 5 && /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P StrongPassw0rd! -i /init-scripts/create-database.sql"
|
|
|
18
|
+ #healthcheck:
|
|
|
19
|
+ #test: ["CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P StrongPassw0rd! -Q 'SELECT 1'"]
|
|
|
20
|
+ #interval: 10s
|
|
|
21
|
+ #timeout: 5s
|
|
|
22
|
+ #retries: 5
|
|
|
23
|
+ entrypoint: ["/usr/local/bin/entrypoint.sh"]
|
|
|
24
|
+ restart: always
|
|
|
25
|
+
|
|
|
26
|
+ web:
|
|
|
27
|
+ build: .
|
|
|
28
|
+ container_name: django_web
|
|
|
29
|
+ volumes:
|
|
|
30
|
+ - ./app:/app
|
|
|
31
|
+ ports:
|
|
|
32
|
+ - "8000:8000"
|
|
|
33
|
+ depends_on:
|
|
|
34
|
+ db:
|
|
|
35
|
+ condition: service_started
|
|
|
36
|
+ #condition: service_healthy
|
|
|
37
|
+ environment:
|
|
|
38
|
+ DB_NAME: "coi_db"
|
|
|
39
|
+ DB_USER: "sa"
|
|
|
40
|
+ DB_PASSWORD: "StrongPassw0rd!"
|
|
|
41
|
+ DB_HOST: "db"
|
|
|
42
|
+ DB_PORT: "1433"
|
|
|
43
|
+ restart: always
|
|
|
44
|
+
|
|
|
45
|
+volumes:
|
|
|
46
|
+ db_data:
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+#!/bin/bash
|
|
|
2
|
+
|
|
|
3
|
+# Start SQL Server in the background
|
|
|
4
|
+/opt/mssql/bin/sqlservr &
|
|
|
5
|
+
|
|
|
6
|
+# Wait for SQL Server to start
|
|
|
7
|
+echo "Waiting for SQL Server to start..."
|
|
|
8
|
+sleep 15
|
|
|
9
|
+
|
|
|
10
|
+# Run the database initialization script
|
|
|
11
|
+echo "Running initialization script..."
|
|
|
12
|
+/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P StrongPassw0rd! -i /init-scripts/create-database.sql
|
|
|
13
|
+
|
|
|
14
|
+# Wait indefinitely to keep the container running
|
|
|
15
|
+wait
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+Django==5.0
|
|
|
2
|
+mssql-django
|
|
|
3
|
+pyodbc==4.0.39
|
|
|
4
|
+# For filtering and querying
|
|
|
5
|
+django-filter # Simplified filtering
|
|
|
6
|
+
|
|
|
7
|
+# For tables/grid view
|
|
|
8
|
+django-tables2 # HTML table rendering
|
|
|
9
|
+
|
|
|
10
|
+# For exporting to Excel
|
|
|
11
|
+openpyxl # Generating Excel files
|
|
|
12
|
+
|
|
|
13
|
+# For API development (optional)
|
|
|
14
|
+djangorestframework # REST API support
|
|
|
15
|
+drf-yasg # Swagger and ReDoc for API documentation (optional)
|
|
|
16
|
+
|
|
|
17
|
+# Admin enhancements (optional)
|
|
|
18
|
+django-import-export # Export/import for admin
|
|
|
19
|
+
|
|
|
20
|
+# Authentication enhancements (optional)
|
|
|
21
|
+django-allauth # For user authentication (optional)
|
|
|
22
|
+
|
|
|
23
|
+# Debugging and performance
|
|
|
24
|
+django-debug-toolbar # Debugging SQL queries and performance issues
|
|
|
25
|
+
|
|
|
26
|
+# Testing (optional)
|
|
|
27
|
+pytest
|
|
|
28
|
+pytest-django
|
|
|
29
|
+factory-boy # Test data creation
|
|
|
30
|
+
|
|
|
31
|
+# Frontend styling (if using Bootstrap or TailwindCSS)
|
|
|
32
|
+django-crispy-forms # Styling for forms
|
|
|
33
|
+crispy-bootstrap5 # For Bootstrap 5 support (optional)
|
|
|
34
|
+
|
|
|
35
|
+# If using TailwindCSS instead of Bootstrap
|
|
|
36
|
+django-tailwind # For TailwindCSS integration
|
|
|
37
|
+
|
|
|
38
|
+# Cache optimization (optional)
|
|
|
39
|
+django-cacheops # Caching ORM QuerySets
|