Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft-Responders #30

Merged
merged 6 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/goal3/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@
'rest_framework',
'bootstrap4',
'bootstrap_datepicker_plus',
'tz_detect',
]

# Creating Bootstrap4 block and turning jquery to true
BOOTSTRAP4 = {
'include_jquery': True,
}

import django

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
Expand All @@ -63,6 +66,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'tz_detect.middleware.TimezoneMiddleware',
]

ROOT_URLCONF = 'goal3.urls'
Expand Down
4 changes: 3 additions & 1 deletion src/goal3/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import path, re_path, include

urlpatterns = [
path('', include('usersapp.urls')),
path('admin/', admin.site.urls),
#using 're-path' instead of 'url'
re_path(r'^tz_detect/', include('tz_detect.urls')),
]
Binary file modified src/requirements.txt
Binary file not shown.
37 changes: 20 additions & 17 deletions src/templates/incident_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
{% bootstrap_javascript jquery='full' %} {# Embed Bootstrap JS+jQuery #}


<div class="container">
<h1>Accident Form</h1>
<p>It is our collective responsibility to report an accident. By reporting accidents, relevant agencies monitor problems and identify their root causes. Reporting road accidents enable actions to be taken to reduce future ocurrences, and at LifeShield it takes about 5 minutes to report an accident.</p>
<form action="{% url 'incident_create' %}"
method="post">
{% csrf_token %}
{% bootstrap_form form %}
{{ form.media }} {# Adds date-picker required JS and CSS #}
{% buttons %}
<button type="submit" class="btn btn-primary">Submit</button>
{% endbuttons %}
</form>
<div class="container-fluid">
<div class="container">
<h1>Accident Form</h1>
<p>It is our collective responsibility to report an accident. By reporting accidents, relevant agencies monitor problems and identify their root causes. Reporting road accidents enable actions to be taken to reduce future ocurrences, and at LifeShield it takes less than 5 minutes to report an accident.</p>
<form action="{% url 'incident_create' %}"
method="post">
{% csrf_token %}
{% bootstrap_form form %}
{{ form.media }} {# Adds date-picker required JS and CSS #}
{% buttons %}
<button type="submit" class="btn btn-primary">Submit</button>
{% endbuttons %}
</form>

<div>
{% for message in messages %}
<h3> {{message}}</h3>
{% endfor %}
</div>
<div>
{% for message in messages %}
<h3> {{message}}</h3>
{% endfor %}

</div>
</div>
<div>
98 changes: 98 additions & 0 deletions src/templates/responder.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}

td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}

tr:nth-child(even) {
background-color: #dddddd;
}
</style>

<body>

<h2>Accident Information</h2>

<table>
<tr>
<th>Accident location</th>
<th>Nearest Landmark</th>
<th>Date of Accident</th>
<th>Time of Accident</th>
<th>Number of vehicles Involved</th>
<th>Vehicle type</th>
<th>Other vehicle (if any)</th>
<th>Vehicles Number Plates</th>
<th>Vehicles precrash factors</th>
<th>Number of damaged vehicles</th>
<th>Road Geometry</th>
<th>Road type</th>
<th>Drivers Precrash factors</th>
<th>Collision type</th>
<th>Number of victims</th>
<th>Number of injured </th>
<th>Number of deaths</th>
<th>Category of victims</th>
<th>Victims age group</th>
<th>Number of male victims</th>
<th>Number of female victims</th>
<th>Number of child victims</th>
<th>Victims current location</th>
<th>Hospital Location</th>
<th>Other Location (if any)</th>
<th>More accident info</th>
</tr>
{% for item in detail %}
<tr>
<td>{{item.accident_location}}</td>
<td>{{item.nearest_landmark}}</td>
<td>{{item.date_of_accident|date:"Y-m-d"}}</td>
<td>{{item.time_of_accident}}</td>

<td>{{vehicles_involved}}</td>
<td>{{item.vehicle_type}}</td>
<td>{{item.other_vehicle_type}}</td>
<td>{{item.vehicles_number_plates}}</td>
<td>{{item.vehicles_precrash_factors}}</td>
<td>{{item.number_of_damaged_vehicles}}</td>
<td>{{item.road_geometry}}</td>
<td>{{item.road_type}}</td>
<td>{{item.drivers_precrash_factors}}</td>
<td>{{item.collision_type}}</td>
<td>{{item.number_of_victims}}</td>
<td>{{item.number_of_injured}}</td>
<td>{{item.number_of_deaths}}</td>
<td>{{item.category_of_victims}}</td>
<td>{{item.victims_age_group}}</td>
<td>{{item.number_of_male_victims}}</td>
<td>{{item.number_of_female_victims}}</td>
<td>{{item.number_of_child_victims}}</td>
<td>{{item.victims_current_location}}</td>
<td>{{hospital_location}}</td>
<td>{{item.other_location}}</td>
<td>{{item.more_accident_info}}</td>
</tr>
{% endfor %}

</table>

{% load tz_detect %}
{% tz_detect %}

</body>
</html>
84 changes: 84 additions & 0 deletions src/templates/search_responses.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{% load bootstrap4 %} {# import bootstrap4 #}
{% bootstrap_css %} {# Embed Bootstrap CSS #}
{% bootstrap_javascript jquery='full' %} {# Embed Bootstrap JS+jQuery #}


<div class="container-fluid">
<div class="container">
<h1>Accident Search</h1>
<form method="GET">
{% bootstrap_form filter.form %}
{{ form.media }} {# Adds date-picker required JS and CSS #}
{% buttons %}
<button type="submit" class="btn btn-primary">Search</button>
<a class="btn btn-warning" href="{% url 'search_responses' %}">Reset</a>
{% endbuttons %}
</form>
<table class="table table-bordered table-hover table-condensed">
<thead>
<tr>
<th>Accident location</th>
<th>Nearest Landmark</th>
<th>Date of Accident</th>
<th>Time of Accident</th>
<th>Number of vehicles Involved</th>
<th>Vehicle type</th>
<th>Other vehicle (if any)</th>
<th>Vehicles Number Plates</th>
<th>Vehicles precrash factors</th>
<th>Number of damaged vehicles</th>
<th>Road Geometry</th>
<th>Road type</th>
<th>Drivers Precrash factors</th>
<th>Collision type</th>
<th>Number of victims</th>
<th>Number of injured </th>
<th>Number of deaths</th>
<th>Category of victims</th>
<th>Victims age group</th>
<th>Number of male victims</th>
<th>Number of female victims</th>
<th>Number of child victims</th>
<th>Victims current location</th>
<th>Hospital Location</th>
<th>Other Location (if any)</th>
<th>More accident info</th>
</tr>
</thead>
{% for item in filter.qs %}
<tbody>>
<tr>
<td>{{item.accident_location}}</td>
<td>{{item.nearest_landmark}}</td>
<td>{{item.date_of_accident|date:"Y-m-d"}}</td>
<td>{{item.time_of_accident}}</td>
<td>{{vehicles_involved}}</td>
<td>{{item.vehicle_type}}</td>
<td>{{item.other_vehicle_type}}</td>
<td>{{item.vehicles_number_plates}}</td>
<td>{{item.vehicles_precrash_factors}}</td>
<td>{{item.number_of_damaged_vehicles}}</td>
<td>{{item.road_geometry}}</td>
<td>{{item.road_type}}</td>
<td>{{item.drivers_precrash_factors}}</td>
<td>{{item.collision_type}}</td>
<td>{{item.number_of_victims}}</td>
<td>{{item.number_of_injured}}</td>
<td>{{item.number_of_deaths}}</td>
<td>{{item.category_of_victims}}</td>
<td>{{item.victims_age_group}}</td>
<td>{{item.number_of_male_victims}}</td>
<td>{{item.number_of_female_victims}}</td>
<td>{{item.number_of_child_victims}}</td>
<td>{{item.victims_current_location}}</td>
<td>{{hospital_location}}</td>
<td>{{item.other_location}}</td>
<td>{{item.more_accident_info}}</td>
</tr>
</tbody>
{% endfor %}
</table>
</div>
</div>
{% load tz_detect %}
{% tz_detect %}
23 changes: 23 additions & 0 deletions src/usersapp/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from .models import Incident
from django import forms
import django_filters

'''
class ResponsesFilter(django_filters.FilterSet):
class Meta:
model = Incident
fields = ['accident_location', 'local_government_area', 'date_of_accident', 'time_of_accident', 'number_of_vehicles_involved', 'vehicle_type', 'vehicles_number_plates', 'vehicles_precrash_factors', 'road_geometry', 'road_type', 'driver_precrash_factors', 'collision_type', 'number_of_victims', 'number_of_injured', 'number_of_deaths', 'category_of_victims', 'victims_age_group', 'number_of_male_victims', 'number_of_female_victims', 'number_of_child_victims', 'victims_current_location']
'''

class ResponsesFilter(django_filters.FilterSet):
month_of_accident = django_filters.NumberFilter(field_name='date_of_accident', lookup_expr='month')
month_of_accident_gte = django_filters.NumberFilter(field_name='date_of_accident', lookup_expr='month__gte')
month_of_accident_lte = django_filters.NumberFilter(field_name='date_of_accident', lookup_expr='month__lte')
year_of_accident = django_filters.NumberFilter(field_name='date_of_accident', lookup_expr='year')
year_of_accident_gte = django_filters.NumberFilter(field_name='date_of_accident', lookup_expr='year__gte')
year_of_accident_lte = django_filters.NumberFilter(field_name='date_of_accident', lookup_expr='year__lte')
#vehicles_precrash_factors = django_filters.CharFilter(lookup_expr='icontains')
class Meta:
model = Incident
#fields = ['accident_location', 'vehicles_precrash_factors', 'road_geometry', 'road_type', 'driver_precrash_factors', 'collision_type', 'victims_current_location']
fields = ['accident_location']
2 changes: 1 addition & 1 deletion src/usersapp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class IncidentForm(ModelForm):
class Meta:
model = Incident
fields = ['accident_location', 'nearest_landmark', 'date_of_accident', 'time_of_accident', 'number_of_vehicles_involved', 'vehicle_type', 'if_other_vehicle_specify', 'vehicles_number_plates', 'vehicle_precrash_factors', 'number_of_damaged_vehicles', 'road_geometry', 'road_type', 'driver_precrash_factors', 'collision_type', 'number_of_victims', 'number_of_injured', 'number_of_deaths', 'category_of_victims', 'victims_age_group', 'number_of_male_victims', 'number_of_female_victims', 'number_of_child_victims', 'victims_current_location', 'if_hospital_specify', 'if_other_location_specify', 'more_accident_info']
fields = ['accident_location', 'local_government_area', 'nearest_landmark', 'date_of_accident', 'time_of_accident', 'number_of_vehicles_involved', 'vehicle_type', 'if_other_vehicle_specify', 'vehicles_number_plates', 'vehicles_precrash_factors', 'road_geometry', 'road_type', 'driver_precrash_factors', 'collision_type', 'number_of_victims', 'number_of_injured', 'number_of_deaths', 'category_of_victims', 'victims_age_group', 'number_of_male_victims', 'number_of_female_victims', 'number_of_child_victims', 'victims_current_location', 'if_hospital_specify', 'if_other_location_specify', 'more_accident_info']
widgets = {
'date_of_accident': DatePickerInput(), # default date-format %m/%d/%Y will be used
# 'end_date': DatePickerInput(format='%Y-%m-%d'), # specify date-frmat
Expand Down
33 changes: 33 additions & 0 deletions src/usersapp/migrations/0008_auto_20200603_1618.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.0.6 on 2020-06-03 15:18

from django.db import migrations, models
import multiselectfield.db.fields


class Migration(migrations.Migration):

dependencies = [
('usersapp', '0007_auto_20200601_2102'),
]

operations = [
migrations.RemoveField(
model_name='incident',
name='vehicles_number_plates',
),
migrations.AddField(
model_name='incident',
name='vehicle_number_plate',
field=models.CharField(blank=True, help_text='You can add more than one vehicle number plate seperated by a comma.', max_length=100, null=True),
),
migrations.AlterField(
model_name='incident',
name='accident_location',
field=models.CharField(choices=[('FCT', 'FCT'), ('Abia', 'Abia'), ('Adamawa', 'Adamawa'), ('Akwa Ibom', 'Akwa Ibom'), ('Anambra', 'Anambra'), ('Bauchi', 'Bauchi'), ('Bayelsa', 'Bayelsa'), ('Benue', 'Benue'), ('Borno', 'Borno'), ('Cross River', 'Cross River'), ('Delta', 'Delta'), ('Ebonyi', 'Ebonyi'), ('Enugu', 'Enugu'), ('Edo', 'Edo'), ('Ekiti', 'Ekiti'), ('Gombe', 'Gombe'), ('Imo', 'Imo'), ('Jigawa', 'Jigawa'), ('Kaduna', 'Kaduna'), ('Kano', 'Kano'), ('Katsina', 'Katsina'), ('Kebbi', 'Kebbi'), ('Kogi', 'Kogi'), ('Kwara', 'Kwara'), ('Lagos', 'Lagos'), ('Nasarawa', 'Nasarawa'), ('Niger', 'Niger'), ('Ogun', 'Ogun'), ('Ondo', 'Ondo'), ('Osun', 'Osun'), ('Oyo', 'Oyo'), ('Plateau', 'Plateau'), ('Rivers', 'Rivers'), ('Sokoto', 'Sokoto'), ('Taraba', 'Taraba'), ('Yobe', 'Yobe'), ('Zamfara', 'Zamfara')], max_length=45),
),
migrations.AlterField(
model_name='incident',
name='vehicle_type',
field=multiselectfield.db.fields.MultiSelectField(choices=[('Car saloon', 'Car saloon'), ('Microbus', 'Microbus (< 10 seater)'), ('Minibus', 'Minibus (< 15 seater)'), ('Coaster', 'Coaster (< 15 > 35 seater)'), ('Bus', 'Bus (> 35 seater)'), ('Pickup', 'Pickup'), ('SUV', 'SUV (Jeep)'), ('Light lorry', 'Light lorry (< 3.5 t)'), ('Heavy lorry', 'Heavy lorry (> 3.5 t)'), ('Tanker', 'Tanker'), ('Trailer', 'Trailer'), ('Motorcycle', 'Motorcycle'), ('Tricycle', 'Tricycle'), ('Bicycle', 'Bicycle'), ('Unknown', 'Unknown'), ('Other', 'Other')], max_length=50),
),
]
23 changes: 23 additions & 0 deletions src/usersapp/migrations/0009_auto_20200603_1623.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.0.6 on 2020-06-03 15:23

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('usersapp', '0008_auto_20200603_1618'),
]

operations = [
migrations.RenameField(
model_name='incident',
old_name='vehicle_number_plate',
new_name='vehicles_number_plates',
),
migrations.RenameField(
model_name='incident',
old_name='vehicle_precrash_factors',
new_name='vehicles_precrash_factors',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.0.6 on 2020-06-07 11:52

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('usersapp', '0009_auto_20200603_1623'),
]

operations = [
migrations.RemoveField(
model_name='incident',
name='number_of_damaged_vehicles',
),
]
Loading