Exemplo n.º 1
0
def outputJobs(dbCursor):
    f = open("MyCollege_jobs.txt", "w+")
    # create list to be filled with jobs
    jobs = db.getAllJobs(dbCursor)
    for job in jobs:
        f.write(f"{job[1]}\n")  # Title
        f.write(f"{job[2]}\n")  # Description
        f.write(f"{job[3]}\n")  # Employer
        f.write(f"{job[4]}\n")  # Location
        f.write(f"{job[5]}\n")  # Author
        f.write("=====\n")
    f.close()
Exemplo n.º 2
0
def testFavoriteAJob(monkeypatch):
    connection = sqlite3.connect("incollege_test.db")
    cursor = connection.cursor()
    cursor.execute("DROP TABLE IF EXISTS Users") #delete tables to make sure no conflicts when running test multiple times
    cursor.execute("DROP TABLE IF EXISTS favorited_jobs")
    db.initTables(cursor)
    db.insertUser(cursor, "username1", "password", "first1", "last1", 0, "2020-01-01 12:30:00")
    db.insertUser(cursor, "username2", "password", "first2", "last2", 0, "2020-01-01 12:30:00")
    db.insertJob(cursor, "title1", "desc1", "emp1", "loc1", "sal1", "first1 last1")
    selectedJob = db.getAllJobs(cursor)[0]
    settings.signedInUname = "username2"
    monkeypatch.setattr("sys.stdin", StringIO("b\nz\n"))
    jobs.viewJobDetails(cursor, connection, selectedJob)
    assert len(db.getFavoriteJobsByUser(cursor, "username2")) == 1
Exemplo n.º 3
0
def testApplyForJob(monkeypatch):
    connection = sqlite3.connect("incollege_test.db")
    cursor = connection.cursor()
    cursor.execute("DROP TABLE IF EXISTS Users") #delete tables to make sure no conflicts when running test multiple times
    cursor.execute("DROP TABLE IF EXISTS user_job_applications")
    db.initTables(cursor)
    db.insertUser(cursor, "username1", "password", "first1", "last1", 0, "01/01/2020")
    db.insertUser(cursor, "username2", "password", "first2", "last2", 0, "01/01/2020")
    db.insertJob(cursor, "title1", "desc1", "emp1", "loc1", "sal1", "first1 last1")
    selectedJob = db.getAllJobs(cursor)[0]
    settings.signedInUname = "username2"
    monkeypatch.setattr("sys.stdin", StringIO("1\n01/01/1234\n01/02/1234\ncredentials\n"))
    jobs.applyForJob(cursor, connection, selectedJob)
    assert len(db.getAppliedJobs(cursor, "username2")) == 1
Exemplo n.º 4
0
def printJobsWithFilter(dbCursor, dbConnection, filterOption):
    while True:
        jobs = None
        title = ""
        if filterOption == 0:
            jobs = db.getAllJobs(dbCursor)
            title = "All Jobs:"
        elif filterOption == 1:
            jobs = db.getFavoriteJobsByUser(dbCursor, settings.signedInUname)
            title = "Favorite Jobs:"
        elif filterOption == 2:
            jobs = db.getAppliedJobs(dbCursor, settings.signedInUname)
            title = "Jobs Applied To:"
        elif filterOption == 3:
            jobs = db.getUnappliedJobs(dbCursor, settings.signedInUname)
            title = "Jobs Not Applied To:"

        print()
        if len(jobs) > 0:
            print(title)
            for i in range(len(jobs)):
                if len(db.getUserJobApplicationByTitle(dbCursor, settings.signedInUname, (jobs[i])[1])) > 0:  # if user has applied to this job
                    print(f"{i + 1}. {(jobs[i])[1]} (Applied)")
                else:
                    print(f"{i + 1}. {(jobs[i])[1]}")
        else:
            print("No jobs available under this filter.")
            return

        print("#. Choose one of the above jobs to view details")
        print("Z. Return to Previous Menu")

        while True:
            response = input("Input: ")
            if response.isdigit() and 1 <= int(response) <= len(jobs):
                selectedJob = jobs[int(response) - 1]
                viewJobDetails(dbCursor, dbConnection, selectedJob)
                break
            elif response.upper() == "Z":
                return
            else:
                print(constants.INVALID_INPUT)
Exemplo n.º 5
0
def outputAppliedJobs(dbCursor):
    f = open("MyCollege_appliedJobs.txt", "w+")

    # create list to be filled with jobs
    jobs = db.getAllJobs(dbCursor)

    for job in jobs:
        # get all applicants for this job
        applicants = db.getJobApplicationDetailsByTitle(dbCursor, job[1])

        # print job title and applicant info
        f.write(f"{job[1]}\n")  # Title

        # print details of any applicants
        if applicants is not None:
            for app in applicants:
                f.write(f"{app[0]}\n")  # applicant name
                f.write(f"{app[1]}\n")  # credentials

        # write job posting separator
        f.write("=====\n")
Exemplo n.º 6
0
def getAllJobs():
    allJobs = database.getAllJobs()
    return flask.jsonify(allJobs)
Exemplo n.º 7
0
def applicants(jobid):
    jobDet = database.getAllJobs()
    # print(jobDet)
    # print(jobDet[int(jobid)-1]['role'])
    jobname = jobDet[int(jobid)-1]['role']
    return flask.render_template('job_applicants.html', jobid=jobid, jobname=jobname)