Rename transmitter properties
Fixing these as part of W0511 There were some transmitter properties labeled "has_" (which implies a boolean) while returning a count. Renamed them and their instances to "_count" along with cleaning up some variables Signed-off-by: Corey Shields <cshields@gmail.com>merge-requests/402/head
parent
40460c47bb
commit
d71114130a
|
@ -117,35 +117,32 @@ class Satellite(models.Model):
|
||||||
# Remove the following pylint disable after Python 3 migration
|
# Remove the following pylint disable after Python 3 migration
|
||||||
return Transmitter.objects.filter(satellite=self.id).exclude(status='invalid') # pylint: disable=E1101
|
return Transmitter.objects.filter(satellite=self.id).exclude(status='invalid') # pylint: disable=E1101
|
||||||
|
|
||||||
# TODO: rename this to sound more like a count
|
|
||||||
@property
|
@property
|
||||||
def pending_transmitter_suggestions(self):
|
def transmitter_suggestion_count(self):
|
||||||
"""Returns number of pending transmitter suggestions for this Satellite
|
"""Returns number of pending transmitter suggestions for this Satellite
|
||||||
|
|
||||||
:returns: number of pending transmitter suggestions for this Satellite
|
:returns: number of pending transmitter suggestions for this Satellite
|
||||||
"""
|
"""
|
||||||
pending = TransmitterSuggestion.objects.filter(satellite=self.id).count()
|
pending_count = TransmitterSuggestion.objects.filter(satellite=self.id).count()
|
||||||
return pending
|
return pending_count
|
||||||
|
|
||||||
# TODO: rename this to sound more like a count
|
|
||||||
@property
|
@property
|
||||||
def has_telemetry_data(self):
|
def telemetry_data_count(self):
|
||||||
"""Returns number of DemodData for this Satellite
|
"""Returns number of DemodData for this Satellite
|
||||||
|
|
||||||
:returns: number of DemodData for this Satellite
|
:returns: number of DemodData for this Satellite
|
||||||
"""
|
"""
|
||||||
has_data = DemodData.objects.filter(satellite=self.id).count()
|
data_count = DemodData.objects.filter(satellite=self.id).count()
|
||||||
return has_data
|
return data_count
|
||||||
|
|
||||||
# TODO: rename this to sound more like a count
|
|
||||||
@property
|
@property
|
||||||
def has_telemetry_decoders(self):
|
def telemetry_decoder_count(self):
|
||||||
"""Returns number of Telemetry objects for this Satellite
|
"""Returns number of Telemetry objects for this Satellite
|
||||||
|
|
||||||
:returns: number of Telemetry objects for this Satellite
|
:returns: number of Telemetry objects for this Satellite
|
||||||
"""
|
"""
|
||||||
has_decoders = Telemetry.objects.filter(satellite=self.id).exclude(decoder='').count()
|
decoder_count = Telemetry.objects.filter(satellite=self.id).exclude(decoder='').count()
|
||||||
return has_decoders
|
return decoder_count
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{0} - {1}'.format(self.norad_cat_id, self.name)
|
return '{0} - {1}'.format(self.norad_cat_id, self.name)
|
||||||
|
|
|
@ -227,7 +227,7 @@ def decode_data(norad, period=None):
|
||||||
otherwise attempt to decode everything
|
otherwise attempt to decode everything
|
||||||
"""
|
"""
|
||||||
sat = Satellite.objects.get(norad_cat_id=norad)
|
sat = Satellite.objects.get(norad_cat_id=norad)
|
||||||
if not sat.has_telemetry_decoders:
|
if not sat.telemetry_decoder_count:
|
||||||
return
|
return
|
||||||
|
|
||||||
now = datetime.utcnow()
|
now = datetime.utcnow()
|
||||||
|
|
|
@ -56,8 +56,8 @@
|
||||||
{% with total=sat.transmitters.all.count %}
|
{% with total=sat.transmitters.all.count %}
|
||||||
{{ total }} transmitter{{ total|pluralize }}
|
{{ total }} transmitter{{ total|pluralize }}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% if request.user.is_superuser and sat.pending_transmitter_suggestions %}
|
{% if request.user.is_superuser and sat.transmitter_suggestion_count %}
|
||||||
- <span class="glyphicon glyphicon-edit" title="Suggest edits"></span> {{ sat.pending_transmitter_suggestions }}
|
- <span class="glyphicon glyphicon-edit" title="Suggest edits"></span> {{ sat.transmitter_suggestion_count }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -415,7 +415,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Data Structs Section -->
|
<!-- Data Structs Section -->
|
||||||
{% if satellite.has_telemetry_decoders %}
|
{% if satellite.telemetry_decoder_count %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 satellite-panels">
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 satellite-panels">
|
||||||
<div class="panel panel-default panel-satellite">
|
<div class="panel panel-default panel-satellite">
|
||||||
|
|
Loading…
Reference in New Issue