Beispiel #1
0
def setListVote(theList, theUser, theIndex, theVote):
    vote = session.query(ListVote) \
        .filter(ListVote.theList == theList.id) \
        .filter(ListVote.user == theUser.id) \
        .filter(ListVote.index == theIndex).first()
    vote.vote = theVote
    session.commit()
Beispiel #2
0
 def __init__(self, title):
     self.title = title
     self.bracket = json.dumps([[]] * BRACKET_SIZE)
     self.url = makeURL(title)
     self.theRound = 1
     session.add(self)
     session.commit()
Beispiel #3
0
 def __init__(self, theList, user, index, vote):
     self.theList = theList.id
     self.user = user.id
     self.index = index
     self.vote = vote
     session.add(self)
     session.commit()
Beispiel #4
0
def resolve_create_skill(_, info, input):
    skill = Skill(**input)
    skill.id = str(uuid4())
    try:
        session.add(skill)
        session.commit()
    except Exception:
        session.rollback()
    return skill
Beispiel #5
0
    def __init__(self, user):
        self.user = user.id

        # Generate Token
        alphabet = string.ascii_letters + string.digits
        self.token = ''.join( choice(alphabet) \
            for i in list(range(TOKEN_SIZE)))

        self.expire = getTime() + TOKEN_EXPIRE

        session.add(self)
        session.commit()
Beispiel #6
0
def resolve_create_person(_, info, input):
    friends = []
    skills = []
    if 'friends' in input:
        person_ids = input.pop('friends')
        friends = session.query(Person).filter(Person.id.in_(person_ids)).all()
    if 'skills' in input:
        skill_ids = input.pop('skills')
        skills = session.query(Skill).filter(Skill.id.in_(skill_ids)).all()

    person = Person(**input)
    person.id = str(uuid4())
    person.friends = friends
    person.skills = skills
    try:
        session.add(person)
        session.commit()
    except Exception:
        session.rollback()
    return person
Beispiel #7
0
    def getBracket(self):
        bracket = []

        for i in range(BRACKET_SIZE):
            bracket.append([])

        matchIndex = BRACKET_SIZE - 1

        for choice in self.getChoices():
            if len(bracket[matchIndex]) == 2:
                matchIndex -= 1
            if matchIndex < (BRACKET_SIZE / 2):
                break
            bracket[matchIndex].append(choice.id)

        bracket[0] = [self.getWinner(bracket, 1)]

        self.bracket = json.dumps(bracket)
        session.commit()

        return bracket
Beispiel #8
0
def create_persons(info, input):
    friends = []
    skills = []
    if 'friends' in input:
        person_ids = input.pop('friends')
        friends = session.query(Person).filter(Person.id.in_(person_ids)).all()
    if 'skills' in input:
        skill_ids = input.pop('skills')
        skills = session.query(Skill).filter(Skill.id.in_(skill_ids)).all()

    new_person = Person(**input)
    new_person.id = str(uuid4())
    new_person.friends = friends
    new_person.skills = skills
    if info.return_type.of_type.name == 'Engineer':
        new_person.employeeId = str(uuid4())
    try:
        session.add(new_person)
        session.commit()
    except Exception:
        session.rollback()
    return new_person
Beispiel #9
0
def db_create_seed():
    # Drop all
    drop_all_db()
    # Create all
    create_all_db()
    # Seed all
    test_product_1 = Product(name='test_1')
    session.add(test_product_1)
    test_product_2 = Product(name='test_2')
    session.add(test_product_2)
    test_product_3 = Product(name='test_3')
    session.add(test_product_3)
    test_product_4 = Product(name='test_4')
    session.add(test_product_4)
    test_product_5 = Product(name='test_5')
    session.add(test_product_5)
    test_product_6 = Product(name='test_6')
    session.add(test_product_6)
    test_product_7 = Product(name='test_7')
    session.add(test_product_7)
    test_product_8 = Product(name='test_8')
    session.add(test_product_8)
    session.commit()
Beispiel #10
0
def to_post():
	if request.method == 'POST':
		session.add(Post(request.form['text'],current_user))
		session.commit()
		return redirect('title')
	return render_template('post.html')
Beispiel #11
0
 def proceed(self):
     self.theRound = self.theRound + 1
     session.commit()
Beispiel #12
0
 def __init__(self, theList, user, choice):
     self.theList = theList.id
     self.choice = choice.id
     self.user = user.id
     session.add(self)
     session.commit()
Beispiel #13
0
 def __init__(self, theList, user, owner):
     self.theList = theList.id
     self.user = user.id
     self.owner = owner
     session.add(self)
     session.commit()
Beispiel #14
0
 def __init__(self, username, password):
     self.username = username
     self.password = pwd.encrypt(password)
     session.add(self)
     session.commit()
Beispiel #15
0
def deleteToken(token):
    session.delete(token)
    session.commit()