1
0
Fork 0

Handle observations with deleted stations

merge-requests/412/head
Nikos Roussos 2017-10-09 20:37:29 +03:00
parent 8c87819fc6
commit 8a2b850656
No known key found for this signature in database
GPG Key ID: BADFF1767BA7C8E1
6 changed files with 39 additions and 18 deletions

View File

@ -41,13 +41,22 @@ class ObservationSerializer(serializers.ModelSerializer):
return obj.satellite.norad_cat_id
def get_station_name(self, obj):
return obj.ground_station.name
try:
return obj.ground_station.name
except:
return None
def get_station_lat(self, obj):
return obj.ground_station.lat
try:
return obj.ground_station.lat
except:
return None
def get_station_lng(self, obj):
return obj.ground_station.lng
try:
return obj.ground_station.lng
except:
return None
class JobSerializer(serializers.ModelSerializer):

View File

@ -428,9 +428,13 @@ def observation_view(request, id):
if request.user.is_authenticated():
if observation.author == request.user or request.user.is_staff:
is_vetting_user = True
if Station.objects.filter(owner=request.user). \
filter(id=observation.ground_station.id).count():
is_vetting_user = True
# Hadle exception for deleted station
try:
if Station.objects.filter(owner=request.user). \
filter(id=observation.ground_station.id).count():
is_vetting_user = True
except:
pass
# This context flag will determine if a delete button appears for the observation.
# That includes observer, superusers and people with certain permission.

View File

@ -192,9 +192,11 @@
<span class="datetime-time">{{ observation.end|date:"H:i:s" }}</span>
</td>
<td>
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station }}
</a>
{% if observation.ground_station %}
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station }}
</a>
{% endif %}
</td>
</tr>
{% endfor %}

View File

@ -65,9 +65,11 @@
<div class="front-line">
<span class="label label-default">Station</span>
<span class="front-data">
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station.name }}
</a>
{% if observation.ground_station %}
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station.name }}
</a>
{% endif %}
</span>
</div>
<div class="front-line">

View File

@ -101,9 +101,11 @@
</a>
</td>
<td>
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station }}
</a>
{% if observation.ground_station %}
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station }}
</a>
{% endif %}
</td>
</tr>
{% endfor %}

View File

@ -146,9 +146,11 @@
<span class="datetime-time">{{ observation.end|date:"H:i:s" }}</span>
</td>
<td>
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station }}
</a>
{% if observation.ground_station %}
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station }}
</a>
{% endif %}
</td>
</tr>
{% endfor %}