Autosave: 20260322-221210

This commit is contained in:
Flatlogic Bot 2026-03-22 22:12:10 +00:00
parent 9a8ca32792
commit d1c0cd3fee
6 changed files with 79 additions and 3 deletions

View File

@ -0,0 +1,20 @@
{% extends "base.html" %}
{% block title %}Dashboard | {{ project_name }}{% endblock %}
{% block content %}
<div class="container mt-5">
<div class="row">
<div class="col-md-12">
<h1 class="mb-4">System Dashboard</h1>
<div class="card">
<div class="card-body">
<h5 class="card-title">Welcome to the Management System</h5>
<p class="card-text">You are logged in as <strong>{{ user.username }}</strong>.</p>
<a href="{% url 'logout' %}" class="btn btn-danger">Logout</a>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,32 @@
{% extends "base.html" %}
{% block title %}Login | {{ project_name }}{% endblock %}
{% block content %}
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h2 class="card-title text-center mb-4">Login</h2>
{% if form.errors %}
<div class="alert alert-danger">Invalid username or password.</div>
{% endif %}
<form method="post">
{% csrf_token %}
<div class="mb-3">
<label for="id_username" class="form-label">Username</label>
<input type="text" name="username" class="form-control" id="id_username" required>
</div>
<div class="mb-3">
<label for="id_password" class="form-label">Password</label>
<input type="password" name="password" class="form-control" id="id_password" required>
</div>
<button type="submit" class="btn btn-primary w-100">Login</button>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,6 +1,7 @@
from django.urls import path from django.urls import path
from django.contrib.auth import views as auth_views
from .views import home, ingest_data, resolve_entities from .views import home, ingest_data, resolve_entities, login_view, dashboard_view, logout_view
app_name = 'core' app_name = 'core'
@ -8,4 +9,7 @@ urlpatterns = [
path("", home, name="home"), path("", home, name="home"),
path("api/ingest/", ingest_data, name="ingest_data"), path("api/ingest/", ingest_data, name="ingest_data"),
path("api/resolve/", resolve_entities, name="resolve_entities"), path("api/resolve/", resolve_entities, name="resolve_entities"),
path("login/", login_view, name="login"),
path("dashboard/", dashboard_view, name="dashboard"),
path("logout/", logout_view, name="logout"),
] ]

View File

@ -3,7 +3,9 @@ from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from core.services.ingestion import IngestionService from core.services.ingestion import IngestionService
from core.services.resolution import EntityResolutionService from core.services.resolution import EntityResolutionService
from django.shortcuts import render from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.utils import timezone from django.utils import timezone
import os import os
import platform import platform
@ -27,6 +29,24 @@ def home(request):
} }
return render(request, "core/index.html", context) return render(request, "core/index.html", context)
def login_view(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('dashboard')
return render(request, 'core/login.html')
@login_required
def dashboard_view(request):
return render(request, 'core/dashboard.html', {'project_name': 'New Style'})
def logout_view(request):
logout(request)
return redirect('home')
@csrf_exempt @csrf_exempt
def ingest_data(request): def ingest_data(request):
if request.method == 'POST': if request.method == 'POST':
@ -43,4 +63,4 @@ def resolve_entities(request):
# Using EntityResolutionService as a placeholder for actual processing # Using EntityResolutionService as a placeholder for actual processing
result = EntityResolutionService.resolve(data) result = EntityResolutionService.resolve(data)
return JsonResponse({'status': 'success', 'result': result}) return JsonResponse({'status': 'success', 'result': result})
return JsonResponse({'error': 'Invalid request'}, status=400) return JsonResponse({'error': 'Invalid request'}, status=400)