Merge pull request #74 from satnogs/73-ground-station-single
Add single station view and fixes of links.merge-requests/75/head
commit
12ebbd304a
|
@ -14,4 +14,8 @@ indent_size = 4
|
|||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.{js,html}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -8,7 +8,7 @@ class AntennaAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
class StationAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'owner', 'lng', 'lat')
|
||||
list_display = ('name', 'owner', 'lng', 'lat', 'location')
|
||||
|
||||
|
||||
class SatelliteAdmin(admin.ModelAdmin):
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('base', '0009_auto_20141027_1522'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='station',
|
||||
name='location',
|
||||
field=models.CharField(max_length=255, null=True, blank=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import datetime
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('base', '0010_station_location'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='station',
|
||||
name='created',
|
||||
field=models.DateTimeField(default=datetime.datetime(2014, 12, 1, 19, 31, 18, 716421, tzinfo=utc), auto_now_add=True),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -33,9 +33,11 @@ class Station(models.Model):
|
|||
MinValueValidator(-90)])
|
||||
lng = models.FloatField(validators=[MaxValueValidator(180),
|
||||
MinValueValidator(-180)])
|
||||
location = models.CharField(max_length=255, null=True, blank=True)
|
||||
antenna = models.ManyToManyField(Antenna)
|
||||
featured = models.BooleanField(default=False)
|
||||
featured_date = models.DateField(null=True, blank=True)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
# Set featured_date when featured bit is flipped
|
||||
|
|
|
@ -130,3 +130,11 @@ def stations_list(request):
|
|||
stations = Station.objects.all()
|
||||
|
||||
return render(request, 'base/stations.html', {'stations': stations})
|
||||
|
||||
|
||||
def view_station(request, id):
|
||||
"""View for single station page."""
|
||||
station = get_object_or_404(Station, id=id)
|
||||
|
||||
return render(request, 'base/station_view.html',
|
||||
{'station': station})
|
||||
|
|
|
@ -122,4 +122,17 @@
|
|||
|
||||
.calculation-result {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
#map-station {
|
||||
margin-top: 2%;
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.station-view-image {
|
||||
width: 200px;
|
||||
float: right;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
$(document).ready(function() {
|
||||
//Reading data for station
|
||||
var station_info = $('#station-info').data();
|
||||
|
||||
//Init the map
|
||||
L.mapbox.accessToken = 'pk.eyJ1IjoicGllcnJvcyIsImEiOiJhTVZyWmE4In0.kl2j9fi24LDXfB3MNdN76w';
|
||||
var map = L.mapbox.map('map-station', 'pierros.jbf6la1j',{
|
||||
zoomControl: false
|
||||
}).setView([station_info.lat, station_info.lng], 6);
|
||||
|
||||
//Add a marker
|
||||
L.mapbox.featureLayer({
|
||||
type: 'Feature',
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [
|
||||
parseFloat(station_info.lng),
|
||||
parseFloat(station_info.lat)
|
||||
]
|
||||
},
|
||||
properties: {
|
||||
title: station_info.name,
|
||||
'marker-size': 'large',
|
||||
'marker-color': '#666',
|
||||
}
|
||||
}).addTo(map);
|
||||
});
|
|
@ -6,8 +6,8 @@
|
|||
{% block title %}Home{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.0.1/mapbox.js'></script>
|
||||
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.0.1/mapbox.css' rel='stylesheet' />
|
||||
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.4/mapbox.js'></script>
|
||||
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.4/mapbox.css' rel='stylesheet' />
|
||||
{% endblock css %}
|
||||
|
||||
{% block prenav-content %}
|
||||
|
@ -43,7 +43,11 @@
|
|||
class="img-gs-front"
|
||||
alt="{{ featured_station.name }}"
|
||||
title="{{ featured_station.name }}">
|
||||
<h3>{{ featured_station.name }}</h3>
|
||||
<h3>
|
||||
<a href="{% url 'base.views.view_station' id=featured_station.id %}">
|
||||
{{ featured_station.name }}
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="caption">
|
||||
<div class="gs-front-line">
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
{% extends "base.html" %}
|
||||
{% load tags %}
|
||||
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block title %}Ground Station {{ station.name }}{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.4/mapbox.js'></script>
|
||||
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.4/mapbox.css' rel='stylesheet' />
|
||||
{% endblock css %}
|
||||
|
||||
{% block content %}
|
||||
<h2 id="station-info"
|
||||
data-name="{{ station.name }}"
|
||||
data-id="{{ station.id }}"
|
||||
data-lng="{{ station.lng }}"
|
||||
data-lat="{{ station.lat }}">
|
||||
{{ station.id }} - {{ station.name }}
|
||||
{% if request.user == station.owner %}
|
||||
<a class="btn btn-primary pull-right" href="#">Edit Station</a>
|
||||
{% endif %}
|
||||
</h2>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="gs-front-line">
|
||||
<span class="label label-default">Owner</span>
|
||||
<span class="gs-front-data">
|
||||
<a href="{% url 'users:view_user' station.owner.username %}">
|
||||
{{ station.owner.get_full_name }}
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="gs-front-line">
|
||||
<span class="label label-default">Location</span>
|
||||
<span class="gs-front-data">
|
||||
{{ station.location }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="gs-front-line">
|
||||
<span class="label label-default">Coordinates</span>
|
||||
<span class="gs-front-data">
|
||||
{{ station.lat|floatformat:-3 }}, {{ station.lng|floatformat:-3 }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="gs-front-line">
|
||||
<span class="label label-default">Altitude</span>
|
||||
<span class="gs-front-data">
|
||||
{{ station.alt }} m
|
||||
</span>
|
||||
</div>
|
||||
<div class="gs-front-line">
|
||||
<span class="label label-default">Creation Date</span>
|
||||
<span class="gs-front-data"
|
||||
title="{{ station.created|date:"c" }}">
|
||||
{{ station.created|timesince }} ago
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{% for antenna in station.antenna.all %}
|
||||
<div class="gs-front-line">
|
||||
<span class="label label-default">Antenna</span>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
{{ antenna.band }} - {{ antenna.antenna_type }} - {% frq antenna.frequency %}
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<p class="notice">
|
||||
No antenna associated with this station.
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<img src="{{ MEDIA_URL }}{{ station.image }}"
|
||||
class="station-view-image"
|
||||
alt="{{ station.name }}"
|
||||
title="{{ station.name }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="map-station"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
{% block javascript %}
|
||||
<script src="{% static 'js/station_view.js' %}"></script>
|
||||
{% endblock javascript %}
|
|
@ -20,25 +20,37 @@
|
|||
<th>Location</th>
|
||||
<th>Altitude</th>
|
||||
<th>Antenna</th>
|
||||
<th>Owner</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for station in stations.all %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#">
|
||||
<a href="{% url 'base.views.view_station' id=station.id %}">
|
||||
<span class="label label-default">
|
||||
{{ station.id }}
|
||||
</span>
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ station.name }}</td>
|
||||
<td>{{ station.lat }}, {{ station.lng }}</td>
|
||||
{% if station.location %}
|
||||
<td title="{{ station.lat|floatformat:-3 }}, {{ station.lng|floatformat:-3 }}">
|
||||
{{ station.location }}
|
||||
</td>
|
||||
{% else %}
|
||||
<td>{{ station.lat|floatformat:-3 }}, {{ station.lng|floatformat:-3 }}</td>
|
||||
{% endif %}
|
||||
<td>{{ station.alt}} m</td>
|
||||
<td>
|
||||
{% for antenna in station.antenna.all %}
|
||||
{{ antenna.antenna_type}} on {{ antenna.frequency }} ({{ antenna.band}})<br>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{% url 'users:view_user' station.owner.username %}">
|
||||
{{ station.owner.get_full_name }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
{% for station in stations.all %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#">
|
||||
<a href="{% url 'base.views.view_station' id=station.id %}">
|
||||
<span class="label label-default">
|
||||
{{ station.id }}
|
||||
</span>
|
||||
|
|
|
@ -24,6 +24,8 @@ urlpatterns = patterns(
|
|||
TemplateView.as_view(template_name='base/about.html'),
|
||||
name='about'),
|
||||
url(r'^stations/$', 'base.views.stations_list', name='stations'),
|
||||
url(r'^s/(?P<id>[0-9]+)/$',
|
||||
'base.views.view_station', name='stations_view_station'),
|
||||
url(r'^prediction_windows/(?P<sat_id>[\w.@+-]+)/(?P<start_date>.+)/(?P<end_date>.+)/$',
|
||||
'base.views.prediction_windows',
|
||||
name='prediction_windows'),
|
||||
|
|
Loading…
Reference in New Issue