Beispiel #1
0
    def post(self) -> Response:

        try:
            if request.is_json:
                data = request.get_json()
                data['uid'] = generate_uid(data)
                post_story = Story(**data).save()
                return jsonify({'id': str(post_story.id)})

            else:
                return send_err(httplib.BAD_REQUEST)

        except (FieldDoesNotExist, ValidationError):
            return send_err(httplib.BAD_REQUEST)

        except:
            return send_err(httplib.INTERNAL_SERVER_ERROR)
Beispiel #2
0
        ' my grandpa, Joachim, was born in 1912 in modern day Poland and his father ' + \
        '(originally a Polish Jew) applied for German citizenship for himself, his wife ' + \
        'and his five children as they were all living in Germany. Joachim, Juliette, Ali ' + \
        '(Alfred), Fredy (Friedrich) and Hans all became German. In the early 1930s, 20 something ' + \
        'Joachim (born in 1912) fled Germany for the U.K. He convinced most of his siblings to come ' + \
        'too, but Juliette stayed behind with her husband and young son. She escaped Germany but was caught ' + \
        'in Vichy France and she was killed by the Nazis. Her son and husband survived. Her grave is in Albi and was visited by ' + \
        'her brother Joachim and his wife(my grandparents) for the first time on their honeymoon in the 1950s. My grandpa Joe met  ' + \
        'my grandmother Pam in Nigeria after he was sent to Egypt with the Royal West African Frontier Force, British Army. There he ' + \
        'met a Nigerian businessman who invited him to come to Nigeria and try and start a business. They had 5 children, including my ' + \
        'mum Penny. Just in case you’re interested 🙂🇪🇺'

    origins = Story(
        title='A story about my Jewish origins',
        description=
        'Collecting our German naturalisation certificates this morning!',
        content=first_story,
        image_url=
        'https://jewishculture.illinois.edu/sites/default/files/inline-images/IMG_0056.JPG',
        creator=gaetano)

    if errors:
        raise Exception(errors)

    second_story = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ' + \
        'ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi' + \
        'ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum' + \
        'dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia' + \
        'deserunt mollit anim id est laborum.'

    lorem = Story(
        title='The standard Lorem Ipsum passage, used since the 1500s',
def create_story(title, number_of_reads):
    story = Story()
    story.title = title
    story.number_of_reads = number_of_reads
    story.save()