コード例 #1
0
def editFAQConfirm():

    if request.method == 'GET':
        try:
            if not session['userName']:

                return render_template("error.html")

        except KeyError:

            return render_template("error.html")

    #Prevents non-admins from reaching upload screen.  Will update with Jeanne's credentials when they are created.
    if check_admin() == False:

        return render_template("autherror.html")

    announcement_result = pg.get_five_announcements()
    isAdmin = check_admin()

    ID = request.form['id'][3:-3]
    now = 'now()'

    pg.edit_FAQ(request.form['title'], request.form['announcement'], ID)

    return render_template("help_screen.html",
                           announcements=announcement_result,
                           admin=isAdmin)
コード例 #2
0
def updatePasswordPage():

    isAdmin = check_admin()

    if request.method == 'POST':

        announcement_result = pg.get_five_announcements()

        if request.form['password1'] != request.form['password2']:

            return render_template('passwordchange.html',
                                   announcements=announcement_result,
                                   admin=isAdmin)

        else:

            pg.change_password(request.form['password2'], session['userName'])

            name = pg.get_name(session['userName'], request.form['password2'])

            return render_template("index.html",
                                   logged=name,
                                   announcements=announcement_result,
                                   admin=isAdmin)

    else:

        return render_template("error.html")
コード例 #3
0
def removeFAQ():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':

        return render_template("error.html")

    #Prevents non-admins from reaching upload screen.  Will update with Jeanne's credentials when they are created.
    if check_admin() == False:

        return render_template("autherror.html")

    announcement_result = pg.get_five_announcements()
    isAdmin = check_admin()

    print(request.form['remove'])
    name = pg.get_name(session['userName'], session['passWord'])

    ID = request.form['remove']
    ID = (ID, )

    pg.delete_FAQ(ID)

    return render_template('help_screen.html',
                           logged=name,
                           announcements=announcement_result,
                           admin=isAdmin)
コード例 #4
0
def viewChecklist():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':
        try:
            if not session['userName']:

                return render_template("error.html")

        except KeyError:

            return render_template("error.html")

    announcement_result = pg.get_five_announcements()
    isAdmin = check_admin()

    fname = pg.get_name(session['userName'], session['passWord'])
    lname = pg.get_last_name(session['userName'], session['passWord'])

    fname = unicode(fname)[2:-2]
    lname = unicode(lname)[2:-2]

    print(fname + " " + fname)

    searchedResults = pg.search_checklist(fname, lname)

    return render_template("studentchecklistview.html",
                           announcements=announcement_result,
                           admin=isAdmin,
                           searched=searchedResults)
コード例 #5
0
def searchResultsPage():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':

        return render_template('error.html')

    if request.method == 'POST':

        announcement_result = pg.get_five_announcements()
        isAdmin = check_admin()

        name_to_search = request.form['fname']

        lname_to_search = request.form['lname']

        name_to_search = name_to_search.title()
        lname_to_search = lname_to_search.title()

        #email_to_search = request.form['email']
        searchedResults = pg.search_checklist(name_to_search, lname_to_search)

        if not searchedResults:

            return render_template('search.html',
                                   announcements=announcement_result,
                                   admin=isAdmin,
                                   searched=searchedResults)

        else:

            return render_template('adminchecklistview.html',
                                   announcements=announcement_result,
                                   admin=isAdmin,
                                   searched=searchedResults)
コード例 #6
0
def searchChecklist():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':
        try:
            if not session['userName']:

                return render_template("error.html")

        except KeyError:

            return render_template("error.html")

    #Prevents non-admins from reaching upload screen.  Will update with Jeanne's credentials when they are created.
        if check_admin() == False:

            return render_template("autherror.html")

    #TODO: Populate the html with this data
    announcement_result = pg.get_five_announcements()
    isAdmin = check_admin()

    return render_template('search.html',
                           announcements=announcement_result,
                           admin=isAdmin)
コード例 #7
0
def bugReport():

    if request.method == 'GET':
        try:
            if not session['userName']:

                return render_template("error.html")
        except KeyError:
            return render_template("error.html")
    announcement_result = pg.get_five_announcements()
    isAdmin = check_admin()

    return render_template("bugreport.html",
                           announcements=announcement_result,
                           admin=isAdmin)
コード例 #8
0
def FAQPosted():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':

        return render_template("error.html")

    announcement_result = pg.get_five_announcements()

    pg.post_FAQ(request.form['question'], request.form['answer'])
    isAdmin = check_admin()

    return render_template('FAQposted.html',
                           announcements=announcement_result,
                           admin=isAdmin)
コード例 #9
0
def announcementsPosted():

    now = "now()"

    if request.method == 'GET':

        return render_template("error.html")

    announcement_result = pg.get_five_announcements()

    pg.post_announcement(now, request.form['title'],
                         request.form['announcement'])
    isAdmin = check_admin()

    return render_template('announcementposted.html',
                           announcements=announcement_result,
                           admin=isAdmin)
