summaryrefslogtreecommitdiff
path: root/tools/mmd/MmdLocationList.py
diff options
context:
space:
mode:
authorJogi Hofmüller <jogi@mur.at>2011-08-03 11:19:44 +0000
committerJogi Hofmüller <jogi@mur.at>2011-08-03 11:19:44 +0000
commit502b6a813a6f90c2e7adb5781b1beecd559014d9 (patch)
tree6c46b328e6a106bc770ad77650c0b6a14fb525e5 /tools/mmd/MmdLocationList.py
parentcleanup (diff)
- added functionality for location
- user's default location is save - map centers on user's location iff available git-svn-id: https://svn.spreadspace.org/mur.sat@96 7de4ea59-55d0-425e-a1af-a3118ea81d4c
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