diff --git a/.env b/.env index 8dbdbea..e69de29 100644 --- a/.env +++ b/.env @@ -1,6 +0,0 @@ -GOOGLE_API_KEY=AIzaSyAh5HbTtCHsO_ZWAtCtn_q5h2_Jw7tEfe8 -HUGGING_FACE_API_KEY=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 - -SMS_ACCOUNT_SSID_API_KEY=AC954136eee66cc8ba187c7722f5840d13 -SMS_ACCOUNT_AUTH_API_KEY=d1501d7b07f1625cce8b4c46c1d5a8f1 -SMS_FROM_NUMBER=+12085516281 \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index f7866c4..3a963bb 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/data_level0.bin b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/data_level0.bin index e3147ce..204f597 100644 Binary files a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/data_level0.bin and b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/data_level0.bin differ diff --git a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/header.bin b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/header.bin index cf7ace5..45faeeb 100644 Binary files a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/header.bin and b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/header.bin differ diff --git a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/index_metadata.pickle b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/index_metadata.pickle index 3e879d2..4fda4d7 100644 Binary files a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/index_metadata.pickle and b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/index_metadata.pickle differ diff --git a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/length.bin b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/length.bin index 1dc89f8..807e222 100644 Binary files a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/length.bin and b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/length.bin differ diff --git a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/link_lists.bin b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/link_lists.bin index 981629d..1d0acf1 100644 Binary files a/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/link_lists.bin and b/db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/link_lists.bin differ diff --git a/db/chroma.sqlite3 b/db/chroma.sqlite3 index 2bb1dd4..49e4fc3 100644 Binary files a/db/chroma.sqlite3 and b/db/chroma.sqlite3 differ diff --git a/dummy.csv b/dummy.csv index b93e4a1..32d910f 100644 --- a/dummy.csv +++ b/dummy.csv @@ -1,51 +1,21 @@ -id,registration_number,type,available,condition,last_maintenance -1,MP01AB1234,Standard,True,Good,2024-06-15 -2,MP02CD5678,Advanced Life Support,True,Good,2024-07-01 -3,MP03EF9101,Standard,False,Needs Repair,2024-06-20 -4,MP04GH2345,Advanced Life Support,True,Good,2024-07-05 -5,MP05IJ6789,Standard,True,Good,2024-06-25 -6,MP06KL0123,Advanced Life Support,False,Needs Repair,2024-06-30 -7,MP07MN4567,Standard,True,Good,2024-07-01 -8,MP08OP8901,Advanced Life Support,True,Good,2024-07-10 -9,MP09QR2345,Standard,True,Needs Repair,2024-06-22 -10,MP10ST6789,Advanced Life Support,True,Good,2024-07-03 -11,MP11UV0123,Standard,False,Needs Repair,2024-06-28 -12,MP12WX4567,Advanced Life Support,True,Good,2024-07-12 -13,MP13YZ8901,Standard,True,Good,2024-07-08 -14,MP14AB2345,Advanced Life Support,True,Good,2024-07-04 -15,MP15CD6789,Standard,True,Needs Repair,2024-06-26 -16,MP16EF0123,Advanced Life Support,True,Good,2024-07-09 -17,MP17GH4567,Standard,False,Needs Repair,2024-07-02 -18,MP18IJ8901,Advanced Life Support,True,Good,2024-07-07 -19,MP19KL2345,Standard,True,Good,2024-06-29 -20,MP20MN6789,Advanced Life Support,True,Needs Repair,2024-07-11 -21,MP21OP0123,Standard,True,Good,2024-06-24 -22,MP22QR4567,Advanced Life Support,False,Needs Repair,2024-07-06 -23,MP23ST8901,Standard,True,Good,2024-07-02 -24,MP24UV2345,Advanced Life Support,True,Good,2024-07-08 -25,MP25WX6789,Standard,False,Needs Repair,2024-07-10 -26,MP26YZ0123,Advanced Life Support,True,Good,2024-07-12 -27,MP27AB4567,Standard,True,Good,2024-06-23 -28,MP28CD8901,Advanced Life Support,True,Needs Repair,2024-07-01 -29,MP29EF2345,Standard,True,Good,2024-07-05 -30,MP30GH6789,Advanced Life Support,True,Good,2024-07-07 -31,MP31IJ0123,Standard,False,Needs Repair,2024-07-03 -32,MP32KL4567,Advanced Life Support,True,Good,2024-07-09 -33,MP33MN8901,Standard,True,Good,2024-06-27 -34,MP34OP2345,Advanced Life Support,True,Needs Repair,2024-07-11 -35,MP35QR6789,Standard,True,Good,2024-06-28 -36,MP36ST0123,Advanced Life Support,False,Needs Repair,2024-07-12 -37,MP37UV4567,Standard,True,Good,2024-07-01 -38,MP38WX8901,Advanced Life Support,True,Good,2024-07-10 -39,MP39YZ2345,Standard,False,Needs Repair,2024-06-30 -40,MP40AB6789,Advanced Life Support,True,Good,2024-07-08 -41,MP41CD0123,Standard,True,Good,2024-07-05 -42,MP42EF4567,Advanced Life Support,False,Needs Repair,2024-07-01 -43,MP43GH8901,Standard,True,Good,2024-06-29 -44,MP44IJ2345,Advanced Life Support,True,Good,2024-07-11 -45,MP45KL6789,Standard,True,Needs Repair,2024-06-27 -46,MP46MN0123,Advanced Life Support,True,Good,2024-07-03 -47,MP47OP4567,Standard,False,Needs Repair,2024-06-25 -48,MP48QR8901,Advanced Life Support,True,Good,2024-07-12 -49,MP49ST2345,Standard,True,Good,2024-07-07 -50,MP50UV6789,Advanced Life Support,True,Needs Repair,2024-07-10 +id,machinery,hours_of_operation,description,status,due_date +1,Excavator,120,Routine maintenance check.,N,2024-07-28 01:37:17 +2,Bulldozer,350,Oil change and filter replacement.,g,2024-07-29 10:15:00 +3,Crane,5000,Complete overhaul.,N,2024-07-30 09:00:00 +4,Loader,450,General maintenance.,g,2024-08-01 11:30:00 +5,Dump Truck,1500,Brake inspection.,N,2024-08-03 14:20:00 +6,Excavator,200,Hydraulic system check.,g,2024-08-05 13:25:00 +7,Bulldozer,300,Engine tune-up.,N,2024-08-07 08:10:00 +8,Crane,4200,Structural inspection.,g,2024-08-09 16:00:00 +9,Loader,800,Transmission service.,N,2024-08-12 10:40:00 +10,Dump Truck,2200,Exhaust system repair.,g,2024-08-15 12:00:00 +11,Excavator,250,Undercarriage inspection.,N,2024-08-17 09:50:00 +12,Bulldozer,350,Filter change.,g,2024-08-20 15:00:00 +13,Crane,4800,Electrical system check.,N,2024-08-22 14:10:00 +14,Loader,600,Coolant system service.,g,2024-08-25 11:30:00 +15,Dump Truck,1800,Tire replacement.,N,2024-08-28 08:00:00 +16,Excavator,300,Engine repair.,g,2024-08-30 10:15:00 +17,Bulldozer,400,Hydraulic fluid change.,N,2024-09-02 13:00:00 +18,Crane,4900,Maintenance and calibration.,g,2024-09-05 12:30:00 +19,Loader,700,General inspection.,N,2024-09-08 15:00:00 +20,Dump Truck,1600,Brake system check.,g,2024-09-10 09:45:00 diff --git a/maintain/__pycache__/admin.cpython-312.pyc b/maintain/__pycache__/admin.cpython-312.pyc index 37c99dd..3e288ba 100644 Binary files a/maintain/__pycache__/admin.cpython-312.pyc and b/maintain/__pycache__/admin.cpython-312.pyc differ diff --git a/maintain/__pycache__/models.cpython-312.pyc b/maintain/__pycache__/models.cpython-312.pyc index 5c09249..cd24375 100644 Binary files a/maintain/__pycache__/models.cpython-312.pyc and b/maintain/__pycache__/models.cpython-312.pyc differ diff --git a/maintain/__pycache__/sms_utility.cpython-312.pyc b/maintain/__pycache__/sms_utility.cpython-312.pyc new file mode 100644 index 0000000..793898c Binary files /dev/null and b/maintain/__pycache__/sms_utility.cpython-312.pyc differ diff --git a/maintain/__pycache__/urls.cpython-312.pyc b/maintain/__pycache__/urls.cpython-312.pyc index a8b48ce..4ba7d22 100644 Binary files a/maintain/__pycache__/urls.cpython-312.pyc and b/maintain/__pycache__/urls.cpython-312.pyc differ diff --git a/maintain/__pycache__/views.cpython-312.pyc b/maintain/__pycache__/views.cpython-312.pyc index 5d4b139..938c5a7 100644 Binary files a/maintain/__pycache__/views.cpython-312.pyc and b/maintain/__pycache__/views.cpython-312.pyc differ diff --git a/maintain/admin.py b/maintain/admin.py index 8c38f3f..a8d811e 100644 --- a/maintain/admin.py +++ b/maintain/admin.py @@ -1,3 +1,9 @@ from django.contrib import admin +from .models import MaintenanceTask -# Register your models here. +from import_export.admin import ImportExportModelAdmin + + +class MaintenanceTaskAdmin(ImportExportModelAdmin): + list_display=['machinery','hours_of_operation','status'] +admin.site.register(MaintenanceTask,MaintenanceTaskAdmin) \ No newline at end of file diff --git a/maintain/migrations/0001_initial.py b/maintain/migrations/0001_initial.py new file mode 100644 index 0000000..99cd7fa --- /dev/null +++ b/maintain/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 5.0.7 on 2024-07-28 01:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='MaintenanceTask', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('machinery', models.CharField(max_length=100)), + ('hours_of_operation', models.IntegerField()), + ('description', models.TextField()), + ('status', models.CharField(max_length=1)), + ('due_date', models.DateTimeField()), + ], + ), + ] diff --git a/maintain/migrations/__pycache__/0001_initial.cpython-312.pyc b/maintain/migrations/__pycache__/0001_initial.cpython-312.pyc new file mode 100644 index 0000000..1257dbd Binary files /dev/null and b/maintain/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/maintain/models.py b/maintain/models.py index 71a8362..5083043 100644 --- a/maintain/models.py +++ b/maintain/models.py @@ -1,3 +1,13 @@ from django.db import models +from django.utils import timezone -# Create your models here. +class MaintenanceTask(models.Model): + machinery = models.CharField(max_length=100) + hours_of_operation = models.IntegerField() + description = models.TextField() + status = models.CharField(max_length=1) + due_date = models.DateTimeField() + + def should_send_alert(self): + return self.due_date.date() == timezone.now().date() + \ No newline at end of file diff --git a/maintain/sms_utility.py b/maintain/sms_utility.py new file mode 100644 index 0000000..8b26cfb --- /dev/null +++ b/maintain/sms_utility.py @@ -0,0 +1,18 @@ +from twilio.rest import Client +import os +from dotenv import load_dotenv +load_dotenv() +def send_sms_alert(task): + account_sid = os.getenv('SMS_ACCOUNT_SSID_API_KEY') + auth_token = os.getenv('SMS_ACCOUNT_AUTH_API_KEY') + client = Client(account_sid, auth_token) + + message_body = f"Maintenance Alert: {task.machinery} requires attention. Task: {task.description}. Hours of Operation: {task.hours_of_operation}." + + message = client.messages.create( + body=message_body, + from_='+1234567890', + to='+0987654321' + ) + + return message.sid \ No newline at end of file diff --git a/maintain/static/maintain/css/maintain.css b/maintain/static/maintain/css/maintain.css index 25349f7..f6145aa 100644 --- a/maintain/static/maintain/css/maintain.css +++ b/maintain/static/maintain/css/maintain.css @@ -18,4 +18,60 @@ display: flex; justify-content: right; align-items: baseline; -} \ No newline at end of file +} + +/* timeline css */ +/* Add this to your CSS file */ +.timeline { + position: relative; + max-width: 1200px; + margin: 0 auto; + padding: 0 10px; +} + +.timeline-item { + position: relative; + margin: 20px 0; + padding: 20px; + background: #f9f9f9; + border-radius: 5px; +} + +.timeline-item::before { + content: ''; + position: absolute; + left: 15px; + top: 20px; + width: 10px; + height: 10px; + border-radius: 50%; + background: #3498db; +} + +.timeline-icon { + display: inline-block; + width: 40px; + height: 40px; + background: #3498db; + border-radius: 50%; + text-align: center; + line-height: 40px; + color: white; + margin-right: 15px; +} + +.timeline-content { + display: inline-block; + vertical-align: top; + max-width: calc(100% - 70px); +} + +.timeline-content h5 { + margin: 0; + font-size: 18px; + font-weight: bold; +} + +.timeline-content p { + margin: 5px 0; +} diff --git a/maintain/templates/maintain/app/activity.html b/maintain/templates/maintain/app/activity.html new file mode 100644 index 0000000..41d5554 --- /dev/null +++ b/maintain/templates/maintain/app/activity.html @@ -0,0 +1,53 @@ +{% extends 'maintain/partial/base.html' %} +{% load static %} +{% block index %} + +
+ +
+
+
+

