Esempio n. 1
0
 def _create_person(self):
     person = Person()
     person.first_name = 'John'
     person.middle_name = 'Q'
     person.last_name = 'Tester'
     person.save()
     return person
Esempio n. 2
0
def handle_new_post(form):
    # Since the end user could input a blank string, let's handle no input the same
    person_first_name = extract_form_field_value(form, 'person_first_name')
    person_middle_name = extract_form_field_value(form, 'person_middle_name')
    person_last_name = extract_form_field_value(form, 'person_last_name')
    share_title = extract_form_field_value(form, 'share_title')
    share_content = extract_form_field_value(form, 'share_content')
    share_attachment = form.files.get('share_attachment', None)

    person = Person()
    person.first_name = person_first_name
    person.middle_name = person_middle_name
    person.last_name = person_last_name
    # TODO: add modified_by for the current logged in user if a user is logged in
    person.save()
    
    share = Share()
    share.title = share_title
    share.content = share_content
    share.owner = person
    # TODO: add modified_by for the current logged in user if a user is logged in
    share.save()

    picture = Picture()
    picture.share = share
    picture.image = share_attachment
    picture.thumbnail = share_attachment
    # TODO: add modified_by for the current logged in user if a user is logged in
    picture.save()
    
    if share.search_index is not None:
        share_index_picture = SearchIndexPicture()
        share_index_picture.picture = picture
        share_index_picture.search_index = share.search_index
        share_index_picture.save()

    if person.search_index is not None:
        person_index_picture = SearchIndexPicture()
        person_index_picture.picture = picture
        person_index_picture.search_index = person.search_index
        person_index_picture.save()