-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3f4ce0
commit 3ea1b0a
Showing
62 changed files
with
376 additions
and
66 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.contrib import admin | ||
from .models import Vehicle | ||
from import_export.admin import ImportExportModelAdmin | ||
|
||
class VehicleAdmin(ImportExportModelAdmin): | ||
list_display = ('id', 'type', 'make', 'model', 'serial_number', 'condition', 'location', 'purchase_date', 'last_service_date', 'next_service_due') | ||
list_filter = ('type', 'condition', 'location') | ||
search_fields = ('make', 'model', 'serial_number') | ||
ordering = ('type', 'make', 'model') | ||
readonly_fields = ('purchase_date', 'last_service_date', 'next_service_due') # Optional: Set fields to read-only if needed | ||
|
||
def get_readonly_fields(self, request, obj=None): | ||
if obj: | ||
return self.readonly_fields + ('type',) | ||
return self.readonly_fields | ||
|
||
admin.site.register(Vehicle, VehicleAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class MachineryConfig(AppConfig): | ||
class assets_manageConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'machinery' | ||
name = 'assets_manage' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django import forms | ||
from .models import Vehicle | ||
|
||
class VehicleForm(forms.ModelForm): | ||
class Meta: | ||
model = Vehicle | ||
fields = '__all__' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 5.0.7 on 2024-07-26 19:34 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Vehicle', | ||
fields=[ | ||
('id', models.AutoField(primary_key=True, serialize=False)), | ||
('type', models.CharField(choices=[('Excavator', 'Excavator'), ('Bulldozer', 'Bulldozer'), ('Garbage Truck', 'Garbage Truck'), ('Bus', 'Bus')], max_length=50)), | ||
('make', models.CharField(max_length=100)), | ||
('model', models.CharField(max_length=100)), | ||
('serial_number', models.CharField(max_length=100, unique=True)), | ||
('condition', models.CharField(max_length=50)), | ||
('location', models.CharField(max_length=100)), | ||
('purchase_date', models.DateField()), | ||
('last_service_date', models.DateField()), | ||
('next_service_due', models.DateField()), | ||
], | ||
), | ||
] |
File renamed without changes.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.db import models | ||
|
||
class Vehicle(models.Model): | ||
VEHICLE_TYPES = [ | ||
('Excavator', 'Excavator'), | ||
('Bulldozer', 'Bulldozer'), | ||
('Garbage Truck', 'Garbage Truck'), | ||
('Bus', 'Bus'), | ||
# Add more vehicle types as needed | ||
] | ||
|
||
id = models.AutoField(primary_key=True) | ||
type = models.CharField(max_length=50, choices=VEHICLE_TYPES) | ||
make = models.CharField(max_length=100) | ||
model = models.CharField(max_length=100) | ||
serial_number = models.CharField(max_length=100, unique=True) | ||
condition = models.CharField(max_length=50) | ||
location = models.CharField(max_length=100) | ||
purchase_date = models.DateField() | ||
last_service_date = models.DateField() | ||
next_service_due = models.DateField() | ||
|
||
def __str__(self): | ||
return f"{self.make} {self.model} ({self.type})" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.container { | ||
width: 80%; | ||
margin: 20px auto; | ||
padding: 20px; | ||
background: #fff; | ||
border-radius: 8px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
color: #333; | ||
} | ||
|
||
table { | ||
width: 100%; | ||
border-collapse: collapse; | ||
margin-top: 20px; | ||
} | ||
|
||
thead { | ||
background-color: #007bff; | ||
color: #fff; | ||
} | ||
|
||
th, td { | ||
padding: 10px; | ||
text-align: left; | ||
border: 1px solid #ddd; | ||
} | ||
|
||
th { | ||
font-weight: bold; | ||
} | ||
|
||
tr:nth-child(even) { | ||
background-color: #f9f9f9; | ||
} | ||
|
||
tr:hover { | ||
background-color: #e9ecef; | ||
} | ||
|
||
form { | ||
margin-top: 20px; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
assets_manage/templates/assets_manage/app/assets_manage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends 'assets_manage/partial/base.html' %} | ||
{% load static %} | ||
|
||
{% block index %} | ||
|
||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="vehicals"> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
{% endblock index %} |
53 changes: 53 additions & 0 deletions
53
assets_manage/templates/assets_manage/app/vehicle_detail.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{% extends 'assets_manage/partial/base.html' %} | ||
{% load static %} | ||
|
||
{% block index %} | ||
|
||
<div class="container"> | ||
<h1>Vehicle Detail</h1> | ||
<table> | ||
<tr> | ||
<th>ID</th> | ||
<td>{{ vehicle.id }}</td> | ||
</tr> | ||
<tr> | ||
<th>Type</th> | ||
<td>{{ vehicle.type }}</td> | ||
</tr> | ||
<tr> | ||
<th>Make</th> | ||
<td>{{ vehicle.make }}</td> | ||
</tr> | ||
<tr> | ||
<th>Model</th> | ||
<td>{{ vehicle.model }}</td> | ||
</tr> | ||
<tr> | ||
<th>Serial Number</th> | ||
<td>{{ vehicle.serial_number }}</td> | ||
</tr> | ||
<tr> | ||
<th>Condition</th> | ||
<td>{{ vehicle.condition }}</td> | ||
</tr> | ||
<tr> | ||
<th>Location</th> | ||
<td>{{ vehicle.location }}</td> | ||
</tr> | ||
<tr> | ||
<th>Purchase Date</th> | ||
<td>{{ vehicle.purchase_date }}</td> | ||
</tr> | ||
<tr> | ||
<th>Last Service Date</th> | ||
<td>{{ vehicle.last_service_date }}</td> | ||
</tr> | ||
<tr> | ||
<th>Next Service Due</th> | ||
<td>{{ vehicle.next_service_due }}</td> | ||
</tr> | ||
</table> | ||
<a href="{% url 'assets_manage:vehicle_list' %}">Back to List</a> | ||
</div> | ||
|
||
{% endblock index %} |
17 changes: 17 additions & 0 deletions
17
assets_manage/templates/assets_manage/app/vehicle_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% extends 'assets_manage/partial/base.html' %} | ||
{% load static %} | ||
|
||
{% block index %} | ||
|
||
|
||
<div class="container"> | ||
<h1>Add New Vehicle</h1> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<button type="submit">Save</button> | ||
</form> | ||
<a href="{% url 'assets_manage:vehicle_list' %}">Back to List</a> | ||
</div> | ||
|
||
{% endblock index %} |
39 changes: 39 additions & 0 deletions
39
assets_manage/templates/assets_manage/app/vehicle_list.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{% extends 'assets_manage/partial/base.html' %} | ||
{% load static %} | ||
|
||
{% block index %} | ||
|
||
<div class="container"> | ||
<h1>Vehicle Inventory</h1> | ||
<a href="{% url 'assets_manage:vehicle_add' %}">Add New Vehicle</a> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Type</th> | ||
<th>Make</th> | ||
<th>Model</th> | ||
<th>Serial Number</th> | ||
<th>Condition</th> | ||
<th>Location</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for vehicle in vehicles %} | ||
<tr> | ||
<td>{{ vehicle.id }}</td> | ||
<td>{{ vehicle.type }}</td> | ||
<td>{{ vehicle.make }}</td> | ||
<td>{{ vehicle.model }}</td> | ||
<td>{{ vehicle.serial_number }}</td> | ||
<td>{{ vehicle.condition }}</td> | ||
<td>{{ vehicle.location }}</td> | ||
<td><a href="{% url 'assets_manage:vehicle_detail' vehicle.id %}">View</a></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
{% endblock index %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% load static %} | ||
<!-- assets_manage js --> | ||
<script src="{% static 'assets_manage/js/assets_manage.js' %}"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% load static %} | ||
<!-- assets_manage css --> | ||
<link rel="stylesheet" href="{% static 'assets_manage/css/assets_manage.css' %}"> | ||
<link rel="stylesheet" href="{% static 'assets_manage/css/inventory.css' %}"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.urls import path | ||
from assets_manage import views | ||
|
||
app_name='assets_manage' | ||
|
||
urlpatterns=[ | ||
path('',views.assets_manage,name='assets_manage'), | ||
path('vehicle/', views.vehicle_list, name='vehicle_list'), | ||
path('vehicle/<int:pk>/', views.vehicle_detail, name='vehicle_detail'), | ||
path('vehicle/add/', views.vehicle_add, name='vehicle_add'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.shortcuts import render | ||
from django.shortcuts import render, get_object_or_404, redirect | ||
from .models import Vehicle | ||
from .forms import VehicleForm | ||
|
||
|
||
def assets_manage(request): | ||
context={ | ||
|
||
} | ||
return render(request,'assets_manage/app/assets_manage.html',context) | ||
|
||
def vehicle_list(request): | ||
vehicles = Vehicle.objects.all() | ||
return render(request, 'assets_manage/app/vehicle_list.html', {'vehicles': vehicles}) | ||
|
||
def vehicle_detail(request, pk): | ||
vehicle = get_object_or_404(Vehicle, pk=pk) | ||
return render(request, 'assets_manage/app/vehicle_detail.html', {'vehicle': vehicle}) | ||
|
||
def vehicle_add(request): | ||
if request.method == 'POST': | ||
form = VehicleForm(request.POST) | ||
if form.is_valid(): | ||
form.save() | ||
return redirect('vehicle_list') | ||
else: | ||
form = VehicleForm() | ||
return render(request, 'assets_manage/app/vehicle_form.html', {'form': form}) |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.