Example #1
0
def sign_in():
    global error
    if (request.method == 'POST'):
        if (request.form['username'] == "" or request.form['password'] == ""
                or request.form['email'] == ""):
            error = 'Please provide some sign up information'
        else:
            # Professor
            if (request.form['username'].isnumeric() == False):
                params_to_insert = [
                    request.form['username'], request.form['password'],
                    request.form['email']
                ]
                db.connection_db(data=params_to_insert,
                                 query="insert",
                                 tablename="orientador")
                return redirect(url_for('login'))

            # Student
            elif (request.form['username'].isnumeric()):
                params_to_insert = [
                    request.form['username'], request.form['password'],
                    request.form['email']
                ]
                db.connection_db(data=params_to_insert,
                                 query="insert",
                                 tablename="student")
                return redirect(url_for('login'))

    return render_template("registo.html", error=error)
Example #2
0
def forgot_password():
    global error
    # Resets password
    if (request.method == 'POST'):
        if (request.form['new_username'].isnumeric()):
            update = {
                "new_user": request.form['new_username'],
                "new_pass": request.form['new_password']
            }

            # Updates password on database
            db.connection_db(data=update, query="update", tablename="student")
            return redirect(url_for('login'))

        elif (request.form['new_username'].isnumeric() == False):
            update = {
                "new_user": request.form['new_username'],
                "new_pass": request.form['new_password']
            }

            # Updates password on database
            db.connection_db(data=update,
                             query="update",
                             tablename="orientador")
            return redirect(url_for('login'))

    return render_template("forgot_password.html", error=error)
Example #3
0
def index():
    if (request.method == 'POST'):

        if (request.form.get('project') is None):
            # When the project is submitted its status is changed to submitted
            data = [{
                'title': request.form['title'],
                'status': "submitted",
                'student': request.form['student'],
                'orientador': request.form['orientador'],
                'public': "no"
            }]

            uploaded_file = request.files['file']
            filename = secure_filename(uploaded_file.filename)

            if (filename != ""):
                file_ext = os.path.splitext(filename)[1]
                if (file_ext not in app.config['UPLOAD_EXTENSIONS']):
                    return "Invalid image", 400

                uploaded_file.save(
                    os.path.join(app.config['UPLOAD_PATH'], filename))
                db.connection_db(data=data,
                                 query="insert",
                                 tablename="projetos",
                                 public="false")

                return redirect(url_for('aluno.personal_page'))

        elif (request.form.get('project') is not None):
            data = [{
                'title': request.form['title'],
                'status': "submitted",
                'student': request.form['student'],
                'orientador': request.form['orientador'],
                'public': "yes"
            }]

            uploaded_file = request.files['file']
            filename = secure_filename(uploaded_file.filename)

            if (filename != ""):
                file_ext = os.path.splitext(filename)[1]
                if (file_ext not in app.config['UPLOAD_EXTENSIONS']):
                    return "Invalid image", 400

                uploaded_file.save(
                    os.path.join(app.config['UPLOAD_PATH'], filename))
                db.connection_db(data=data,
                                 query="insert",
                                 tablename="projetos",
                                 public="true")

                return redirect(url_for('aluno.personal_page'))

    return render_template("upload.html")
Example #4
0
def submit_theme():
    if (request.method == 'POST'):

        # Submits a theme and the status becomes to_approve
        data = [{
            'title': request.form['title'],
            'status': 'to_approve',
            'student': request.form['student'],
            'orientador': request.form['orientador']
        }]

        db.connection_db(data=data, query="insert", tablename="projetos")

    return render_template("submit_tema.html")
def submit_grade():

    if (request.method == 'POST'):

        # Submit final grade
        grade = {
            "student": request.form['student'],
            "project_name": request.form['project'],
            "grade": request.form['note']
        }

        # Insert data into DB
        db.connection_db(data=grade, query="insert", tablename="grades")

    return render_template("final_grade.html")
def new_projects():
    # Submit new project proposals
    if (request.method == 'POST'):

        suggestions = [{
            "sigla": request.form['sigla'],
            "nome_projeto": request.form['name'],
            "description": request.form['description']
        }]

        db.connection_db(data=suggestions,
                         query="insert",
                         tablename="orientador_suggestions")

    return render_template("project_suggestion.html")
Example #7
0
def papers_already_approved():

    if (request.method == 'POST'):
        # Search for approved projects
        approved_projects = db.connection_db(query="select",
                                             tablename="projetos")

    return render_template("approved.html", data=approved_projects)
Example #8
0
def submited_papers():
    # Show submited files
    if (request.method == 'GET'):
        projects = db.connection_db(query="select",
                                    tablename="projetos",
                                    public="false")

    return render_template("submited_projects.html", data=projects)
def public_projects():

    if (request.method == 'GET'):
        # Request approved projects
        approved_projects = db.connection_db(query="select",
                                             tablename="projetos",
                                             public="true")

    return render_template("publico.html", data=approved_projects)
Example #10
0
def login():
    global error
    if (request.method == 'POST'):
        # Check for empty inputs
        if (request.form['username'] == "" or request.form['password'] == ""):
            error = 'No credentials provided. Please try again.'
        else:
            # Student login
            if (request.form['username'].isnumeric()):
                authorization = db.connection_db(
                    data=[request.form['username'], request.form['password']],
                    query="search",
                    tablename="student")

                if (authorization == 1):
                    return redirect(url_for('aluno.personal_page'))
                elif (authorization == 0):
                    error = 'Invalid Credentials. Please try again.'
                    return render_template("login.html", error=error)

            # Conselour login
            if (request.form['username'].isnumeric() == False):
                if (request.form['username'] != diretor_username):
                    authorization = db.connection_db(data=[
                        request.form['username'], request.form['password']
                    ],
                                                     query="search",
                                                     tablename="orientador")

                    if (authorization == 1):
                        return redirect(url_for('orientador.orientador_page'))
                    elif (authorization == 0):
                        error = 'Invalid Credentials. Please try again.'
                        return render_template("login.html", error=error)

                # Administrator login
                elif (request.form['username'] == diretor_username
                      and request.form['password'] == diretor_password):
                    return redirect(url_for('diretor.diretor_page'))
                else:
                    return redirect(url_for('app.login'))

    return render_template("login.html", error=error)
def available_projects():

    projects = db.connection_db(query="select",
                                tablename="orientador_suggestions")
    return render_template("available_projects.html", data=projects)
Example #12
0
def approve_papers():
    if (request.method == 'GET'):
        # Search for projects with null status on DB
        result = db.connection_db(query="select", tablename="projetos")

    return render_template("for_approval.html", data=result)