コード例 #1
0
def eliminarComentarioById(id):

    comentario = get_comentario(id)
    if current_user.is_admin() or current_user.is_owner(comentario) or current_user.is_owner(comentario.evento):
        try:
            db.session.delete(comentario)
            db.session.commit()
        except SQLAlchemyError as e:
            db.rollback()
            enviarMail(os.getenv('ADMIN_MAIL'), 'SQLAlchemy error', 'error', e=e)

        flash('Comentario eliminado!', 'success')
        return redirect(url_for('vistaevento', id=comentario.eventoId))
    else:
        return redirect(url_for('index'))
コード例 #2
0
 def get_book_profile(self, book_id) -> (dict, bool):
     book = self.get_model(book_id, BookModel)
     formed_book = self._book_formation(book)
     owner = False
     if not current_user.is_anonymous:
         owner = current_user.is_owner(book.user_id)
     return (formed_book, owner)
コード例 #3
0
 def get_book_profile(self, book_id) -> (dict, bool):
     book = self.get_model(book_id, BookModel)
     formed_book = self._book_formation(book)
     owner = False
     if not current_user.is_anonymous:
         owner = current_user.is_owner(book.user_id)
     return (formed_book, owner)
コード例 #4
0
ファイル: routes.py プロジェクト: rahuldesai1/AppReview
def generate_queue():
    if not current_user.is_owner():
        flash("You are not the owner of the group")
        return redirect(url_for("index"))
    queue = utils.generate_queue_from_application(
        current_user.get_application())
    current_user.get_application().application_list = utils.serialize(queue)
    db.session.commit()
    flash("Application is now open for Review")
    return redirect(url_for('index'))
コード例 #5
0
def eliminarEventoById(id):
    evento = get_evento(id)
    if current_user.is_admin() or current_user.is_owner(evento):
        try:
            db.session.delete(evento)
            db.session.commit()
        except SQLAlchemyError as e:
            db.rollback()
            enviarMail(os.getenv('ADMIN_MAIL'), 'SQLAlchemy error', 'error', e=e)
        return redirect(url_for('aprobareventos'))
    else:
        return redirect(url_for('index'))
コード例 #6
0
ファイル: routes.py プロジェクト: rahuldesai1/AppReview
def create_application():
    if not current_user.is_owner():
        flash("You are not the owner of the group")
        return redirect(url_for("index"))
    form = ApplicationForm()
    if form.validate_on_submit():
        # if the current user already has an app, override it
        app = Application(num_apps=form.num_apps.data,
                          reviews_per_app=form.reviews_per_app.data,
                          reviews_per_user=form.num_per_user.data,
                          typeform_id=form.typeform_id.data,
                          semester=form.semester.data,
                          group=current_user.group)
        current_user.get_group().application = app
        # clear the list of reviewed applications for all existing users
        for user in current_user.get_group().users:
            user.applications_reviewed = None
        db.session.add(app)
        db.session.commit()
        return redirect(url_for('group'))
    return render_template("create_application.html", form=form)