Esempio n. 1
0
def update(_id):
    content = request.get_json()
    nom = content['nom']
    email = content['email']
    password = content['password']
    updated_user = Data.User(nom, email, password, kwargs={'id': _id})
    updated_user.id = _id
    session.merge(updated_user)
    session.flush()
    session.commit()

    return "user updated "
Esempio n. 2
0
def post():
    print(request.is_json)
    content = request.get_json()
    nom = content['nom']
    email = content['email']
    password = content['password']
    user = Data.User(nom, email, password)
    session.add(user)
    session.flush()
    session.commit()

    return 'User added'
Esempio n. 3
0
    def from_xml(node):
        # if question already has ID assigned, fetch it
        if 'id' in node.attrib:
            question = session.query(Question).get(node.attrib['id'])
        # otherwise, create a new one
        else:
            if 'review' in node.attrib and 't' in node.attrib['review'].lower():
                question = PeerReview()
            else:
                question = Question()
            session.add(question)
            session.flush()

        question.sync_from_node(node)
        session.commit()

        return question
Esempio n. 4
0
    def from_xml(node):
        """Constructs a Item object from an xml node"""

        klass_map = {'Multiple Choice': MultipleChoiceItem,
                     'Long Answer': LongAnswerItem,
                     'Short Answer': ShortAnswerItem}
        if node.attrib['type'] in klass_map:
            klass = klass_map[node.attrib['type']]
        else:
            raise ValueError('type of question not recognized, options are %s' % `klass_map.keys()`)

        # get existing item based on ID, if specified
        if 'id' in node.attrib:
            item = session.query(Item).get(node.attrib['id'])
        # otherwise create new item
        else:
            item = klass()
            session.add(item)

        item.sync_from_node(node)
        item.xml = ET.tostring(node, method="xml")
        session.flush()
        return item