コード例 #1
0
    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()
コード例 #2
0
ファイル: models.py プロジェクト: eaudeweb/cites-meetings
def update_representing_for(category):
    persons = [(pm.meeting, pm.person) for pm in PersonMeeting.select().where(
        category=category.data['id'])]
    for meeting, person in persons:
        person.data['printout_representing'] = person.rep(meeting,
            category=category) or ''
        person.save()
コード例 #3
0
ファイル: models.py プロジェクト: eaudeweb/cites-meetings
def get_person_category_or_404(meeting_id, person_id=None, category_id=None):
    if not category_id:
        try:
            category_id = PersonMeeting.select().where(meeting=meeting_id,
                person=person_id).get().category
        except PersonMeeting.DoesNotExist:
            flask.abort(404)

    try:
        category = Category.select().where(
            data__contains={'id': str(category_id)}
        ).join(CategoryMeeting).where(meeting_id=str(meeting_id)).get()
    except Category.DoesNotExist:
        flask.abort(404)

    return category