MCPcopy Create free account
hub / github.com/c3bottles/c3bottles / Location

Class Location

c3bottles/model/location.py:10–115  ·  view source on GitHub ↗

A physical location of a drop point at some point in time. Drop points may be relocated at any time for whatever reason. For analysis after an event and optimization of the drop point locations for the next event at the same venue, drop point locations are tracked over time.

Source from the content-addressed store, hash-verified

8
9
10class Location(db.Model):
11 """
12 A physical location of a drop point at some point in time.
13
14 Drop points may be relocated at any time for whatever reason. For
15 analysis after an event and optimization of the drop point locations
16 for the next event at the same venue, drop point locations are tracked
17 over time.
18
19 Each location has a start time indicating the placement of the drop
20 point at that location. If a drop point is relocated, a new location
21 with the respective start time is added. If the start time is null,
22 the drop point has been there since the creation of the universe.
23
24 If the human-readable description as well as the coordinates both are
25 null, the location of that drop point is unknown.
26 """
27
28 MAX_DESCRIPTION: int = 140
29
30 loc_id = db.Column(db.Integer, primary_key=True)
31
32 dp_id = db.Column(db.Integer, db.ForeignKey("drop_point.number"), nullable=False)
33
34 dp = db.relationship("DropPoint")
35
36 time = db.Column(db.DateTime)
37 description = db.Column(db.String(MAX_DESCRIPTION))
38 lat = db.Column(db.Float)
39 lng = db.Column(db.Float)
40 level = db.Column(db.Integer)
41
42 def __init__(
43 self,
44 dp: "drop_point.DropPoint",
45 time: datetime = None,
46 description: str = None,
47 lat: float = None,
48 lng: float = None,
49 level: int = None,
50 ):
51 errors: List[Dict[str, LazyString]] = []
52
53 if not isinstance(dp, drop_point.DropPoint):
54 errors.append({"Location": lazy_gettext("Not given a drop point object.")})
55 raise ValueError(errors)
56
57 self.dp = dp
58
59 if time and not isinstance(time, datetime):
60 errors.append({"Location": lazy_gettext("Start time not a datetime object.")})
61
62 if isinstance(time, datetime) and time > datetime.now():
63 errors.append({"Location": lazy_gettext("Start time in the future.")})
64
65 if dp.locations and isinstance(time, datetime) and time < dp.locations[-1].time:
66 errors.append({"Location": lazy_gettext("Location older than current.")})
67

Callers 11

l2Function · 0.90
test_invalid_dpFunction · 0.90
test_location_futureFunction · 0.90
test_invalid_latFunction · 0.90
test_invalid_lngFunction · 0.90
test_invalid_levelFunction · 0.90
__init__Method · 0.90
editFunction · 0.90

Calls

no outgoing calls

Tested by 9

l2Function · 0.72
test_invalid_dpFunction · 0.72
test_location_futureFunction · 0.72
test_invalid_latFunction · 0.72
test_invalid_lngFunction · 0.72
test_invalid_levelFunction · 0.72