Ejemplo n.º 1
0
	def post(self):

		json = request.json
		abort_if_invalid_request_params(json, ['user', 'degree', 'organization', 'date_start', 'date_end', 'country'])

		education = Education()
		education.user = ObjectId(json['user'])			
		education.degree = json['degree']
		education.organization = json['organization']
		education.date_start = json['date_start']
		education.date_end = json['date_end']
		education.country = json['country']
		
		education.save()
		return me_obj_to_serializable(education)
Ejemplo n.º 2
0
    def setUp(self):

        Info.query.delete()
        Education.query.delete()
        Population.query.delete()
        Poverty.query.delete()

        information = Info(county='Butler County',
                           state='Ohio',
                           county_code='017',
                           state_code=39,
                           joint_code=39017)
        education = Education(county_code='017', state_code=39, ed_pop=54151)
        population = Population(county_code='017',
                                state_code=39,
                                pop=384134,
                                pop_den=821)
        poverty = Poverty(county_code='017', state_code=39, pov=11.7)

        db.session.add_all([information, education, population, poverty])
        db.session.commit()

        self.information = information
        self.education = education
        self.population = population
        self.poverty = poverty
Ejemplo n.º 3
0
	def get(self):
		args = request.args

		if 'id' in args:
			return me_obj_to_serializable(Education.objects.get(id=args['id']))
		elif 'user' in args:
			return me_obj_to_serializable(Education.objects(user=args['user']))
		else:
			return me_obj_to_serializable(Education.objects)
Ejemplo n.º 4
0
def dash():
    if request.method == 'POST':
        #take data from form and put into database
        #TODO(rushiagr): do session expire check here
        user_personal_info = UserPersonalInfo(
            email=session.get('userEmail'),
            name=request.form.get('name'),
            title=request.form.get('position'),
            location=request.form.get('location'),
            summary=request.form.get('summary'),
        )
        user_personal_info.put()
        experience = Experience(
            email=session.get('userEmail'),
            position=request.form.get('experience_role'),
            description=request.form.get('experience_description'),
        )
        experience.put()
        projects = Projects(
            email=session.get('userEmail'),
            project_name=request.form.get('project_name'),
            description=request.form.get('project_description'),
        )
        projects.put()
        education = Education(
            email=session.get('userEmail'),
            duration=request.form.get('education_duration'),
            program=request.form.get('education_program'),
            institution=request.form.get('education_institution'),
            score_achieved=request.form.get('education_score'),
            score_out_of='10',
        )
        education.put()
        return render_template('profile.html',
                               session_user=session.get('userEmail'),
                               user_personal_info=user_personal_info,
                               experience=experience,
                               projects=projects,
                               education=education)
        
    elif request.method == 'GET':
        return render_template('edit_profile.html', session_user=session.get('userEmail'))
Ejemplo n.º 5
0
	def save(self, employer):
		data=self.cleaned_data
		if data['edu_id']:
			edu=Education.objects.filter(id=data['edu_id'])
			if edu:
				edu = edu[0]
				edu.higher_specification = data['higher_specification']
				edu.higher_year = data['higher_year']
				edu.secondary_specification = data['secondary_specification']
				edu.secondary_year = data['secondary_year']
				edu.graduation = data['graduation']
				edu.year = data['year']
				edu.university = data['university']
				edu.save()
		else:
			edu = Education(employer = employer, higher_specification = data['higher_specification'],
				higher_year = data['higher_year'] ,secondary_specification = data['secondary_specification'], 
				secondary_year = data['secondary_year'], graduation = data['graduation'],
				year = data['year'], university = data['university'])
			edu.save()
		return True
Ejemplo n.º 6
0
def add_education():
    if request.method == 'POST':
        education = get_education()
        school = Education(school=request.form['school'],
                           degree=request.form['degree'],
                           major=request.form['major'],
                           location=request.form['location'],
                           start_year=request.form['start_year'],
                           end_year=request.form['end_year'],
                           bullet_1=request.form['bullet_1'],
                           bullet_2=request.form['bullet_2'],
                           bullet_3=request.form['bullet_3']
                           )
        session.add(school)
        session.commit()
        return redirect(url_for('home'))
    else:
        return render_template('modifyEducation.html', type='add')
Ejemplo n.º 7
0
def add_education():
    education_query = Education.query.filter_by(general_id=current_user.id)
    form = EducationForm()
    if request.method == "POST" and form.validate_on_submit():
        ed_query_count = 1
        if education_query:
            ed_query_count = education_query.count() + 1
        new_education = Education(
            school=form.school.data,
            time=form.time.data,
            degree=form.degree.data,
            general=current_user,
            order_ed=ed_query_count,
        )
        db.session.add(new_education)
        db.session.commit()
        return redirect(url_for("main_page.home") + "#Education")

    return render_template("form_page.html", form=form, title="Education")