Log Repair Activities

+

Track all repair activities including costs and downtime. Maintain records of repairs to monitor asset performance and costs.

+ + + + + + + + + + + + + + {% for repair in repair_activities %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
MachineryDateHours of OperationDescriptionStatus
{{ repair.machinery }}{{ repair.due_date }}{{ repair.hours_of_operation }}{{ repair.description }} + {% if repair.status == 'Completed' %} + Completed + {% elif repair.status == 'Pending' %} + Pending + {% else %} + Unknown + {% endif %} +
No repair activities logged.
+
+
+
+
+ +{% endblock index %} diff --git a/maintain/templates/maintain/app/maintain.html b/maintain/templates/maintain/app/maintain.html index 54ad0d6..95d9843 100644 --- a/maintain/templates/maintain/app/maintain.html +++ b/maintain/templates/maintain/app/maintain.html @@ -8,7 +8,7 @@

Automated Reminders

Set up automated reminders for routine maintenance tasks. Schedule periodic checks and alerts to ensure timely maintenance.

- View Reminders + View Reminders
@@ -23,7 +23,7 @@

Automated Reminders

Log Repair Activities

Track all repair activities including costs and downtime.Maintain records of repairs to monitor asset performance and costs.

- View Activities + View Activities
diff --git a/maintain/templates/maintain/app/remainder.html b/maintain/templates/maintain/app/remainder.html new file mode 100644 index 0000000..c0879eb --- /dev/null +++ b/maintain/templates/maintain/app/remainder.html @@ -0,0 +1,78 @@ +{% extends 'maintain/partial/base.html' %} +{% load static %} +{% block index %} + +
+
+
+

Today's Tasks

+ + + + + + + + + + + + {% for task in maintenance_tasks %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
MachineryHours of OperationDescriptionDue DateStatus
{{ task.machinery }}{{ task.hours_of_operation }}{{ task.description }}{{ task.due_date }} + {% if task.status == 'N' %} + Needs Attention + {% elif task.status == 'g' %} + Good Condition + {% endif %} +
No upcoming tasks.
+

Upcoming Maintenance Tasks

+ + + + + + + + + + + + {% for task in future_tasks %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
MachineryHours of OperationDescriptionDue DateStatus
{{ task.machinery }}{{ task.hours_of_operation }}{{ task.description }}{{ task.due_date }} + {% if task.status == 'N' %} + Needs Attention + {% elif task.status == 'g' %} + Good Condition + {% endif %} +
No upcoming tasks.
+
+
+
+ +{% endblock index %} \ No newline at end of file diff --git a/maintain/templates/maintain/app/repair.html b/maintain/templates/maintain/app/repair.html new file mode 100644 index 0000000..bd0fc65 --- /dev/null +++ b/maintain/templates/maintain/app/repair.html @@ -0,0 +1,44 @@ +{% extends 'maintain/partial/base.html' %} +{% load static %} +{% block index %} + +
+
+
+

Log Repair Activities

+ + + + + + + + + + + {% for repair in repair_activities %} + + + + + + + {% empty %} + + + + {% endfor %} + +
MachineryHours of OperationDescriptionRepair Status
{{ repair.machinery }}{{ repair.hours_of_operation }}{{ repair.description }} + {% if repair.status == 'Completed' %} + Completed + {% elif repair.status == 'Pending' %} + Pending + {% else %} + Unknown + {% endif %} +
No repair activities logged.
+
+
+
+{% endblock index %} \ No newline at end of file diff --git a/maintain/urls.py b/maintain/urls.py index 468e41c..762ce7a 100644 --- a/maintain/urls.py +++ b/maintain/urls.py @@ -5,4 +5,6 @@ urlpatterns=[ path('',views.maintain,name='maintain'), + path('remainder',views.remainder,name='remainder'), + path('repair',views.view_repair_activities,name='repair'), ] \ No newline at end of file diff --git a/maintain/views.py b/maintain/views.py index ff7cb53..253d8e3 100644 --- a/maintain/views.py +++ b/maintain/views.py @@ -1,7 +1,27 @@ +from django.utils import timezone from django.shortcuts import render +from .models import MaintenanceTask +from .sms_utility import send_sms_alert def maintain(request): context={ } return render(request,'maintain/app/maintain.html',context) + +def remainder(request): + maintenance_tasks = MaintenanceTask.objects.filter(due_date__lte=timezone.now()) + future_tasks = MaintenanceTask.objects.filter(due_date__gt=timezone.now()) + # for task in maintenance_tasks: + # if task.should_send_alert(): + # send_sms_alert(task) + + context={ + 'maintenance_tasks': maintenance_tasks, + 'future_tasks':future_tasks, + } + return render(request,'maintain/app/remainder.html',context) + +def view_repair_activities(request): + repair_activities = MaintenanceTask.objects.all().order_by('due_date') + return render(request, 'maintain/app/activity.html', {'repair_activities': repair_activities}) \ No newline at end of file