Exemple #1
0
def new():
    if request.method == 'GET':
        return render_template('admin/new.html')
    if request.method == 'POST':
        form = request.form
        a = Article(form)
        a.save()
        return redirect(url_for('index.index'))
Exemple #2
0
    def post(self):
        req = request.json

        # 處理新的tags
        _tags = req.pop("tags")
        tags = []
        for _tag in _tags:
            tag = Tag.query.filter_by(tag_name=_tag['tag_name']).first()
            if not tag:
                Tag(_tag['tag_name']).save()
                tag = Tag.query.filter_by(tag_name=_tag['tag_name']).first()
            tags.append(tag)

        article = Article(
            tags=tags,
            title=req.pop('title'),
            preview=req.pop('preview'),
            content=req.pop('content'),
        )

        article.save()

        return {'id': article.article_id}, 200
Exemple #3
0
        'username': '******',
        'email': '*****@*****.**',
        'password': '******',
        'password_confirmation': 'passpass'
    })
    if errors:
        raise Exception(errors)
    begona.save()

    llorona = Article(
        title="La Llorona",
        #pylint: disable=C0301
        content=
        "The legend is said that in a rural village there lived a young woman named Maria.\n Maria came from a poor family but was known around her village for her beauty. One day, an extremely wealthy nobleman traveled through her village. He stopped in his tracks when he saw Maria. Maria was charmed by him and he was charmed by her beauty, so when he proposed to her, she immediately accepted. Maria's family was thrilled that she was marrying into a wealthy family, but the nobleman's father was extremely disappointed that his son was marrying into poverty. Maria and her new husband built a house in the village to be away from his disapproving father. Eventually, she gave birth to two boys. Her husband was always traveling, and stopped spending time with his family. When he came home, he only paid attention to the sons and Maria knew her husband was falling out of love with her. One day, he returned to the village with a younger woman, and told his sons farewell, ignoring Maria.Maria, angry and hurt, took her sons to a river and drowned them in a blind rage. She realized what she had done and searched for them, but the river had already carried them away. Days later, she was found dead on the river bank. Challenged at the gates of heaven for the whereabouts of her sons, she was not permitted to enter the afterlife until she finds them. Stuck between the land of the living and the dead, she spends eternity looking for her lost sons. She is always heard weeping for her sons, earning her the name 'La Llorona.' It is said that if you hear her crying, you are to run the opposite way. If you hear her cries, they could bring misfortune or even death. Many parents in Latin America use this story to scare their children from staying out too late.La Llorona kidnaps wandering children at night, mistaking them for her own. She begs the heavens for forgiveness, and drowns the children she kidnaps.\n People who claim to have seen her say she appears at night or in the late evening by rivers or lakes, wearing a white or black gown with a veil.[3] Some believe those who hear the wails of La Llorona are marked for death or misfortune, similar to the Gaelic banshee legend.[4] Among her wails, she is noted as crying '¡Ay, mis hijos!'' which translates to 'Oh, my children!' She scrapes the bottom of the rivers and lakes, searching for her sons. It is said that when her wails sounds near she is actually far and when she sounds distant, she is actually very near.",
        creator=maria)
    llorona.save()

    mandragora = Article(
        title="Mandragora",
        #pylint: disable=C0301
        content=
        "In myth, mandragoras are familiar demons who appear in the figures of little men without beards.Mandragoras are thought to be little dolls or figures given to sorcerers by the Devil for the purpose of being consulted by them in time of need; and it would seem as if this conception had sprung directly from that of the fetish, which is nothing else than a dwelling-place made by a shaman or medicine-man for the reception of any wandering spirit who chooses to take up his abode therein.",
        creator=roan)
    mandragora.save()

    gog = Article(
        title="Gog and Magog",
        #pylint: disable=C0301
        content=
        "Gog and Magog (/ˈɡɒɡ ... ˈmeɪɡɒɡ/; Hebrew: גּוֹג וּמָגוֹג Gog u-Magog) appear in the Hebrew Bible as individuals, peoples, or lands. In Ezekiel 38, Gog is an individual and Magog is his land; in Genesis 10 Magog is a man, but no Gog is mentioned; and centuries later Jewish tradition changed Ezekiel's Gog from Magog into Gog and Magog, which is the form in which they appear in the Book of Revelation, although there they are peoples rather than individuals.A legend was attached to Gog and Magog by the time of the Roman period, that the Gates of Alexander were erected by Alexander the Great to repel the tribe. Romanized Jewish historian Josephus knew them as the nation descended from Magog the Japhetite, as in Genesis, and explained them to be the Scythians. In the hands of Early Christian writers they became apocalyptic hordes, and throughout the Medieval period variously identified as the Huns, Khazars, Mongols, Turanians or other nomads, or even the Ten Lost Tribes of Israel.The legend of Gog and Magog and the gates was also interpolated into the Alexander romances. In one version, 'Goth and Magoth' are kings of the Unclean Nations, driven beyond a mountain pass by Alexander, and blocked from returning by his new wall. Gog and Magog are said to engage in human cannibalism in the romances and derived literature. They have also been depicted on Medieval cosmological maps, or mappae mundi, sometimes alongside Alexander's wall.The conflation of Gog and Magog with the legend of Alexander and the Iron Gates was disseminated throughout the Near East in the early centuries of the Christian era.They appear in the Quran as Yajuj and Majuj (Arabic: يأجوج ومأجوج‎ Yaʾjūj wa-Maʾjūj), adversaries of Dhul-Qarnayn, who is mentioned in the Qu'ran as a great righteous ruler and is most commonly considered to be Alexander the Great. Muslim geographers identified them at first with Turkic tribes from Central Asia and later with the Mongols. In modern times they remain associated with apocalyptic thinking, especially in the United States and the Muslim world.",
        creator=roan,
Exemple #4
0
US = User()
US.password = "******"
US.first_name = "test1 "
US.phone_number = 0000
US.save()

AR = Article()
AR.user_id = US.id
AR.tag_id = TA.id
AR.category_id = CA.id
AR.title = "tets"
AR.description = " walaaaaaaaaaaaaaaaaaaaah test"
AR.content = "nammi test"
AR.version = "test"
AR.promoted = 1
AR.save()
print(TA.to_dict())
print("------------------------------------------------")
print("\n")

print(CA.to_dict())
print("------------------------------------------------")
print("\n")

print(US.to_dict())
print("------------------------------------------------")
print("\n")

print(AR.to_dict())
print("------------------------------------------------")
print("\n")