Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/NGO
Browse files Browse the repository at this point in the history
# Conflicts:
#	templates/home.html
  • Loading branch information
jishnu-krishna committed Aug 17, 2018
2 parents 0dfc33e + f6be415 commit b1a7800
Show file tree
Hide file tree
Showing 21 changed files with 305 additions and 73 deletions.
28 changes: 28 additions & 0 deletions mainapp/migrations/0034_auto_20180817_1206.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.1 on 2018-08-17 06:36

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0033_auto_20180817_1003'),
]

operations = [
migrations.AddField(
model_name='rescuecamp',
name='latlng',
field=models.CharField(blank=True, help_text="Comma separated latlng field. Leave blank if you don't know it", max_length=100, verbose_name='GPS Coordinates'),
),
migrations.AddField(
model_name='rescuecamp',
name='map_link',
field=models.CharField(blank=True, help_text='Copy and paste the full Google Maps link', max_length=250, null=True, verbose_name='Map link'),
),
migrations.AlterField(
model_name='person',
name='address',
field=models.TextField(blank=True, max_length=150, null=True, verbose_name='Address - വിലാസം'),
),
]
25 changes: 25 additions & 0 deletions mainapp/migrations/0034_auto_20180817_1337.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 2.1 on 2018-08-17 08:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0033_auto_20180817_1003'),
]

operations = [
migrations.AddField(
model_name='rescuecamp',
name='taluk',
field=models.CharField(default=' ', max_length=50, verbose_name='Taluk'),
preserve_default=False,
),
migrations.AddField(
model_name='rescuecamp',
name='village',
field=models.CharField(default=' ', max_length=50, verbose_name='Village'),
preserve_default=False,
),
]
10 changes: 6 additions & 4 deletions mainapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,14 @@ class RescueCamp(models.Model):
max_length=15,
choices=districts
)
taluk = models.CharField(max_length=50,verbose_name="Taluk")
village = models.CharField(max_length=50,verbose_name="Village")
contacts = models.TextField(verbose_name="Phone Numbers",blank=True,null=True)
data_entry_user = models.ForeignKey(User,models.SET_NULL,blank=True,null=True)
map_link = models.CharField(max_length=250, verbose_name='Map link',blank=True,null=True,help_text="Copy and paste the full Google Maps link")
latlng = models.CharField(max_length=100, verbose_name='GPS Coordinates', blank=True,help_text="Comma separated latlng field. Leave blank if you don't know it")
class Meta:
verbose_name = 'Relief Camp'
verbose_name = 'Relief Camp'
def __str__(self):
return self.name

Expand All @@ -233,7 +237,7 @@ class Person(models.Model):
verbose_name='Gender - ലിംഗം',
null=True,blank=True
)
address = models.CharField(max_length=150,null=True,blank=True,verbose_name="Address - വിലാസം")
address = models.TextField(max_length=150,null=True,blank=True,verbose_name="Address - വിലാസം")
district = models.CharField(
max_length = 15,
choices = districts,
Expand All @@ -245,5 +249,3 @@ class Person(models.Model):
added_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.name


6 changes: 6 additions & 0 deletions mainapp/templates/mainapp/add_person.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ <h3>{{ message }}</h3>
</p>
</form>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$('#id_gender_0').parents('.radio').hide();
$('#id_gender > .radio').removeClass('radio').addClass('radio-inline');
</script>

{% endblock %}
6 changes: 3 additions & 3 deletions mainapp/templates/mainapp/districtmanager_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<div class="table-responsive">
<table class="table">
<tr>
<th>Name</th>
<th>Phone</th>
<th>Email</th>
<th>Name - പേര്</th>
<th>Phone - ഫോൺ</th>
<th>Other Contact - മറ്റ് കോൺടാക്റ്റ്</th>
</tr>
{% for req in filter.qs %}
<tr>
Expand Down
9 changes: 9 additions & 0 deletions mainapp/templates/mainapp/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends 'base.html' %}
{% load bootstrap3 %}

{% block content %}
<div class="row text-center static-page-box">
<h1 class="text-center">Error</h1>
<p style="font-size:1.7rem;">{{ error_text }}</p>
</div>
{% endblock %}
39 changes: 36 additions & 3 deletions mainapp/templates/mainapp/relief_camps.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,26 @@ <h3>
</div>
</div>

