habulaj commited on
Commit
bb4df7f
·
verified ·
1 Parent(s): 923951b

Update routes/logs.py

Browse files
Files changed (1) hide show
  1. routes/logs.py +14 -13
routes/logs.py CHANGED
@@ -171,23 +171,24 @@ async def get_logs(
171
  new_data = {}
172
 
173
  email = user_info.get("email", "Someone")
174
- target_email = None
175
 
176
- if reference == "User" and new_data:
177
- target_email = new_data.get("email")
178
- elif reference == "Approval" and old_data:
179
- target_email = old_data.get("name")
 
180
  elif reference == "Collaboration":
181
- target_email = new_data.get("email") or old_data.get("email")
182
  elif reference == "Onboarding":
183
- target_email = None
184
 
185
  if action == "update" and reference == "User":
186
- return f"{email} updated profile information of {target_email or 'a user'}"
187
  elif action == "approve" and reference == "Approval":
188
- return f"{email} approved stylist {target_email or ''}"
189
  elif action == "deny" and reference == "Approval":
190
- return f"{email} denied stylist {target_email or ''}"
191
  elif action == "update" and reference == "Onboarding":
192
  return f"{email} updated an onboarding question"
193
  elif action == "add" and reference == "Onboarding":
@@ -195,11 +196,11 @@ async def get_logs(
195
  elif action == "delete" and reference == "Onboarding":
196
  return f"{email} deleted an onboarding question"
197
  elif action == "add" and reference == "Collaboration":
198
- return f"{email} added {target_email or 'a collaborator'} to the team"
199
  elif action == "delete" and reference == "Collaboration":
200
- return f"{email} removed {target_email or 'a collaborator'} from the team"
201
  elif action == "update" and reference == "Collaboration":
202
- return f"{email} updated permissions of {target_email or 'a collaborator'}"
203
 
204
  return f"{email} performed action: {action} on {reference}"
205
 
 
171
  new_data = {}
172
 
173
  email = user_info.get("email", "Someone")
174
+ target_name = None
175
 
176
+ if reference == "User":
177
+ target_name = old_data.get("name") or old_data.get("email") or new_data.get("name") or new_data.get("email")
178
+
179
+ elif reference == "Approval":
180
+ target_name = old_data.get("name")
181
  elif reference == "Collaboration":
182
+ target_name = new_data.get("email") or old_data.get("email")
183
  elif reference == "Onboarding":
184
+ target_name = None
185
 
186
  if action == "update" and reference == "User":
187
+ return f"{email} updated profile information of {target_name or 'a user'}"
188
  elif action == "approve" and reference == "Approval":
189
+ return f"{email} approved stylist {target_name or ''}"
190
  elif action == "deny" and reference == "Approval":
191
+ return f"{email} denied stylist {target_name or ''}"
192
  elif action == "update" and reference == "Onboarding":
193
  return f"{email} updated an onboarding question"
194
  elif action == "add" and reference == "Onboarding":
 
196
  elif action == "delete" and reference == "Onboarding":
197
  return f"{email} deleted an onboarding question"
198
  elif action == "add" and reference == "Collaboration":
199
+ return f"{email} added {target_name or 'a collaborator'} to the team"
200
  elif action == "delete" and reference == "Collaboration":
201
+ return f"{email} removed {target_name or 'a collaborator'} from the team"
202
  elif action == "update" and reference == "Collaboration":
203
+ return f"{email} updated permissions of {target_name or 'a collaborator'}"
204
 
205
  return f"{email} performed action: {action} on {reference}"
206