Ejemplo n.º 8
0
    def add_education():
        data = request.json
        print(data)
        if ((data.get('name', '') == '') or (data.get('system_id', '') == '')):
            abort(422)
        try:
            education = Education(name=data.get('name'))
            education.system_id = data.get('system_id')
            education.rank = data.get('rank')
            education.insert()
        except Exception:
            abort(422)

        return jsonify({'message': 'success', 'id': education.id})
Ejemplo n.º 9
0
def handle_education():
    """
    Create education and retrieve it all
    """

    # POST request
    if request.method == 'POST':
        body = request.get_json()

        if body is None:
            raise APIException(
                "You need to specify the request body as a json object",
                status_code=400)
        if 'school' not in body:
            raise APIException('You need to specify the school',
                               status_code=400)
        if 'degree' not in body:
            raise APIException('You need to specify the degree',
                               status_code=400)

        education1 = Education(school=body['school'],
                               degree=body['degree'],
                               course=body['course'],
                               fromDate=body['fromDate'],
                               toDate=body['toDate'],
                               resume=body['resume'],
                               user_id=body["user_id"])

        db.session.add(education1)
        db.session.commit()
        return "ok", 200

    # GET request
    if request.method == 'GET':
        all_education = Education.query.all()
        all_education = list(map(lambda x: x.serialize(), all_education))
        return jsonify(all_education), 200

    return "Invalid Method", 404
Ejemplo n.º 10
0
from app import app
from models import db, Info, Education, Population, Poverty
from flask import request

# Use test database and don't clutter tests with SQL
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql:///covid_test'
app.config['SQLALCHEMY_ECHO'] = False

# Make Flask errors be real errors, rather than HTML pages with error info
app.config['TESTING'] = True

db.drop_all()
db.create_all()

# Setting up inital values
ed = Education(county_code='017', state_code=39, ed_pop=51551)
population = Population(county_code='017',
                        state_code=39,
                        pop=383134,
                        pop_den=821)
poverty = Poverty(county_code='017', state_code=39, pov=10)


class informationTestCase(TestCase):
    def setUp(self):

        Info.query.delete()
        Education.query.delete()
        Population.query.delete()
        Poverty.query.delete()
Ejemplo n.º 11
0
from datetime import date

from models import Education


college = Education(
    institution='Reed College',
    attained_level='BA Physics',
    start=date(2009, 8, 30),
    end=date(2013, 5, 16),
    description='Senior thesis subsequently published -- Jones-Smith, K. & Wallace, C. Int J Theor Phys (2015) 54: 219.'
)

print college.render()
Ejemplo n.º 12
0
def cv(user):
    # quick check to make sure the user actually exists
    resp = fluid.get('/users/%s' % user)
    if resp.status_code == 404:
        abort(404)
    person_rpc = Person.filter('fluiddb/users/username="******"', user, async=True)
    # check for person's picture
    #logging.debug('Checking for %s/picture at %s' % (user, person.picture))
    #h = httplib2.Http()
    #head, cont = h.request(person.picture, 'HEAD')
    #if head['status'] == '200':
    #    person.has_pic = True
    #    logging.debug('%s/picture exists' % user)
    #else:
    #    person.has_pic = False
    #    logging.debug('%s/picture does not exist. Returned %s status' % (
    #        user, head['status']))
    # find user's jobs
    work_rpc = Work.filter('has %s/employer', user, async=True)
    # find user's schools
    school_rpc = Education.filter('has %s/attended', user, async=True)
    # find user's publications
    #publications = fluid_filter('has %s/publication' % user)
    #publications = [Publication(uid, user) for uid in publications]
    publications = []
    # find user's skills associated with o'reilly books
    oskill_rpc = OReillySkill.filter(
            'has %s/skill and has %%s/title' % user, 'oreilly.com', async=True)

    resp = fluid.result(person_rpc)
    logging.info('Person filter for %s returned %d' % (user, resp.status_code))
    if resp.status_code == 200 and resp.content['results']['id']:
        [(uid, tags)] = resp.content['results']['id'].items()
        person = Person(uid, user, tags)
    else:
        abort(404)

    resp = fluid.result(work_rpc)
    logging.info('Work filter for %s returned %d' % (user, resp.status_code))
    if resp.status_code == 200 and resp.content['results']['id']:
        resp = resp.content['results']['id']
        jobs = Work.from_response(user, resp)
    else:
        #FIXME need better error handling
        jobs = []

    resp = fluid.result(school_rpc)
    logging.info('School filter for %s returned %d' % (user, resp.status_code))
    if resp.status_code == 200 and resp.content['results']['id']:
        resp = resp.content['results']['id']
        schools = Education.from_response(user, resp)
    else:
        schools = []

    resp = fluid.result(oskill_rpc)
    logging.info('Skill filter for %s returned %d' % (user, resp.status_code))
    if resp.status_code == 200 and resp.content['results']['id']:
        resp = resp.content['results']['id']
        oskills = OReillySkill.from_response(resp)
    else:
        oskills = []

    return render_template('cv.html', person=person, jobs=jobs,
                           schools=schools, publications=publications,
                           oskills=oskills,
                           current_date=datetime.now().date())
