def photo_view(self):
# Check agreements
if not self.user.purchase_agreement:
return HTTPFound(location=self.request.route_path("purchase_agreement_act"))
elif not self.user.privacy_agreement:
return HTTPFound(location=self.request.route_path("privacy_policy_act"))
base_path = self.request.registry._settings["base_dir"]
if "tick_id" in self.request.matchdict:
tick_id = self.request.matchdict["tick_id"]
ticket = None
# Find ticket
for tick in self.user.tickets:
if tick.__name__ == tick_id:
ticket = tick
break
# Safety
if ticket == None:
return FileResponse(os.path.join(base_path, "data/profile_images", "blank.png"), request=self.request)
else:
file_name = ticket.guest_info.photo_file
if os.path.isfile(os.path.join(base_path, "data/profile_images", file_name)):
return FileResponse(os.path.join(base_path, "data/profile_images", file_name), request=self.request)
else:
return FileResponse(os.path.join(base_path, "data/profile_images", "blank.png"), request=self.request)
else:
file_name = self.user.profile.photo_file
if os.path.isfile(os.path.join(base_path, "data/profile_images", file_name)):
return FileResponse(os.path.join(base_path, "data/profile_images", file_name), request=self.request)
else:
return FileResponse(os.path.join(base_path, "data/profile_images", "blank.png"), request=self.request)
评论列表
文章目录