Handle observations with deleted stations
parent
8c87819fc6
commit
8a2b850656
|
@ -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):
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in New Issue