def save(self, person, person_meeting): attending_dates = ' '.join(self.data['attending_dates']) if self.data['attending_dates'] else '' person.data.update(dict(self.data, attending_dates=attending_dates)) personal_category = int(person.data.pop('personal_category')) person.save() person.data['_text_for_search'] = person.text_for_search person.save() if person_meeting: person_meeting.category = personal_category person_meeting.save() else: data = { 'registered_date': str(datetime.now().replace(second=0, microsecond=0)) } MediaMeeting.create(person=person.id, meeting=self.meeting.id, category=personal_category, token=random_string(), data=data)
def save(self, person): photo = self.data.get('photo') #use last name for the photo filename filename = '%s.' % secure_filename(self.data['personal_last_name']) photo_name = photos.save(photo, name=filename) if photo else '' press_card = self.data.get('press_card') #use last name for the press_card filename filename = '%s_press.' % secure_filename(self.data['personal_last_name']) press_card_name = files.save(press_card, name=filename) if press_card else '' editor_letter = self.data.get('editor_letter') #use last name for the editor_letter filename filename = '%s_letter.' % secure_filename(self.data['personal_last_name']) editor_letter_name = files.save(editor_letter, name=filename) if editor_letter else '' attending_dates = ' '.join(self.data['attending_dates']) if self.data['attending_dates'] else '' person.data.update(dict(self.data, photo=photo_name, press_card=press_card_name, editor_letter=editor_letter_name, attending_dates=attending_dates)) personal_category = int(person.data.pop('personal_category')) person.save() person.data['_text_for_search'] = person.text_for_search person.save() data = { 'registered_date': str(datetime.now().replace(second=0, microsecond=0)) } MediaMeeting.create(person=person.id, meeting=self.meeting.id, category=personal_category, token=random_string(), data=data)