コード例 #10
0
def landingPage():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':
        try:
            if not session['userName']:

                return render_template("error.html")

        except KeyError:

            return render_template("error.html")

    #Creating the current session
    if request.method == 'POST':

        session['userName'] = request.form['username']
        session['passWord'] = request.form['password']

    if 'userName' in session:
        user = [session['userName'], session['passWord']]

    else:
        user = ['', '']

    print(session['userName'] + " Has logged in")

    result = pg.get_login(session['userName'], session['passWord'])

    isAdmin = check_admin()

    announcement_result = pg.get_five_announcements()

    if not result:

        session['userName'] = ''
        session['passWord'] = ''
        return render_template('login.html')

    name = pg.get_name(session['userName'], session['passWord'])

    return render_template('index.html',
                           logged=name,
                           announcements=announcement_result,
                           admin=isAdmin)
コード例 #11
0
def updatePasswordFormPage():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':
        try:
            if not session['userName']:

                return render_template("error.html")

        except KeyError:

            return render_template("error.html")

    announcement_result = pg.get_five_announcements()
    isAdmin = check_admin()

    return render_template('passwordchange.html',
                           announcements=announcement_result,
                           admin=isAdmin)
コード例 #12
0
def helpPage():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':
        try:
            if not session['userName']:

                return render_template("error.html")

        except KeyError:

            return render_template("error.html")

    announcement_result = pg.get_five_announcements()
    FAQ_result = pg.get_FAQ()
    isAdmin = check_admin()

    return render_template('help_screen.html',
                           announcements=announcement_result,
                           FAQ=FAQ_result,
                           admin=isAdmin)
コード例 #13
0
def editFAQ():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':
        try:
            if not session['userName']:

                return render_template("error.html")

        except KeyError:

            return render_template("error.html")

    #Prevents non-admins from reaching upload screen.  Will update with Jeanne's credentials when they are created.
    if check_admin() == False:

        return render_template("autherror.html")

    announcement_result = pg.get_five_announcements()
    isAdmin = check_admin()

    ID = request.form['edit']
    ID = (ID, )

    title = pg.get_faq_question(ID)
    message = pg.get_faq_answer(ID)

    title = unicode(title)[3:-3]
    message = unicode(message)[3:-3]

    return render_template('editFAQ.html',
                           announcements=announcement_result,
                           admin=isAdmin,
                           t=title,
                           m=message,
                           edit=ID)
コード例 #14
0
def uploadPage():

    #Prevents page from being rendered unless it is being accessed through a valid session
    if request.method == 'GET':

        try:
            if not session['userName']:

                return render_template("error.html")

        except KeyError:

            return render_template("error.html")

        #Prevents non-admins from reaching upload screen.  Will update with Jeanne's credentials when they are created.
        if session['userName'] != "*****@*****.**" and session[
                'userName'] != "*****@*****.**" and session[
                    'userName'] != "*****@*****.**" and session[
                        'userName'] != "*****@*****.**":

            return render_template("autherror.html")

    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            flash('No file part')
            return redirect(request.url)
        file = request.files['file']

        # if user does not select file, browser also
        # submit a empty part without filename
        if file.filename == '':

            flash('No selected file')

            return redirect(request.url)

        if file and allowed_file(file.filename):

            filename = secure_filename(file.filename)

            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

            replace_first_line(
                "/home/ubuntu/workspace/CSVFiles/" + filename,
                "/home/ubuntu/workspace/CSVFiles/cleanedCSV.csv",
                "LastName,FirstName,ID,email,Admitted,duPontCode,Status,Term,CoCur1,Date1,FSEMHN,FSEMDate,HNcourse1,HN1Date,HNcourse2,HN2Date,HNcourse3,HN3Date,HNcourse4,HN4Date,HNcourse5,HN5Date,ResearchCourse,ResearchDate,CapstoneCourse,CapstoneDate,HONR201,HONR201Date,Leadership,mentoring,HONRPortfolio4,HONRPortfolio1,HONRPortfolio2,HONRPortfolio3,ExitInterview"
            )

            subprocess.call([
                "sed", "-i", 's/\r//',
                '/home/ubuntu/workspace/CSVFiles/cleanedCSV.csv'
            ])

            pg.import_csv()

            #WARNING.  IF THE LINE BELOW THIS AR UNCOMMENTED THEY WILL SEND EMAILS TO ALL STUDENTS IN THE CSV FILE UPON SUCCESSFUL UPLOAD.  MAKE SURE IT IS COMMENTED OUT WHEN TESTING CSV UPLOADING, OR USE A SEPARATE CSV FILE.

    announcement_result = pg.get_five_announcements()
    isAdmin = check_admin()

    return render_template('upload.html',
                           announcements=announcement_result,
                           admin=isAdmin)