def insert_antrag(antrag, to_pos):
    a = prepare_antrag(antrag)
    details = antrag_details_prepare_html(a)
    id_ = a[K["id"]]
    tags = [id_, a[K["kind"]], a[K["group"]]] + ADDITIONAL_TAGS
    if TO_GIVEN:
        # add TO position tags
        if to_pos != 0:
            tags.append("Top80")
            tags.append("TO" + str(to_pos))
        else:
            tags.append("Rest")
        
    # insert question into DB
    additional = create_additional_data(tags)
    question = Question(title=a["shorttitle"], url=id_, details=details, dateAdded=time.time(),
                        score=0, scoreTrending=0, scoreTop=0, userId=2, groupId=0, type=0, flags=0, additionalData=additional)
    session.add(question)
    session.commit()
    # insert title words in Tag table because this table is used for question searches
    title_words = a[K["title"]].split()
    for tag in tags + title_words:
        tag_obj = Tag(tag=tag.replace(" ", "-"), questionId=question.questionId, groupId=0)
        session.add(tag_obj)
    session.commit()
    return question
Beispiel #2
0
def insert_antrag(antrag):
    a = prepare_antrag(antrag)
    details = antrag_details_prepare_html(a)
    id_ = a["id"]
    tags = [id_, "LPT13.1", a["kind"]]
    additional = create_additional_data(tags)
    question = Question(title=a["shorttitle"], url=id_, details=details, dateAdded=time.time(),
                        score=0, scoreTrending=0, scoreTop=0, userId=2, additionalData=additional)
    session.add(question)
    session.commit()
    # insert title words in Tag table because this table is used for question searches
    title_words = a["title"].split()
    for tag in tags + title_words:
        tag_obj = Tag(tag=tag, questionId=question.questionId)
        session.add(tag_obj)
    session.commit()
    return question