Ejemplo n.º 1
0
 def test_company_3(self):
     y = Year(1986)
     db.session.add(y)
     c = Company(1, "Bethesda Softworks", 11, None, 66, 8.9, 1986)
     c2 = Company(2, "Bethesda Softworks", 11, None, 66, 8.9, 1986)
     db.session.add(c)
     self.assertTrue(c in db.session)
     self.assertFalse(c2 in db.session)
     db.session.remove()
Ejemplo n.º 2
0
def do_create_company(name: str,
                      email: str,
                      registered_name: str,
                      address: str,
                      type: int = Company.PRIVATE) -> Optional[Company]:
    try:
        company = Company(name=name,
                          email=email,
                          registered_name=registered_name,
                          address=address,
                          type=type)
        company.save()
    except Error:
        return None
    return company
Ejemplo n.º 3
0
 def test_company_2(self):
     y = Year(1986)
     db.session.add(y)
     c = Company(1, "Bethesda Softworks", 11, None, 66, 8.9, 1986)
     y2 = Year(1994)
     db.session.add(y2)
     c2 = Company(2, "Blizzard Entertainment", 20, None, 40, 9, 1994)
     y3 = Year(1980)
     db.session.add(y3)
     c3 = Company(3, "Activision", 10, None, 1000, 6, 1980)
     db.session.add(c)
     db.session.add(c2)
     db.session.add(c3)
     db.session.commit()
     q = Company.query.all()
     self.assertEqual(len(q), 3)
     db.session.remove()
Ejemplo n.º 4
0
 def test_company_1(self):
     y = Year(1986)
     db.session.add(y)
     c = Company(1,"Bethesda Softworks", 11, None, 66, 8.9, 1986)
     db.session.add(c)
     db.session.commit()
     self.assertTrue(c in db.session)
     db.session.remove()
Ejemplo n.º 5
0
def add_company():
    form = CompanyForm()
    if request.method == 'GET':
        return render_template('add_company.html', form=form)
    else:
        if form.validate_on_submit():
            company = Company(name=form.company_name.data)
            db.session.add(company)
            db.session.commit()
            return redirect(url_for('index'))
        else:
            return jsonify({'message': 'Something went wrong'})
Ejemplo n.º 6
0
def add_companies(companies, game):
	global company_cache
	global year_cache
	for company in companies:
		c={}
		company_to_update = None
		company_id = company["id"]
		if company_id in company_cache:
			company_to_update = Company.query.filter_by(company_id = company_id).first()
			if company["developer"]:
				company_to_update.num_developed += 1
			if company["publisher"]:
				company_to_update.num_published += 1
			db.session.commit()
		else:
			company_cache.add(company_id)
			c["company_id"] = company_id
			c["name"] = company["name"]
			c["num_developed"] = 1 if company["developer"] else 0
			c["num_published"] = 1 if company["publisher"] else 0
			url_specific_company = "https://www.igdb.com/api/v1/companies/" + str(company_id)
			r = requests.get(url_specific_company, params = header)
			company_info = r.json()["company"]
			if "founded_year" in company_info:
				year = company_info["founded_year"]
				c["year_founded"] = year

				if(year not in year_cache):
					y = Year(year)
					db.session.add(y)
					year_cache+= [year]

			if "average_rating" in company_info:
				c["avg_rating"] = company_info["average_rating"]
			else:
				c["avg_rating"] = 0.0

			if "company_logo" in company_info:
				c["image_url"] = "https:" + company_info["company_logo"]["url"]
			company_to_update = Company(**c)
			db.session.add(company_to_update)

		game.associated_companies.append(company_to_update)
