summaryrefslogtreecommitdiff
path: root/tools/mmd/MmdLocationList.py
blob: 7b4c95db707d27baebbf1b06cca61b680f490c06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Location List class for MURSAT1 Mission Dashboard
"""
from cgi import parse_qs, escape
from MmdDb import Db
from MmdLocation import Location

class LocationList:

  def __init__ (self, user_id = False):
    self.db = Db ()
    self.locations = []
    if user_id:
      self.user_id = user_id
      location_ids = self.db.locationListByUserId (user_id)
      for l in location_ids:
        self.locations.append (Location (l['id']))

  def count (self):
    return len (self.locations)

  def getDefaultLocation (self):
    for l in self.locations:
      if l.is_default == 'yes':
        return l
    return False

  def addLocation (self, name, longitude, latitude, altitude, is_default):
    location = Location ()
    if location.create (name, longitude, latitude, altitude, is_default, self.user_id):
      self.locations.append (location)
      return True
    return False

  def delete (self):
    for location in self.locations:
      location.delete ()

if __name__ == "__main__":
  pass

# vim: tw=0 ts=2 expandtab
# EOF