Skip to content

Commit

Permalink
a track has a flight now, and reverse name is hardcoded to track
Browse files Browse the repository at this point in the history
  • Loading branch information
tamarmot authored and batiyeh committed May 5, 2018
1 parent 080f836 commit b62eae6
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions geocamTrack/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from geocamUtil.loader import LazyGetModelByName

from geocamUtil.usng import usng
from xgds_core.models import SearchableModel, HasVehicle
from xgds_core.models import SearchableModel, HasVehicle, HasFlight

# pylint: disable=C1001
latestRequestG = None
Expand All @@ -43,26 +43,6 @@ def getModClass(name):
return name[:dot], name[dot + 1:]


# class AbstractResource(UuidModel):
# name = models.CharField(max_length=128, db_index=True)
# user = models.ForeignKey(User, null=True, blank=True)
# extras = ExtrasDotField()
# primary = models.NullBooleanField(null=True, default=False) # to be used for 'primary vehicles' which show up in the import dropdown
#
# def __unicode__(self):
# return '%s %s' % (self.__class__.__name__, self.name)
#
# def get_content_type(self):
# return ContentType.objects.get_for_model(self).pk
#
# class Meta:
# abstract = True
#
#
# class Resource(AbstractResource):
# pass


class IconStyle(UuidModel):
name = models.CharField(max_length=40, blank=True)
url = models.CharField(max_length=1024, blank=True)
Expand Down Expand Up @@ -208,7 +188,11 @@ def getKmlUrl(trackName=None,
return reverse(urlPattern) + queryParams


# TODO update this if you are not using Vehicle
# TODO update these if you are not using defaults
DEFAULT_FLIGHT_FIELD = lambda: models.ForeignKey('xgds_core.Flight',
related_name='track',
verbose_name=settings.XGDS_CORE_FLIGHT_MONIKER, blank=True,
null=True)
DEFAULT_VEHICLE_FIELD = lambda: models.ForeignKey('xgds_core.Vehicle',
related_name='%(app_label)s_%(class)s_related',
verbose_name=settings.XGDS_CORE_VEHICLE_MONIKER, blank=True,
Expand All @@ -219,7 +203,7 @@ def getKmlUrl(trackName=None,
related_name='%(app_label)s_%(class)s_related')


class AbstractTrack(SearchableModel, UuidModel, HasVehicle):
class AbstractTrack(SearchableModel, UuidModel, HasVehicle, HasFlight):
""" This is for an abstract track with a FIXED vehicle model, ie all the tracks have like vehicles.
"""
name = models.CharField(max_length=40, blank=True)
Expand Down Expand Up @@ -596,6 +580,8 @@ def getSearchFormFields(cls):
class Track(AbstractTrack, HasVehicle):
iconStyle = DEFAULT_ICON_STYLE_FIELD()
lineStyle = DEFAULT_LINE_STYLE_FIELD()
flight = DEFAULT_FLIGHT_FIELD()
vehicle = DEFAULT_VEHICLE_FIELD()

def __unicode__(self):
return '%s %s' % (self.__class__.__name__, self.name)
Expand Down

0 comments on commit b62eae6

Please sign in to comment.