<hr>

<div class="text-center">
<h4>Select District to see Relief Camps</h4>
</div>

<form action="" method="get">
{{ filter.form }}
<button class="btn btn-default" type="submit">Show Relief Camps</button>
</form>

{% if relief_camps.count > 0 %}
<div>
<table class="table">
<tr>
<th>District</th>
<th>Camp Name</th>
<th>Map</th>
<th>Address</th>
<th>Contact</th>
<th>Contact Numbers</th>
<th>Registrations</th>
</tr>
{% for item in relief_camps %}
Expand All @@ -42,10 +55,13 @@ <h3>
{{ item.name }}
</td>
<td>
{{ item.location | linebreaks }}
{% if item.map_link %} <a href="{{ item.map_link}}">Map Link</a> {% else %} N/A {% endif %}
</td>
<td>
{{ item.contacts }}
{{ item.location | linebreaks }}
</td>
<td class="phone-links">
{{ item.contacts | linebreaks }}
</td>
<td>
{{ item.count }}
Expand All @@ -54,4 +70,21 @@ <h3>
{% endfor %}
</table>
</div>
{% elif district_chosen %}
<div class="text-center text-warning">
No relief camps listed for this district yet.
</div>
{% endif %}


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$('.phone-links').each(function () {
var content = $(this).html();
// Convert 10 digit numbers to links
links = content.replace(/[0-9 ]{10,15}/g, "<a href=\"tel:$&\">$&</a>");
$(this).html(links);
})

</script>
{% endblock %}
53 changes: 53 additions & 0 deletions mainapp/templates/mainapp/request_details.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends 'base.html' %}
{% load bootstrap3 %}

{% block content %}

<form action="{%url 'requestlistview' %}" method="get" class="text-center">
{{ filter.form.as_p }}
<input value="View requests" class="btn btn-primary" type="submit" />
</form>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th colspan="2" style="text-align:center;">Request details</th>
</tr>
</thead>

<tbody>
<tr>
<td><b> District : </b></td><td>{{ req.get_district_display }}</td>
</tr>
<tr>
<td><b> Location : </b></td><td>{{ req.location }}</td>
</tr>
<tr>
<td><b> GPS Location : </b></td>
<td>
{% if not req.is_request_for_others and req.latlng %}
<a class="btn btn-sm btn-success" href="https://maps.google.com/?q={{ req.latlng }}" target="_blank">Open in maps</a>
<br>
Accuracy: {{ req.latlng_accuracy }}
{% else %}
NA
{% endif %}
</td>
</tr>
<tr>
<td><b> Requestee : </b></td><td>{{ req.requestee }}</td>
</tr>
<tr>
<td><b> Contact number : </b></td><td><a href="tel:{{ req.requestee_phone }}" >{{ req.requestee_phone }}</a></td>
</tr>
<tr>
<td><b> Summary of request : </b></td><td>{{ req.summarise | linebreaks }}</td>
</tr>
<tr>
<td><b> Date : </b></td><td>{{ req.dateadded }}</td>
</tr>
</tbody>
</table>

</div>
{% endblock %}
91 changes: 67 additions & 24 deletions mainapp/templates/mainapp/request_list.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,86 @@
{% extends 'base.html' %}
{% load bootstrap3 %}

{% block css %}
<style>
@media only screen and (max-width: 800px) {

#requests-table table, thead, tbody, th, td, tr {
display: block;
}

#requests-table thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}

#requests-table tr {
margin: 0 0 1rem 0;
}

#requests-table tr:nth-child(odd) {
background: #ccc;
}

#requests-table td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}

#requests-table td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 0;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
#requests-table td:nth-of-type(1):before { content: "District"; }
#requests-table td:nth-of-type(2):before { content: "Location"; }
#requests-table td:nth-of-type(3):before { content: "Requestee"; }
#requests-table td:nth-of-type(4):before { content: "Phone"; }
#requests-table td:nth-of-type(5):before { content: "Date"; }
#requests-table td:nth-of-type(6):before { content: "More details"; }
}
</style>
{% endblock %}

{% block content %}