Ejemplo n.º 13
0
def edit(user):
    person = fluid_filter('fluiddb/users/username="******"' % user)
    if not person:
        abort(404)
    form = ResumeForm()
    person = Person(person[0], user)
    jobs = fluid_filter('has %s/employer' % user)
    jobs = [Work(uid, user) for uid in jobs]
    for job in jobs:
        form.jobs.append_entry()
        # join functions list to paragraph
        job.functions = r"\n".join(job.functions).strip()

    schools = fluid_filter('has %s/attended' % user)
    schools = [Education(uid, user) for uid in schools]
    for school in schools:
        form.schools.append_entry()

    if form.validate_on_submit():
        denied = False
        logging.debug('Valid form for %s' % user)
        password = form.person.password.data

        if not person.update_from_form(form.person):
            denied = True

        for job_form in form.jobs:
            # it seems that we get 1 or more phantom jobs here...
            if not job_form.url.data:
                continue
            # this seems kinda weird, but I'm not sure of a better way to
            # find the correct work object yet
            found_job = False
            logging.info("working on job: %s" % job_form.url.data)
            for job in jobs:
                if job.about == job_form.url.data:
                    if not job.update_from_form(job_form, password):
                        denied = True
                    found_job = True

            if not found_job:
                job = Work.create(job_form.url.data, user)
                if not job.update_from_form(job_form, password):
                    denied = True

        for school_form in form.schools:
            # it seems that we get 1 or more phantom schools here...
            if not school_form.url.data:
                continue
            # this seems kinda weird, but I'm not sure of a better way to
            # find the correct work object yet
            found_school = False
            logging.info("working on school: %s" % school_form.url.data)
            for school in schools:
                if school.about == school_form.url.data:
                    if not school.update_from_form(school_form, password):
                        denied = True
                    found_school = True

            if not found_school:
                school = Education.create(school_form.url.data, user)
                if not school.update_from_form(school_form, password):
                    denied = True

        if form.skills.data:
            OReillySkill.update_from_form(form.skills, user, password)

        if denied:
            flash("Permission Denied!", category='error')
        else:
            flash("Success!", category='info')

        # gotta reload the attributes to show changes
        person.reload_tags()
        for job in jobs:
            job.reload_tags()
        for school in schools:
            school.reload_tags()

    skills = fluid_filter('has %s/skill' % user)
    skills = [OReillySkill(uid) for uid in skills]
    skill_list = json.dumps([{'id'   : skill.uid,
                              'name' : skill.title}
                             for skill in skills])

    return render_template('edit.html', person=person, jobs=jobs,
                           schools=schools, form=form, user=user,
                           skill_list=skill_list)
