Skip to content

Commit 072014c

Browse files
committed
Fixed findroute not to set self.step_points as None
1 parent d40a67e commit 072014c

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

tsptw/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def render(self) -> None:
1616
with st.sidebar:
1717
user_info = login_button(client_id=AUTH0_CLIENT_ID, domain=AUTH0_DOMAIN)
1818
if user_info:
19+
if not user_info["email_verified"]:
20+
st.error("Email is not verified")
21+
return
22+
1923
st.session_state["sid"] = user_info["sid"]
2024
else:
2125
if "sid" in st.session_state and st.session_state["sid"] is None:

tsptw/pages/edit.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def submit(
2020
actor: ActorId = ActorId.NONE,
2121
sp_id: str = "",
2222
timestamp: int = 0,
23-
first_set: bool = False,
2423
last_delete: bool = False,
2524
):
2625
sid = st.session_state["sid"]
@@ -41,10 +40,7 @@ def submit(
4140
end_time,
4241
)
4342

44-
if first_set:
45-
cont_ref.set({sp.id: sp.to_dict()})
46-
else:
47-
cont_ref.update({sp.id: sp.to_dict()})
43+
cont_ref.set({sp.id: sp.to_dict()}, merge=True)
4844
elif actor == ActorId.UPDATE:
4945
sp = StepPoint(sp_id, timestamp, step_name, step_address, staying_min, start_time, end_time)
5046
cont_ref.update({sp.id: sp.to_dict()})
@@ -137,7 +133,6 @@ def render(self):
137133
"actor": ActorId.ADD,
138134
"sp_id": self.selected["id"],
139135
"timestamp": self.selected["timestamp"],
140-
"first_set": self.selected["id"] == "",
141136
"last_delete": contacts is not None and len(contacts) == 1,
142137
},
143138
)
@@ -151,7 +146,6 @@ def render(self):
151146
"actor": ActorId.UPDATE,
152147
"sp_id": self.selected["id"],
153148
"timestamp": self.selected["timestamp"],
154-
"first_set": self.selected["id"] == "",
155149
"last_delete": contacts is not None and len(contacts) == 1,
156150
},
157151
)
@@ -165,7 +159,6 @@ def render(self):
165159
"actor": ActorId.DELETE,
166160
"sp_id": self.selected["id"],
167161
"timestamp": self.selected["timestamp"],
168-
"first_set": self.selected["id"] == "",
169162
"last_delete": contacts is not None and len(contacts) == 1,
170163
},
171164
)

tsptw/pages/findroute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def render(self):
200200
st.warning("Please login to continue")
201201
return
202202

203-
if "step_points" in st.session_state:
203+
if "step_points" in st.session_state and st.session_state["step_points"]:
204204
self.step_points = st.session_state["step_points"]
205205

206206
contacts = self.sort_data(self.connect_to_database(st.session_state["sid"]))
@@ -215,7 +215,7 @@ def render(self):
215215
self.step_points = st.multiselect(
216216
"経由地点",
217217
contacts.values(),
218-
self.step_points,
218+
default=self.step_points,
219219
format_func=lambda contact: contact["name"],
220220
key="step_points",
221221
disabled=len(self.step_points) > 25,

0 commit comments

Comments
 (0)