Skip to content

Commit

Permalink
added vehicle inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
anurag6569201 committed Jul 26, 2024
1 parent f3f4ce0 commit 3ea1b0a
Show file tree
Hide file tree
Showing 62 changed files with 376 additions and 66 deletions.
File renamed without changes.
Binary file added assets_manage/__pycache__/admin.cpython-312.pyc
Binary file not shown.
Binary file added assets_manage/__pycache__/apps.cpython-312.pyc
Binary file not shown.
Binary file added assets_manage/__pycache__/forms.cpython-312.pyc
Binary file not shown.
Binary file added assets_manage/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file added assets_manage/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file added assets_manage/__pycache__/views.cpython-312.pyc
Binary file not shown.
17 changes: 17 additions & 0 deletions assets_manage/admin.py
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)
4 changes: 2 additions & 2 deletions machinery/apps.py → assets_manage/apps.py
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'
7 changes: 7 additions & 0 deletions assets_manage/forms.py
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__'
29 changes: 29 additions & 0 deletions assets_manage/migrations/0001_initial.py
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.
24 changes: 24 additions & 0 deletions assets_manage/models.py
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})"
46 changes: 46 additions & 0 deletions assets_manage/static/assets_manage/css/inventory.css
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;
}
Binary file added assets_manage/static/assets_manage/image/jcv.png
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 assets_manage/templates/assets_manage/app/assets_manage.html
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 assets_manage/templates/assets_manage/app/vehicle_detail.html
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 assets_manage/templates/assets_manage/app/vehicle_form.html
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 assets_manage/templates/assets_manage/app/vehicle_list.html
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 %}
3 changes: 3 additions & 0 deletions assets_manage/templates/assets_manage/elements/script.html
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>
4 changes: 4 additions & 0 deletions assets_manage/templates/assets_manage/elements/style.html
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' %}">
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% load static %}

{% block appstyling %}
{% include 'machinery/elements/style.html' %}
{% include 'assets_manage/elements/style.html' %}
{% endblock appstyling %}

{% block mainapp %}
Expand All @@ -11,5 +11,5 @@
{% endblock mainapp %}

{% block appscripting %}
{% include 'machinery/elements/script.html' %}
{% include 'assets_manage/elements/script.html' %}
{% endblock appscripting %}
File renamed without changes.
11 changes: 11 additions & 0 deletions assets_manage/urls.py
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'),
]
29 changes: 29 additions & 0 deletions assets_manage/views.py
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 modified blinklog/__pycache__/settings.cpython-312.pyc
Binary file not shown.
Binary file modified blinklog/__pycache__/urls.cpython-312.pyc
Binary file not shown.
4 changes: 3 additions & 1 deletion blinklog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# Application definition

INSTALLED_APPS = [
'jazzmin',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand All @@ -40,11 +41,12 @@
'django.contrib.staticfiles',

# custom apps
'import_export',
'userauths',
'core',

# custom apps
'machinery',
'assets_manage',
]

MIDDLEWARE = [
Expand Down
2 changes: 1 addition & 1 deletion blinklog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
path('user/',include('userauths.urls')),

# custom apps
path('machinery/',include('machinery.urls')),
path('assets_manage/',include('assets_manage.urls')),
]

urlpatterns += static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
Expand Down
Loading

0 comments on commit 3ea1b0a

Please sign in to comment.