Exemplo n.º 1
0
def employerEditLogo():
    if escape(session['type']) == 'employer':
        if request.method == 'GET':
            cid = adb.get_cid(escape(session['uname']))
            if os.path.isfile(os.path.join(app.config['UPLOAD_FOLDER'],
                                              "logo{}.jpg".format(cid))):
                return render_template('employereditlogo.html',
                                       imgpath=app.config['UPLOAD_FOLDER'] +
                                            "logo{}.jpg".format(cid), cid=cid)
            else:
                return render_template('employeraddlogo.html', cid=cid)


        if request.method == 'POST':
            #use the logged in uname(email) and position name
            #to create position in db module
            cid = adb.get_cid(escape(session['uname']))
            imgfile = request.files['img_file']
            if imgfile and allowed_image(imgfile.filename):
                fname = "logo{}.{}".format(cid, 'jpg')
                imgfile.save(os.path.join(app.config['UPLOAD_FOLDER'],
                                          fname))
                flash("Successfully added your logo!")
                return redirect('/Employer/Home')

            else:
                flash("Could not add image file")
                return redirect('/Employer/Home')

    return 'employer'
Exemplo n.º 2
0
def employerChangeDescription(iid):
    if escape(session['type']) == 'employer':
        cid = adb.get_cid(escape(session['uname']))

        if adb.check_ci_ids(cid, iid):
            if request.method == 'GET':
                if os.path.isfile(os.path.join(app.config['UPLOAD_FOLDER'],
                                                  "desc{}.txt".format(iid))):
                    txtfile = open(os.path.join(app.config['UPLOAD_FOLDER'],
                                              "desc{}.txt".format(iid)))

                    return render_template('employereditdescription.html',
                                           txt=txtfile.read())
                else:
                    return render_template('employeradddescription.html')


            if request.method == 'POST':
                #use the logged in uname(email) and position name
                #to create position in db module
                txtfile = request.files['txt_file']
                if txtfile and allowed_text(txtfile.filename):
                    fname = "desc{}.{}".format(iid, 'txt')
                    txtfile.save(os.path.join(app.config['UPLOAD_FOLDER'],
                                              fname))
                    flash("Successfully added your description!")
                    return redirect('/Employer/ViewInternships')

                else:
                    flash("Could not add your description.")
                    return redirect('/Employer/ViewInternships')

    return redirect('/Employer')
Exemplo n.º 3
0
def employerDeleteInt(iid):
    if escape(session['type']) == 'employer':
        cid = adb.get_cid(escape(session['uname']))

        if adb.check_ci_ids(cid, iid) and adb.int_isactive(iid):
            adb.int_makeinactive(iid)
            flash("Deleted your internship.")
            return redirect('/Employer/ViewInternships')

    return redirect('/Employer')
Exemplo n.º 4
0
def employerViewSpecificInt(iid):
    if escape(session['type']) == 'employer':
        cid = adb.get_cid(escape(session['uname']))

        if adb.check_ci_ids(cid, iid):
            studs = students_applied(iid)
            sname, iname = adb.get_name(iid=iid)

            return render_template('employerviewinternshipsiid.html', students=studs, iid=iid, posname=iname)

    return redirect('/Employer')
Exemplo n.º 5
0
def employerViewInt():
    if escape(session['type']) == 'employer':
        sid = request.args.get('sid')
        iid = request.args.get('iid')

        cid = adb.get_cid(escape(session['uname']))
        if sid and iid:
            if adb.check_ci_ids(cid, iid):
                adb.student_seen(sid, iid)
                flash('Student has been removed.')
                return redirect('/Employer/ViewInternships/{}'.format(iid))

        internlist = []
        for r in adb.view_cjoini_t():
            if r[2] == cid and r[8]:
                internlist.append(r)

        return render_template('employerviewinternships.html', internlist=internlist)

    return 'employer'
Exemplo n.º 6
0
def employerRegister():
    try: #if already logged in as employer go straight to home
        if escape(session['type']) == 'employer':
            return redirect('/Employer/Home')
    except:
        pass

    error = None
    if request.method == 'POST':
        #returns 0 if successful, 1 if username already taken
        #2 if passwords dont match up, 3 if email already taken/invalid
        flag = reg_employer(request.form['username'],
                            request.form['password'],
                            request.form['cpassword'],
                            request.form['email'])

        if not flag: #log in not implemented
            session['uname'] = request.form['email']
            session['type']  = "employer"

            imgfile = request.files['img_file']
            if imgfile and allowed_image(imgfile.filename):
                cid = adb.get_cid(escape(session['uname']))
                fname = "logo{}.{}".format(cid, 'jpg')
                imgfile.save(os.path.join(app.config['UPLOAD_FOLDER'],
                                          fname))
                flash("Successfully added your logo!")

            else:
                flash("Could not add logo")

            return log_employer_in('email')
        elif flag == 1:
            error = 'Invalid username/password'
        elif flag == 2:
            error = 'Invalid e-mail'
        elif flag == 3:
            error = 'Company or E-mail already in use!'

    return render_template('employerregister.html', error=error)