Ejemplo n.º 14
0
def get_models(row):
    """
    """
    judge_row = Judge(
        **{
            slug_col: clean_data(slug_col, row[col])
            for col, slug_col in column_name_maps.demographic_col_map.items()
        })

    # A judge can have multiple appointments. There are a lot of columns associated with an appointment
    # and they are in the data as "<Column Description (N)>", go through and link all of these
    # together. There is no way of knowning how many (N) a judge may have and it's not sufficient to
    # just look for one column that has data, so loop through and look if _any_ of the appointment
    # pattern columns have data up to the MAX_DUP_COLS appointment.
    for i in range(1, MAX_DUP_COLS):
        appointment_dict = {}
        for col, slug_col in column_name_maps.appt_col_map.items():
            appt_row_val = row.get(_get_column_pattern(col, i))
            if appt_row_val:
                appointment_dict[slug_col] = clean_data(slug_col, appt_row_val)
        if len(appointment_dict) == 0:
            continue

        # In case there are multiple start dates due to bad data, assume the earliest
        appointment_dict['start_date'] = min(
            appointment_dict[date_col]
            for date_col in column_name_maps.START_DATE_COLUMNS_TO_PARSE
            if appointment_dict.get(date_col))

        appointment_dict['start_year'] = datetime.strptime(
            appointment_dict['start_date'], DATE_FORMAT).year

        # Multiple columns indicate a judgeship ending, take the min of them if duplicates.
        potential_end_dates = [
            appointment_dict[date_col]
            for date_col in column_name_maps.END_DATE_COLUMNS_TO_PARSE
            if appointment_dict.get(date_col)
        ]

        # Empty list means still in job
        if not potential_end_dates:
            appointment_dict['end_date'] = None
        else:
            appointment_dict['end_date'] = min(potential_end_dates)

        if appointment_dict['end_date']:
            appointment_dict['end_year'] = datetime.strptime(
                appointment_dict['end_date'], DATE_FORMAT).year
        else:
            appointment_dict['end_year'] = None

        if appointment_dict.get('confirmation_date') and appointment_dict.get(
                'nomination_date'):
            timedelta_to_confirm = (
                datetime.strptime(appointment_dict['confirmation_date'],
                                  DATE_FORMAT) -
                datetime.strptime(appointment_dict['nomination_date'],
                                  DATE_FORMAT))
            appointment_dict['days_to_confirm'] = timedelta_to_confirm.days
        else:
            appointment_dict['days_to_confirm'] = None

        judge_row.appointments.append(Appointment(**appointment_dict))

    education_dict = defaultdict(dict)
    for i in range(1, MAX_DUP_COLS):
        for col, slug_col in column_name_maps.edu_col_map.items():
            edu_row_val = row.get(_get_column_pattern(col, i))
            if edu_row_val:
                education_dict[i][slug_col] = clean_data(slug_col, edu_row_val)
        if len(education_dict[i]) == 0:
            education_dict.pop(i)
            continue
        judge_row.educations.append(Education(**education_dict[i]))

    return judge_row
from models import engine, db_session, Base, Basic, Education, Occupation, Household, Foodandbeverage, Hobbiesandinterests
Base.metadata.create_all(bind=engine)

melanie = Basic(name='Melanie', age=34, gender='female')
db_session.add(melanie)
degree = Education(highestdegree='Masters',
                   areaofstudy='Petroleum Engineering',
                   basic=melanie)
db_session.add(degree)
job = Occupation(organization='ExxonMobil',
                 employeedepartment='Petrophysics',
                 employeeprimaryrole='Data Analyst',
                 basic=melanie)
db_session.add(job)
house = Household(numberofpersonsinhome=3,
                  maritalstatus='Married',
                  numberofchildren=1,
                  accomodationtype='Apartment',
                  income='over 120,000',
                  basic=melanie)
db_session.add(house)
foods = Foodandbeverage(fastfoodweeklyfrequency=0,
                        alcoholweeklyfrequency=3,
                        restaurantweeklyfrequency=3,
                        basic=melanie)
db_session.add(foods)
hobbies = Hobbiesandinterests(cinemaweeklyfrequency=1,
                              exerciseweeklyfrequency=5,
                              favoritemusicgenre='rock',
                              basic=melanie)
db_session.add(hobbies)
Ejemplo n.º 16
0
    def post(self, request, *args, **kwargs):

        educational_details = ast.literal_eval(request.POST['educational_details'])
        status = 200
        if educational_details['id']:
            job_seeker = Jobseeker.objects.get(id=educational_details['id'])
            if job_seeker.education:
                education = job_seeker.education
            else:
                education = Education()
            education.basic_edu = educational_details['basic_edu']
            education.basic_edu_specialization = educational_details['basic_specialization']
            education.pass_year_basic = int(educational_details['pass_year_basic'])
            if educational_details['masters_edu'] != "":
                education.masters = educational_details['masters_edu']
                if educational_details['master_specialization'] != "":
                    education.masters_specialization = educational_details['master_specialization']
                if educational_details['pass_year_masters'] != "":
                    education.pass_year_masters = int(educational_details['pass_year_masters'])
            else:
                education.masters = ''
                education.masters_specialization = ''
                education.pass_year_masters = None
            doctrate = ast.literal_eval(educational_details['doctrate'])
            education.save()
            if education.doctrate:
                education.doctrate.clear()
            for doctrate_name in doctrate:
                if len(doctrate_name['name']) > 0 and not doctrate_name['name'].isspace():
                    doctorate, created = Doctorate.objects.get_or_create(doctorate_name = doctrate_name['name'])
                    education.doctrate.add(doctorate)
            education.save()
            job_seeker.education = education
            job_seeker.save()
            res = {
                'result': 'ok',
                'job_seeker_id': job_seeker.id,
            }
            response = simplejson.dumps(res)
            return HttpResponse(response, status=status, mimetype='application/json')