diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index d63d93a..4c2eae5 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 8886bf8..55d10a6 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/templates/core/dashboard.html b/core/templates/core/dashboard.html new file mode 100644 index 0000000..c6ef6fc --- /dev/null +++ b/core/templates/core/dashboard.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} + +{% block title %}Dashboard | {{ project_name }}{% endblock %} + +{% block content %} +
+
+
+

System Dashboard

+
+
+
Welcome to the Management System
+

You are logged in as {{ user.username }}.

+ Logout +
+
+
+
+
+{% endblock %} diff --git a/core/templates/core/login.html b/core/templates/core/login.html new file mode 100644 index 0000000..5d1bf7b --- /dev/null +++ b/core/templates/core/login.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} + +{% block title %}Login | {{ project_name }}{% endblock %} + +{% block content %} +
+
+
+
+
+

Login

+ {% if form.errors %} +
Invalid username or password.
+ {% endif %} +
+ {% csrf_token %} +
+ + +
+
+ + +
+ +
+
+
+
+
+
+{% endblock %} diff --git a/core/urls.py b/core/urls.py index 1facb35..dfbd8af 100644 --- a/core/urls.py +++ b/core/urls.py @@ -1,6 +1,7 @@ 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' @@ -8,4 +9,7 @@ urlpatterns = [ path("", home, name="home"), path("api/ingest/", ingest_data, name="ingest_data"), 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"), ] \ No newline at end of file diff --git a/core/views.py b/core/views.py index cfa6cf5..01c2908 100644 --- a/core/views.py +++ b/core/views.py @@ -3,7 +3,9 @@ from django.http import JsonResponse from django.views.decorators.csrf import csrf_exempt from core.services.ingestion import IngestionService 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 import os import platform @@ -27,6 +29,24 @@ def home(request): } 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 def ingest_data(request): if request.method == 'POST': @@ -43,4 +63,4 @@ def resolve_entities(request): # Using EntityResolutionService as a placeholder for actual processing result = EntityResolutionService.resolve(data) return JsonResponse({'status': 'success', 'result': result}) - return JsonResponse({'error': 'Invalid request'}, status=400) \ No newline at end of file + return JsonResponse({'error': 'Invalid request'}, status=400)