• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sugar.get_object_or_404函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sugar.get_object_or_404函数的典型用法代码示例。如果您正苦于以下问题:Python get_object_or_404函数的具体用法?Python get_object_or_404怎么用?Python get_object_or_404使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_object_or_404函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: check_request_funding

def check_request_funding(meeting_id):
    sugar.get_object_or_404(models.Meeting, id=meeting_id)
    category_id = flask.request.form['category_id']
    country_code = flask.request.form['country_code']

    resp = {'request_funding': False}
    category = sugar.get_person_category_or_404(
        meeting_id,
        category_id=category_id
    )
    try:

        country = models.Country.get(data__contains={'iso': country_code})
    except models.Country.DoesNotExist:
        country = None

    if category.data.get('request_funding', False):
        resp['request_funding'] = True
    if category.data.get('credentials_file', False):
        resp['credentials_file'] = True

    if (category.data.get('request_funding_with_country', False)
        and country
        and country.data.get('request_funding', False)):
        resp['request_funding'] = True
    if (category.data.get('credentials_file_with_country', False)
        and country
        and country.data.get('request_funding', False)):
        resp['credentials_file'] = True

    return flask.jsonify(resp)
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:31,代码来源:participant.py


示例2: settings_category_add

def settings_category_add(meeting_id):
    sugar.get_object_or_404(models.Meeting, id=meeting_id)
    categories = flask.request.form.getlist('categories')
    for categ in categories:
        models.CategoryMeeting.create(meeting_id=meeting_id, category_id=categ)
    return flask.redirect(flask.url_for('.settings_category_index',
                                        meeting_id=meeting_id))
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:7,代码来源:meeting.py


示例3: event_delete

def event_delete(meeting_id, event_id):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    event = sugar.get_object_or_404(models.Event, id=event_id)
    event.delete_instance()
    return flask.jsonify({
        'status': 'success',
        'url': flask.url_for('.events', meeting_id=meeting_id)
    })
开发者ID:pombredanne,项目名称:cites-meetings,代码行数:8,代码来源:meeting.py


示例4: questions_delete

def questions_delete(meeting_id, question_id):
    sugar.get_object_or_404(models.Meeting, id=meeting_id)
    question = sugar.get_object_or_404(models.Question, id=question_id,
                                       meeting_id=meeting_id)
    question.delete_instance()
    return flask.jsonify({
        'status': 'success',
        'url': flask.url_for('.questions', meeting_id=meeting_id)
    })
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:9,代码来源:meeting.py


示例5: update_attendance

def update_attendance(meeting_id, person_id, field):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    person = sugar.get_person_or_404(meeting_id, person_id)
    person_meeting = sugar.get_object_or_404(models.PersonMeeting,
        person=person_id, meeting=meeting_id)
    status = person_meeting.data['meeting_flags_%s' % field]
    person_meeting.data['meeting_flags_%s' % field] = '1' if not status else ''
    person_meeting.save()
    return flask.jsonify({'status': 'success'})
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:9,代码来源:participant.py


示例6: settings_fee_index

def settings_fee_index(meeting_id):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    fees = meeting.get_fees
    return {
        'fees': fees,
        'meeting': meeting,
    }
开发者ID:pombredanne,项目名称:cites-meetings,代码行数:7,代码来源:meeting.py


示例7: questions

def questions(meeting_id):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    questions = meeting.get_questions()
    return {
        'meeting': meeting,
        'questions': questions
    }
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:7,代码来源:meeting.py


示例8: media_file

def media_file(meeting_id, file_type, media_person_id=None, person_id=None):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    if media_person_id:
        person = sugar.get_media_person_or_404(meeting_id, media_person_id)
        redirect_url = flask.url_for('.view', meeting_id=meeting.id,
                                     media_person_id=person.id)
    elif person_id:
        person = sugar.get_person_or_404(meeting_id, person_id)
        redirect_url = flask.url_for('participant.view',
                                     meeting_id=meeting.id,
                                     person_id=person.id)
    else:
        flask.abort(400)

    app = flask.current_app
    media_file = flask.request.files[file_type]

    if media_file:
        # delete old file
        if person.data.get(file_type):
            try:
                app.config['UPLOADED_FILES_DEST'].joinpath(
                    person.data[file_type]).unlink()
            except OSError:
                pass
        filename = '%s_%s.' % (
            secure_filename(person.decoded_data['personal_last_name']),
            file_type)
        media_file_name = files.save(media_file, name=filename) if media_file else ''
        person.data[file_type] = media_file_name
        person.save()

    return flask.redirect(redirect_url)
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:33,代码来源:media_participant.py


