def get(self): user = users.get_current_user() logging.info(user) user_email = user.email() role = RoleEntity.get_by_id('admin') members = role.members if not members: members = [] if user_email not in members: logging.critical("Unauthorized request : " + user_email) self.response.write("Unauthorized request") return self.response.headers['Content-Type'] = 'application/csv;charset=UTF-8' self.response.headers['Content-disposition'] = 'attachment; filename=all_feedbacks.csv' csv_writer = csv.writer(self.response.out, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL) u_csv_writer = UnicodeWriter(self.response.out) qry = FeedbackEntity.query().order(-FeedbackEntity.date_created) fbs = qry.fetch() fms = [] # csv_writer.writerow(['id','restaurant','entrie','quantity','flavor','deliverman','overall','timestamp']) u_csv_writer.writerow(['id','restaurant','entrie','quantity','flavor','deliverman','overall','timestamp','comment']) for fb in fbs: created_time = fb.date_created if created_time: utc_zone = tz.gettz('UTC') cst_zone = tz.gettz('America/Chicago') created_time = created_time.replace(tzinfo=utc_zone) created_time_cst = created_time.astimezone(cst_zone) created_time_cst = created_time_cst.strftime('%Y-%m-%d') else: created_time_cst = "" u_csv_writer.writerow([str(fb.key.id()),fb.restaurant or "",fb.entrie or "", fb.quantity or "", fb.flavor or "", fb.deliverman or "", fb.overall_rating or "", created_time_cst, fb.comment or ""])
def roles_check(self, request): user = endpoints.get_current_user() user_email = user.email() role = RoleEntity.get_by_id(request.role) resp = "false" if user_email in role.members: resp = "true" return BooleanMessage(resp=resp)
def roles_get(self, request): check_admin(endpoints) role = RoleEntity.get_by_id(request.name) return RoleMessage(name=role.name, description=role.description, members=role.members)
def roles_patch(self, request): check_admin(endpoints) role = RoleEntity(id=request.name, name=request.name, description=request.description, members=request.members) role.put() return RoleMessage(name=role.name, description=role.description, members=role.members)