Ejemplo n.º 1
0
    def get(self, pk):
        if not CredentialManager.get_is_admin():
            raise UnauthorizedError("Unauthorized.")

        speakerinfo = get_or_404(SpeakerInfo, pk)

        return speakerinfo
Ejemplo n.º 2
0
    def get(self):
        if not CredentialManager.get_is_admin():
            raise UnauthorizedError("Unauthorized.")

        users = User.query.all()

        return users
Ejemplo n.º 3
0
    def get(self, pk):
        if not CredentialManager.get_is_admin():
            raise UnauthorizedError("Unauthorized.")

        user = get_or_404(User, pk)

        return user
Ejemplo n.º 4
0
    def delete(self, pk):
        if not CredentialManager.get_is_admin():
            raise UnauthorizedError("Unauthorized.")

        speakerinfo = get_or_404(SpeakerInfo, pk)
        SpeakerInfoRepo.delete(speakerinfo)

        return '', 204
Ejemplo n.º 5
0
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"])
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
    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}
Ejemplo n.º 9
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,
        }