示例9: envelope_print

def envelope_print(meeting_id, person_id):
    app = flask.current_app

    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    person = sugar.get_person_or_404(meeting_id, person_id)
    secretariat = refdata.secretariat

    temp = path(tempfile.mkdtemp())
    flask.g.pdf_compatible = True
    country_names = []

    try:
      country_names = refdata.translated_country_names[
          person.data['personal_country']]
    except KeyError:
      pass

    context = dict(meeting=meeting,
                   person=person,
                   path=app.root_path,
                   secretariat=secretariat,
                   country_names=country_names)

    return sugar.render_pdf('participant/person_envelope.html',
                            temp=temp,
                            height='6.4in',
                            width='9.0in',
                            context=context,
                            filename=secure_filename(person.name),
                            use_wkhtmltopdf=True)
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:30,代码来源:participant.py


示例10: badge_misc_pdf

def badge_misc_pdf(meeting_id, badge_type):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    temp = path(tempfile.mkdtemp())
    app = flask.current_app

    if badge_type == 'visitor':
        category = models.Category.select().where(
            data__contains={'name_E': 'Visitor'}).get()
    elif badge_type == 'security':
        category = models.Category.select().where(
            data__contains={'name_E': 'Security'}).get()
    elif badge_type == 'exhibitor':
        category = models.Category.select().where(
            data__contains={'name_E': 'Exhibitor'}).get()
    elif badge_type == 'host_government':
        category = models.Category.select().where(
            data__contains={'name_E': 'Host Government'}).get()
    elif badge_type == 'local_staff':
        category = models.Category.select().where(
            data__contains={'name_E': 'Local staff'}).get()
    else:
        flask.abort(400)

    context = {
        'meeting': meeting,
        'category': category,
        'badge_type': badge_type,
        'path': app.root_path,
        'background_path': app.config['UPLOADED_BACKGROUNDS_DEST'],
    }

    return sugar.render_pdf('participant/badge_misc_simple.html', temp=temp,
                             height="2.15in", width="3.4in", context=context,
                             filename=sugar.random_string(6),
                             use_wkhtmltopdf=True)
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:35,代码来源:participant.py


示例11: badge_misc

def badge_misc(meeting_id, badge_type):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    if badge_type == 'visitor':
        category = models.Category.select().where(
            data__contains={'name_E': 'Visitor'}).get()
    elif badge_type == 'security':
        category = models.Category.select().where(
            data__contains={'name_E': 'Security'}).get()
    elif badge_type == 'exhibitor':
        category = models.Category.select().where(
            data__contains={'name_E': 'Exhibitor'}).get()
    elif badge_type == 'host_government':
        category = models.Category.select().where(
            data__contains={'name_E': 'Host Government'}).get()
    elif badge_type == 'local_staff':
        category = models.Category.select().where(
            data__contains={'name_E': 'Local staff'}).get()
    else:
        flask.abort(400)

    return {
        'meeting': meeting,
        'category': category,
        'badge_type': badge_type,
    }
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:25,代码来源:participant.py


示例12: revert_photo

def revert_photo(meeting_id, person_id):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    person = sugar.get_person_or_404(meeting_id, person_id)
    url = flask.url_for('participant.crop_photo_view',
                         meeting_id=meeting.id,
                         person_id=person.id)
    return _revert_photo(meeting, person, url)
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:7,代码来源:participant.py


示例13: view_pdf

