def save(self, meeting, person, person_meeting): form_data = dict(self.data) if person.data: form_data['photo'] = person.data.get('photo', None) else: person.data = {} person.data.update(form_data.items()) personal_category = person.data.pop('personal_category') meeting_flags = self._get_meeting_flags(person) category = get_person_category_or_None(meeting.id, personal_category) person.data['printout_representing'] = person.rep(meeting, category_id=personal_category) or '' person.data['room'] = category.data['room'] or '' person.save() person.data['_text_for_search'] = person.text_for_search person.save() if person_meeting: person_meeting.category = personal_category person_meeting.data.update(meeting_flags) person_meeting.save() else: person_meeting = PersonMeeting() person_meeting.person = person.id person_meeting.meeting = meeting.id person_meeting.category = personal_category person_meeting.token = random_string() person_meeting.data = meeting_flags person_meeting.data['registered_date'] = \ str(datetime.now().replace(second=0, microsecond=0)) person_meeting.save()
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)