Пример #1
0
def search_internship_by_name(name):
    try:
        with db.DbContext() as connection:
            cursor = connection.cursor()
            cursor.execute("select all from intrship where ename:", (name, ))
            row = cursor.fetchone()
            intern_pro_lst = [Internship(*row)]
            _view_internship_list(intern_pro_lst)
    except Exception as e:
        print(str(e))
Пример #2
0
def view_all_internships():
    try:
        with db.DbContext() as connection:
            cursor = connection.cursor()
            cursor.execute("select id,iname,company,i_year,status from internship")
            rows = cursor.fetchall()
            intern_pro_lst = [Internship(*row) for row in rows]
            _view_internship_list(intern_pro_lst)
    except Exception as e:
        print(str(e))
Пример #3
0
def search_internship_by_name(name):
    try:
        with db.DbContext() as connection:
            cursor = connection.cursor()
            cursor.execute(
                "select id,iname,company,i_year,status from internship where iname like ?",
                ('%' + name + '%', ))
            rows = cursor.fetchall()
            intern_pro_lst = [Internship(*row) for row in rows]
            _view_internship_list(intern_pro_lst)
    except Exception as e:
        print(f"{str(e)}")
Пример #4
0
def displayBusinessForm():
    if request.method == 'GET':
        return render_template('business-registration-form.html')

    elif request.method == 'POST':
        bname = request.form.get('bname')
        num_interns = request.form.get('num_interns')
        duration = request.form.get('duration')
        credits = request.form.get('credits')
        stipend = request.form.get('stipend')
        lang = request.form.get('lang')
        design = request.form.get('design')
        dbms = request.form.get('dbms')
        soft_skills = request.form.get('soft_skills')

        business = Business.query.filter_by(bname=bname).first()

        if business is None:
            new_business = Business(bname=bname,
                                    num_interns=num_interns,
                                    duration=duration,
                                    stipend=stipend,
                                    credits=credits,
                                    language=lang,
                                    design=design,
                                    dbms=dbms,
                                    soft_skills=soft_skills)

            db.session.add(new_business)
            db.session.commit()

            proj_name = request.form.get('proj_name')
            proj_descript = request.form.get('proj_descript')
            activities = request.form.get('activities')
            internship = Internship.query.filter_by(
                proj_name=proj_name).first()

            if internship is None:
                new_internship = Internship(
                    proj_name=proj_name,
                    proj_descript=proj_descript,
                    activities=activities,
                    business_ID=new_business.businessID)
            try:
                db.session.add(new_internship)
                db.session.commit()
                #return render_template('business-homepage.html')
                return redirect(url_for('displayBusinessForm'))
            except IntegrityError:
                return 'Application does not exist', render_template(
                    "business-registration.html"), 400
    return
Пример #5
0
def search_internship_by_name(name):
    try:
        with db.DbContext() as connection:
            cursor = connection.cursor()
            cursor.execute("SELECT id, iname, company, i_year, status FROM internship WHERE iname=?",(name,))
            rows = cursor.fetchall()
            if(rows):
                intern_pro_lst = [Internship(*row) for row in rows]
                _view_internship_list(intern_pro_lst)
            else:
                print(f"No internship found with name : {name} ")
    except Exception as e:
        print(str(e))
Пример #6
0
def change_status_internship(name):
    try:
        with db.DbContext() as connection:
            cursor = connection.cursor()
            stat = int(input("enter the status of the intership"))
            status = "completed" if stat == 0 else "run"
            cursor.execute(
                "update status where status =:(select iname from internship where iname :",
                (
                    status,
                    name,
                ))
            row = cursor.fetchone()
            intern_pro_lst = [Internship(*row)]
            _view_internship_list(intern_pro_lst)
    except Exception as e:
        print(str(e))
Пример #7
0
def internship():
    Entry = namedtuple(
        'Entry',
        ['organization', 'designation', 'start', 'end', 'text_description'])
    intern_value = Internship.load(current_user.id)
    if intern_value.intern_list:
        data = {'intern_list': []}
        for intern_dict in intern_value.intern_list:
            data['intern_list'].append(
                Entry(intern_dict['organization'], intern_dict['designation'],
                      intern_dict['start_date'], intern_dict['end_date'],
                      intern_dict['description']))
        form = InternshipListForm(data=data)
    else:
        form = InternshipListForm()
    if form.validate_on_submit():
        if form.add.data:
            if bool(form.organization.data) and bool(
                    form.designation.data) and bool(form.start.data) and bool(
                        form.end.data):
                intern_dict = {
                    'organization': form.organization.data,
                    'designation': form.designation.data,
                    'start_date': form.start.data,
                    'end_date': form.end.data,
                    'description': form.text_description.data
                }
                intern_value.add(intern_dict)
                flash('Internship added', 'success')
                commit()
            else:
                flash('Empty field', 'danger')
            return redirect(url_for('internship.internship'))
        else:
            for index in range(len(form.intern_list)):
                if form.intern_list[index].save.data:
                    if bool(
                            form.intern_list[index].organization.data
                    ) and bool(
                            form.intern_list[index].designation.data) and bool(
                                form.intern_list[index].start.data) and bool(
                                    form.intern_list[index].end.data):
                        intern_dict = {
                            'organization':
                            form.intern_list[index].organization.data,
                            'designation':
                            form.intern_list[index].designation.data,
                            'start_date':
                            form.intern_list[index].start.data,
                            'end_date':
                            form.intern_list[index].end.data,
                            'description':
                            form.intern_list[index].text_description.data
                        }
                        intern_value.update(index, intern_dict)
                        commit()
                        flash('Updated successfully', 'success')
                    else:
                        flash('Empty field', 'danger')
                    return redirect(url_for('internship.internship'))
                if form.intern_list[index].delete.data:
                    intern_value.delete(index)
                    commit()
                    flash('Deleted successfully', 'success')
                    return redirect(url_for('internship.internship'))
    return render_template('internship.html', form=form)