summaryrefslogtreecommitdiff
path: root/tools/mmd/MmdLocationList.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mmd/MmdLocationList.py')
-rw-r--r--tools/mmd/MmdLocationList.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/mmd/MmdLocationList.py b/tools/mmd/MmdLocationList.py
new file mode 100644
index 0000000..fd793f7
--- /dev/null
+++ b/tools/mmd/MmdLocationList.py
@@ -0,0 +1,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, is_default):
+ location = Location ()
+ if location.create (name, longitude, latitude, 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