def view_pdf(meeting_id, person_id):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    person = sugar.get_person_or_404(meeting_id, person_id)
    labeled = schema.common.labels_for_values(person.data, meeting_id)
    category = sugar.get_person_category_or_404(meeting_id,
        category_id=person.category_id(meeting.id))
    phrases = {p.data['name']: p for p in meeting.get_phrases}
    event_form = EventCitesForm(meeting_model=meeting, person=person)

    # render form in participant language
    participant_lang = {"E": "en", "S": "es", "F": "fr"}.get(person.lang, "E")
    sugar.set_lang(participant_lang)

    pdf = sugar.generate_pdf_from_html(
        flask.render_template('participant/credentials.html', **{
            'person': person,
            'category': category,
            'meeting': meeting,
            'labeled': labeled,
            'phrases': phrases,
            'credentials_strings': refdata.credentials_strings,
            'event_form': event_form,
        })
    )
    return flask.Response(response=pdf, mimetype='application/pdf')
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:25,代码来源:participant.py


示例14: view

def view(meeting_id, person_id):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    person = sugar.get_person_or_404(meeting_id, person_id)
    page_info = {}
    page_info['picture'] = {
        'edit_url': flask.url_for('participant.edit_photo',
                                   meeting_id=meeting.id,
                                   person_id=person.id),

        'remove_url': flask.url_for('participant.remove_photo',
                                     meeting_id=meeting.id,
                                     person_id=person.id),

        'url': person.image_file,

        'rotate_url': flask.url_for('participant.rotate_photo',
                                     meeting_id=meeting.id,
                                     person_id=person.id),

        'crop_url': flask.url_for('participant.crop_photo_view',
                                   meeting_id=meeting.id,
                                   person_id=person.id),
    }
    event_form = EventCitesForm(meeting_model=meeting, person=person)
    return {
        'meeting': meeting,
        'person': person,
        'page_info': page_info,
        'event_form': event_form,
    }
开发者ID:pombredanne,项目名称:cites-meetings,代码行数:30,代码来源:participant.py


示例15: badge_print

def badge_print(meeting_id, person_id, person_type):
    app = flask.current_app
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)

    if person_type == 'person':
        person = sugar.get_person_or_404(meeting_id, person_id)
    else:
        person = sugar.get_media_person_or_404(meeting_id, person_id)
    badge = flask.request.args.get('badge', None)

    # create a temporary folder and save participant photo to disk
    temp = path(tempfile.mkdtemp())
    photo = person.data.get('photo', None)

    if photo:
        person.photo_url = app.config['UPLOADED_PHOTOS_DEST'] / photo
    else:
        person.photo_url = None

    # save badge as html
    context = dict(meeting=meeting, person=person, path=app.root_path,
                   background_path=app.config['UPLOADED_BACKGROUNDS_DEST'],
                   badge=badge, person_type=person_type)
    return sugar.render_pdf("participant/person_badge_simple.html", temp=temp,
                             height="2.15in", width="3.4in", context=context,
                             filename=secure_filename(person.name),
                             use_wkhtmltopdf=True)
开发者ID:pombredanne,项目名称:cites-meetings,代码行数:27,代码来源:participant.py


示例16: settings_phrases

def settings_phrases(meeting_id):
    session = database.get_session()
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)

    if flask.request.method == 'POST':
        form_data = dict(schema.PhraseSchema.from_defaults().flatten())
        form_data.update(flask.request.form.to_dict())
        phrase_schema = schema.PhraseSchema.from_flat(form_data)

        if phrase_schema.validate():
            phrase = (models.Phrase.select()
                .where(data__contains={'id': str(phrase_schema['id'].value)})
                .where(meeting=meeting_id).get())
            phrase.data.clear()
            phrase.data.update(phrase_schema.flatten())
            phrase.save()
            flask.flash('Phrase saved', 'success')
        else:
            flask.flash(u'Errors in phrase information', 'error')

    phrases = meeting.get_phrases

    return {
        'language': refdata.language,
        'phrases': phrases,
        'meeting': meeting,
    }
开发者ID:pombredanne,项目名称:cites-meetings,代码行数:27,代码来源:meeting.py


示例17: view

