Example #1
0
def createSet(name, constructed):

	if not name:
		raise ValueError('A set name must be supplied')

	db.session.add(Set(name = name, constructed = constructed))
	db.session.commit()
Example #2
0
    def setUpClass(cls):
        database.clean()

        cls.set = Set()
        cls.sequenceset = SequenceSet()
        cls.sentenceset = SentenceSet()
        cls.documentset = DocumentSet()

        db.session.add_all(
            [cls.set, cls.sequenceset, cls.sentenceset, cls.documentset])
        db.session.commit()
Example #3
0
def add_set():
    if current_user.username == 'Admin':
        if request.method == 'POST':
            set_name = request.form['name']
            set_about = request.form['about']
            new_set = Set(set_name=set_name, set_about=set_about)
            db.session.add(new_set)
            db.session.commit()
            return redirect(url_for('add_set'))
        else:
            all_sets = Set.query.all()
            return render_template('add_set.html', sets=all_sets)
    else:
        return render_template('accessdenied.html')
Example #4
0
    def test_set(self):
        """Test to make sure that ``Set`` is working.
        """

        sets = db.session.query(Set).all()

        set2 = Set()
        self.set.children = [set2]
        set2.save()

        assert set2.parent == self.set
        assert self.set.children == [set2]

        assert len(sets) == 4
        assert self.set in sets
def create_set():
    data = request.json

    # gets decodes userinfo out of token using auth0 api
    token = request.headers.get('Authorization')
    req = requests.get('https://codelet-app.auth0.com/userinfo',
                       headers={
                           'Authorization': token
                       }).content
    userInfo = json.loads(req)
    userId = User.query.filter_by(email=userInfo['email']).first().id
    set = Set(
        title=data['title'],
        description=data['description'],
        category_id=data['category_id'],
        user_id=userId,
        created_at=data['created_at'],
    )
    db.session.add(set)
    db.session.commit()
    return set.to_dict(), 201
Example #6
0
def store_points(points):
    for points_table in points:
        # Skip the 'Super' set, as it is not a separate language
        if points_table.name == 'Super':
            continue

        # Skip tables with an unprintable name
        try:
            print(points_table.name)
        except:
            continue

        set_record = Set(name=points_table.name)
        db.session.add(set_record)
        db.session.commit()

        for letter, score in points_table.points.iteritems():
            score_record = LetterScore(set_id=set_record.id,
                                       letter=letter,
                                       score=score)
            db.session.add(score_record)
            db.session.commit()
Example #7
0
def ImportSets(txtFile, versionNumber):

    with open(txtFile) as input:
        lines = input.readlines()

        num = 0
        for line in lines:
            print(str(num / len(lines)) + "%")
            num = num + 1

            set = Set(VersionNumber=versionNumber, Checked=False, Notes="")
            set.save()
            setId = set.id

            recordIds = [int(s.strip()) for s in line.split(',')]

            for recordId in recordIds:
                record = Record.objects.filter(EnterpriseId=recordId)[0]
                setMember = SetMember(RecordId=record, SetId=set, IsGood=True)
                setMember.save()

    return