<form action="" method="get" class="text-center">
{{ filter.form.as_p }}
<input value="View requests" class="btn btn-primary" type="submit" />
</form>
<div class="table-responsive">
<div id="requests-table" class="table-responsive">
<table class="table">
<tr>
<th>District</th>
<th>Location</th>
<th>GPS Location</th>
<th>Requestee</th>
<th>Contact number</th>
<th>Summary of request</th>
<th>Date</th>
</tr>
<thead>
<tr>
<th>District</th>
<th>Location</th>
<th>Requestee</th>
<th>Phone</th>
<th>Date</th>
<th>More details</th>
</tr>
</thead>
<tbody>
{% for req in data %}
<tr>
<td>{{ req.get_district_display }}</td>
<td>{{ req.location }}</td>
<td>
{% if not req.is_request_for_others and req.latlng %}
<a class="btn btn-sm btn-success" href="https://maps.google.com/?q={{ req.latlng }}" target="_blank">Open in maps</a>
<br>
Accuracy: {{ req.latlng_accuracy }}
{% else %}
NA
{% endif %}
</td>
<td>{{ req.requestee }}</td>
<td><a href="tel:{{ req.requestee_phone }}" >{{ req.requestee_phone }}</a></td>
<td>{{ req.summarise | linebreaks }}</td>
<td><a href="tel:{{ req.requestee_phone }}" >{{ req.requestee_phone }}</a></td>
<td>{{ req.dateadded }}</td>
<td><a class="btn btn-sm btn-success" href="{%url 'requestdetailsview' req.id %}" target="_blank">More details</a>
</tr>
{% endfor %}

</tbody>
</table>

<div class="pagination" >
Expand All @@ -46,15 +89,15 @@
<a href="?page=1&district={{ request.GET.district }}">&laquo; first</a>
<a href="?page={{ data.previous_page_number }}&district={{ request.GET.district }}">previous</a>
{% endif %}

{% for i in data.paginator.page_range %}
{% if data.number == i %}
<a class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></a>
{% else %}
<a href="?page={{ i }}&district={{ request.GET.district }}">{{ i }}</a>
{% endif %}
{% endfor %}

{% if data.has_next %}
<a href="?page={{ data.next_page_number }}&district={{ request.GET.district }}">next</a>
<a href="?page={{ data.paginator.num_pages }}&district={{ request.GET.district }}">last &raquo;</a>
Expand Down
7 changes: 5 additions & 2 deletions mainapp/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.urls import path
from django.conf.urls import url
from django.contrib.auth import views as auth_views
from . import views

Expand All @@ -9,6 +10,7 @@
path('volunteer/', views.RegisterVolunteer.as_view(), name='registerview'),
path('NGO/', views.RegisterNGO.as_view(), name='ngoregisterview'),
path('requests/', views.request_list, name='requestlistview'),
url(r'request_details/(?P<request_id>\d+)/$', views.request_details, name='requestdetailsview'),
path('contactus/', views.districtmanager_list, name='contactus'),
path('reg_success/', views.RegSuccess.as_view(), name='reg_successview'),
path('req_sucess/', views.ReqSuccess.as_view(), name='req_sucessview'),
Expand All @@ -18,12 +20,13 @@
path('disclaimer/', views.DisclaimerPage.as_view(), name='disclaimer'),
path('ieee/', views.AboutIEEE.as_view(), name='aboutieee'),
path('data/' , views.mapdata , name="mapdata"),
path('map_td/' , views.mapview , name="mapview"),
path('map/' , views.mapview , name="mapview"),
path('dmodash/' , views.dmodash , name="DMODash"),
path('dmoinfo/' , views.dmoinfo , name="DMOInfo" ),
path('error/' , views.error , name="errorview" ),
path('add_person/', views.AddPerson.as_view(), name='add_person'),
path('login/', auth_views.LoginView.as_view(template_name='mainapp/login.html'),name='user_login'),
path('logout/', views.logout_view, name='user_logout'),
path('relief_camps/', views.ReliefCamps.as_view(), name='relief_camps'),
path('relief_camps/', views.relief_camps, name='relief_camps'),
path('find_people/', views.find_people, name='find_people'),
]
Loading

0 comments on commit b1a7800

Please sign in to comment.