def get(self, pk): if not CredentialManager.get_is_admin(): raise UnauthorizedError("Unauthorized.") speakerinfo = get_or_404(SpeakerInfo, pk) return speakerinfo
def get(self): if not CredentialManager.get_is_admin(): raise UnauthorizedError("Unauthorized.") users = User.query.all() return users
def get(self, pk): if not CredentialManager.get_is_admin(): raise UnauthorizedError("Unauthorized.") user = get_or_404(User, pk) return user
def delete(self, pk): if not CredentialManager.get_is_admin(): raise UnauthorizedError("Unauthorized.") speakerinfo = get_or_404(SpeakerInfo, pk) SpeakerInfoRepo.delete(speakerinfo) return '', 204
def log(): from app.managers.credential import CredentialManager secret_key = CredentialManager.get_secret_key() results = LoggerResource().get() return render_template("admin/admin_log.html", secret_key=secret_key, results=results, logs=results["items"])
def get(self): libraries = Library.query.all() resp_fields = library_fields if CredentialManager.get_is_admin(): resp_fields = {**library_fields, **library_protected_fields} return marshal(libraries, resp_fields)
def delete(self, pk): if not CredentialManager.get_is_admin(): raise UnauthorizedError("Unauthorized.") user = get_or_404(User, pk) try: db.session.delete(user) db.session.commit() except Exception as e: print(str(e)) db.session.rollback() raise e return '', 204
def get(self, pk): if not CredentialManager.get_is_admin(): raise UnauthorizedError("Unauthorized.") speaker = get_or_404(SpeakerInfo, pk) speaker.admin_approved = 1 try: db.session.merge(speaker) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return {"result": 0}
def get(self): if not CredentialManager.get_is_admin(): raise UnauthorizedError("Unauthorized.") args = self.parser.parse_args() print(args["page"]) logs = Log.query.order_by(Log._id.desc())\ .paginate(args["page"], self.PER_PAGE, False) results = [] for item in logs.items: results.append(raw_logitem_to_dict(item)) return { "has_next": logs.has_next, "has_prev": logs.has_prev, "items": results, "next_num": logs.next_num, "page": logs.page, "pages": logs.pages, "prev_num": logs.prev_num, "total": logs.total, }