Ejemplo n.º 7
0
def inject_test_data():

    if not Project.query.all():

        # projects
        project1 = Project(
            published=True,
            demo=True,
            title="Online Picure Converter (React)",
            description="""
            <h1>Project Description</h1>
            <p>
            We need a developer to create an online picture
            converter that will be able to convert images
            into different formats.
            </p>
            <p>
            This project needs to be built with React and needs
            to be a single page application (SPA).
            </p>
            """,
            link="https://letsconvert.app",
            created_at=get_unix(),
            modified_at=get_unix(),
        )
        project2 = Project(
            published=True,
            demo=True,
            title="Babysitting Booking Platform",
            description="""
            <h1>Project Description</h1>
            <p>
            We need a developer to migrate our existing buggy
            wordpress website to a new framework that is faster,
            more efficient, and can handle our increasing sales.
            </p>
            <p>
            Our company is an on-demand babysitter booking service
            that needs to allow users to book with real-time 
            availabilities and babysitter schedules.
            </p>
            """,
            link="https://kiid.ca/en",
            created_at=get_unix() + 1,
            modified_at=get_unix() + 1,
        )
        project3 = Project(
            published=True,
            demo=True,
            title="Persian Carpets Store CMS",
            description="""
            <h1>Project Description</h1>
            <p>
            We need a developer to build a custom CMS system
            that integrates with our existing protocols and
            ways of doing things.
            </p>
            <p>
            Our existing website is built on a framwork from
            1999 and is no longer performing adequately.
            We need something newer, better that can integrate
            with our existing inventory and procedures.
            </p>
            """,
            link="https://bashircarpets.com",
            created_at=get_unix() + 2,
            modified_at=get_unix() + 2,
        )
        project4 = Project(
            published=True,
            demo=True,
            title="Online 3D Art Gallery",
            description="""
            <h1>Project Description</h1>
            <p>
            We need a developer to build a 3D art gallery that
            will allow artists to upload their artworks and
            buyers to purchase them / view them in 3D.
            </p>
            <p>
            We also need a custom CMS solution to manage these
            artists and artworks, as well as a way to post events
            and have users be able to RSVP to the events they want
            to participate to.
            </p>
            """,
            restrictions="Europe Only",
            link="https://st-artamsterdam.com",
            created_at=get_unix() + 3,
            modified_at=get_unix() + 3,
        )

        db.session.add(project1)
        db.session.add(project2)
        db.session.add(project3)
        db.session.add(project4)

        # company
        company1 = Company(
            name="Let's Convert",
            location="International",
            email="*****@*****.**",
            logo="/assets/img/companies/logo-placeholder.png",
            created_at=get_unix(),
            modified_at=get_unix(),
        )
        company2 = Company(
            name="Kiid Babysitting",
            location="Montreal, Canada",
            email="*****@*****.**",
            logo="/assets/img/companies/logo-placeholder.png",
            created_at=get_unix() + 1,
            modified_at=get_unix() + 1,
        )
        company3 = Company(
            name="Bashir Persian Rugs",
            location="Montreal, Canada",
            email="*****@*****.**",
            logo="/assets/img/companies/logo-placeholder.png",
            created_at=get_unix() + 2,
            modified_at=get_unix() + 2,
        )
        company4 = Company(
            name="St-Art Amsterdam",
            location="Amsterdam, Netherlands",
            email="*****@*****.**",
            logo="/assets/img/companies/logo-placeholder.png",
            created_at=get_unix() + 3,
            modified_at=get_unix() + 3,
        )

        db.session.add(company1)
        db.session.add(company2)
        db.session.add(company3)
        db.session.add(company4)

        company1.projects.append(project1)
        company2.projects.append(project2)
        company3.projects.append(project3)
        company4.projects.append(project4)

        # tags
        tag1 = Tag(
            name="react",
            created_at=get_unix(),
            modified_at=get_unix(),
        )
        tag1_1 = Tag(
            name="reactjs",
            created_at=get_unix(),
            modified_at=get_unix(),
        )
        tag1_2 = Tag(
            name="react-javascript",
            created_at=get_unix(),
            modified_at=get_unix(),
        )
        tag2 = Tag(
            name="python",
            created_at=get_unix(),
            modified_at=get_unix(),
        )
        tag3 = Tag(
            name="go",
            created_at=get_unix(),
            modified_at=get_unix(),
        )

        db.session.add(tag1)
        db.session.add(tag1_1)
        db.session.add(tag1_2)
        db.session.add(tag2)
        db.session.add(tag3)

        project1.tags.append(tag1)
        project2.tags.append(tag1)
        project3.tags.append(tag1)
        project4.tags.append(tag1)

        project1.tags.append(tag2)
        project2.tags.append(tag2)
        project3.tags.append(tag2)
        project4.tags.append(tag2)

        db.session.commit()

    return
Ejemplo n.º 8
0
def project_preview():

    # company variables
    try:
        name = request.form['company_name']
        location = request.form['company_location']
        email = request.form['company_email']
    except KeyError as e:
        print(e)
        raise RequestError(general_error, 400)

    # checks for existing company
    company = Company.query.filter_by(email=email.lower()).first()

    # creates a company
    if not company:
        company = Company(
            name=name,
            location=location,
            email=email.lower(),
            logo="test-logo",
            created_at=get_unix(),
            modified_at=get_unix(),
        )
        db.session.add(company)

    # project variables
    try:
        title = request.form['title']
        description = request.form['description']
        restrictions = request.form['restrictions']
        link = request.form['link']
    except KeyError as e:
        print(e)
        raise RequestError(general_error, 400)

    # checks for existing project
    if request.form.get('project_id'):

        project_id = request.form.get('project_id')
        project = Project.query.filter_by(id=project_id).first()

        project.title = title
        project.description = description
        project.restrictions = restrictions
        project.link = link

        # removes tags as they will be re-added later
        project.tags = []

    else:

        # creates a project
        project = Project(
            published=False,
            demo=False,
            title=title,
            description=description,
            restrictions=restrictions,
            link=link,
            created_at=get_unix(),
            modified_at=get_unix(),
        )
        db.session.add(project)

    # adds project to company
    company.projects.append(project)

    # tags variable
    try:
        tags = request.form['tags']
    except KeyError as e:
        print(e)
        raise RequestError(general_error, 400)

    # converts to list
    tags = tags.split(',')

    # creates tags
    if tags:
        for t in tags:

            # ignores ['']
            if t:

                # looks for existing tag
                tag = Tag.query.filter_by(name=t.lower()).first()
                if not tag:
                    tag = Tag(
                        name=t.lower(),
                        created_at=get_unix(),
                        modified_at=get_unix(),
                    )
                    db.session.add(tag)

                # adds tag to project
                project.tags.append(tag)

    # commits
    db.session.commit()

    return json.dumps([get_project(project)])