Skip to content

Commit 797ead9

Browse files
committed
Merge pull request OpenTreeMap#135 from ahinz/bug/polygons
Bug/polygons
2 parents 3c9e317 + 4aa7d57 commit 797ead9

File tree

6 files changed

+57
-35
lines changed

6 files changed

+57
-35
lines changed

polygons/admin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.contrib.gis import admin
2+
from polygons.models import TreeRegionPolygon, DBHClass, TreeRegionEntry
3+
4+
admin.site.register(DBHClass)
5+
admin.site.register(TreeRegionEntry)

polygons/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,26 @@ class TreeRegionPolygon(models.Model):
1010
photo = models.ImageField(upload_to="polygons/%Y/%m/%d",null=True,blank=True)
1111
objects = models.GeoManager()
1212

13+
def __unicode__(self):
14+
return u"Polygon #%s, Region ID: %s" % (self.pk, self.region_id)
15+
1316
class DBHClass(models.Model):
1417
label = models.CharField(max_length=255)
1518
dbh_min = models.FloatField()
1619
dbh_max = models.FloatField()
1720

21+
def __unicode__(self):
22+
return u"DBH Class #%s: %s (%s - %s)" % \
23+
(self.pk, self.label, self.dbh_min, self.dbh_max)
24+
1825
class TreeRegionEntry(models.Model):
1926
polygon = models.ForeignKey(TreeRegionPolygon)
2027
species = models.ForeignKey(Species)
2128
dbhclass = models.ForeignKey(DBHClass)
2229
count = models.IntegerField(default=0)
2330

2431
objects = models.GeoManager()
32+
33+
def __unicode__(self):
34+
return u"%s, Species: %s, Count: %s" % \
35+
(str(self.polygon), str(self.species), self.count)

static/css/polygons.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ input {
66
width: 100%;
77
}
88

9-
#polygontable {
9+
.table-container {
1010
overflow: auto;
11+
width: 95%;
1112
}
1213

1314
/** CSS for OTM is screwy... we're just going to give

templates/polygons/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<form method="POST" action="{{ SITE_ROOT }}polygons/{{ polygonobj.pk }}/photo" enctype="multipart/form-data">
5555
<input type="file" name="photo">
5656
<input type="hidden" name="currentpage" value="{{ request.get_full_path }}">
57-
<input type="submit">
57+
<input type="submit" value="Submit Photo">
5858
</form>
5959
{% endif %}
6060
</ul>

templates/polygons/edit.html

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,30 @@
55
<h1>Polygon #{{ polygonobj.pk }}</h1>
66

77
<form method="POST" action="{{ SITE_ROOT}}polygons/{{ polygonobj.pk }}/update">
8-
<table class="polygon-table table" data-id="{{ polygonobj.pk }}" width="100%">
9-
<tr>
10-
<th>Species</th>
11-
{% for cl in classes %}
12-
<th data-dbh-id={{ cl.pk }}>{{ cl.label }}</th>
8+
<div class="table-container">
9+
<table class="polygon-table table" data-id="{{ polygonobj.pk }}" width="100%">
10+
<tr>
11+
<th>Species</th>
12+
{% for cl in classes %}
13+
<th data-dbh-id={{ cl.pk }}>{{ cl.label }}</th>
14+
{% endfor %}
15+
<th></th>
16+
</tr>
17+
{% for row in polygon %}
18+
<tr>
19+
{% for item in row %}
20+
{% if forloop.first %}
21+
<td data-species-id="{{ item.0 }}">{{ item.1 }}</td>
22+
{% else %}
23+
<td><input name="pval_{{ polygonobj.pk }}_{{ row.0.0 }}_{{ item.0 }}" value="{% if item.1 %}{{ item.1 }}{% else %}0{% endif %}"></td>
24+
{% endif %}
25+
{% endfor %}
26+
<td><a href="#" class="removespecies">Remove</a></td>
27+
</tr>
1328
{% endfor %}
14-
<th></th>
15-
</tr>
16-
{% for row in polygon %}
17-
<tr>
18-
{% for item in row %}
19-
{% if forloop.first %}
20-
<td data-species-id="{{ item.0 }}">{{ item.1 }}</td>
21-
{% else %}
22-
<td><input name="pval_{{ polygonobj.pk }}_{{ row.0.0 }}_{{ item.0 }}" value="{% if item.1 %}{{ item.1 }}{% else %}0{% endif %}"></td>
23-
{% endif %}
24-
{% endfor %}
25-
<td><a href="#" class="removespecies">Remove</a></td>
26-
</tr>
27-
{% endfor %}
2829
</table>
30+
</div>
31+
2932
<input type="submit" name="submit" value="Update" />
3033
<a href="{{ SITE_ROOT}}polygons/{{ polygonobj.pk }}">Cancel</a>
3134
</form>

templates/polygons/view.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ <h1>Polygon #{{ polygonobj.pk }}</h1>
77
<a href="{{ SITE_ROOT }}polygons/{{ polygonobj.pk }}/edit"><button>Edit</button></a>
88
{% endif %}
99

10-
<table id="polygontable" class="table" width="100%">
11-
<tr>
12-
<th>Species</th>
13-
{% for cl in classes %}
14-
<th>{{ cl.label }}</th>
10+
<div class="table-container">
11+
<table id="polygontable" class="table" width="100%">
12+
<tr>
13+
<th>Species</th>
14+
{% for cl in classes %}
15+
<th>{{ cl.label }}</th>
16+
{% endfor %}
17+
</tr>
18+
{% for row in polygon %}
19+
<tr>
20+
{% for item in row %}
21+
<td>{{ item.1 }}</td>
22+
{% endfor %}
23+
</tr>
1524
{% endfor %}
16-
</tr>
17-
{% for row in polygon %}
18-
<tr>
19-
{% for item in row %}
20-
<td>{{ item.1 }}</td>
21-
{% endfor %}
22-
</tr>
23-
{% endfor %}
24-
</table>
25+
</table>
26+
</div>
2527

2628
{% endblock %}

0 commit comments

Comments
 (0)