def view(meeting_id, media_person_id):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    person = sugar.get_media_person_or_404(meeting_id, media_person_id)

    page_info = {}
    page_info['picture'] = {
        'edit_url': flask.url_for('.edit_photo', meeting_id=meeting.id,
                                   media_person_id=person.id),
        'remove_url': flask.url_for('.remove_photo', meeting_id=meeting.id,
                                     media_person_id=person.id),
        'url': person.image_file,

        'rotate_url': flask.url_for('media_participant.rotate_photo',
                                     meeting_id=meeting.id,
                                     media_person_id=person.id),

        'crop_url': flask.url_for('media_participant.crop_photo_view',
                                   meeting_id=meeting.id,
                                   media_person_id=person.id),
    }

    return {
        'meeting': meeting,
        'person': person,
        'page_info': page_info,
    }
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:26,代码来源:media_participant.py


示例18: provisional_pdf

def provisional_pdf(meeting_id, printout_type):
    meeting = sugar.get_object_or_404(Meeting, id=meeting_id)
    filters = {'meeting_flags_%s' % printout_type: '1'}
    categs, categ_ids = get_categories_for_printouts(meeting, None, all=True)
    order_by = [("category", "ASC"),
                ("(t1.data -> 'printout_representing')", "ASC"),
                ("(t1.data -> 'personal_last_name')", "ASC"),]
    fields = [R('t1.data', 'data'), R('category', 'category'),
              R('t1.data-> \'printout_representing\'', 'printout_representing')]
    persons = (Person.select(fields)
                     .group_by("category")
                     .group_by("t1.data -> 'printout_representing'")
                     .group_by("t1.data")
                     .order_by(*order_by)
    )
    persons = sugar.append_persons_query(persons, meeting_id,
                                         categories=categ_ids)

    page_info =  {
        'title': 'Provisional list as entered by participant',
        'meeting_description': _get_meeting_description(meeting, 'E'),
        'type': printout_type,
        'today': datetime.now(),
    }

    return {
        'meeting': meeting,
        'persons': persons,
        'page_info': page_info,
        'count': persons.count(),
    }
开发者ID:pombredanne,项目名称:cites-meetings,代码行数:31,代码来源:printouts.py


示例19: events

def events(meeting_id):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    events = meeting.get_events()
    return {
        'meeting': meeting,
        'events': events,
    }
开发者ID:pombredanne,项目名称:cites-meetings,代码行数:7,代码来源:meeting.py


示例20: edit

def edit(meeting_id, person_id=None):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)

    if person_id is None:
        person = models.Person()
        person_meeting = None
        template = 'participant/edit/create.html'
        subject = 'add-participant'
        event_form = EventCitesForm(meeting_model=meeting)
        person_data_as_attributes = None
    else:
        person = sugar.get_person_or_404(meeting_id, person_id)
        person_meeting = sugar.get_object_or_404(models.PersonMeeting,
                                                 person=person_id,
                                                 meeting=meeting_id)
        event_form = EventCitesForm(meeting_model=meeting, person=person)
        template = 'participant/edit/cites_edit.html'
        subject = 'edit-participant'
        person_data_as_attributes = person.data_as_attributes(meeting_id)

    ParticipantForm = get_participant_form(meeting.data['info_type'])
    form = ParticipantForm(meeting=meeting,
                          obj=person_data_as_attributes)

    if flask.request.method == 'POST':
        if form.validate():
            form.save(meeting, person, person_meeting)
            event_form.save(person)

            sugar.activity(meeting_id, subject, person.name, person.id)
            flask.flash('Person information saved', 'success')
            view_url = flask.url_for('participant.view',
                                      meeting_id=meeting.id,
                                      person_id=person.id)
            return flask.redirect(view_url)
        else:
            flask.flash('Errors in person information', 'error')

    return {
        'template': template,
        'form': form,
        'event_form': event_form,
        'person': person,
        'person_id': person_id,
        'meeting': meeting,
    }
开发者ID:eaudeweb,项目名称:cites-meetings,代码行数:46,代码来源:participant.py



注:本文中的sugar.get_object_or_404函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python bundlebuilder.start函数代码示例发布时间:2022-05-27
下一篇:
Python sxbuiltin.Factory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap