当前位置: 首页>>代码示例>>Python>>正文


Python Conference.find_one方法代码示例

本文整理汇总了Python中website.conferences.model.Conference.find_one方法的典型用法代码示例。如果您正苦于以下问题:Python Conference.find_one方法的具体用法?Python Conference.find_one怎么用?Python Conference.find_one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在website.conferences.model.Conference的用法示例。


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

示例1: populate_conferences

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def populate_conferences():
    for meeting, attrs in MEETING_DATA.iteritems():
        meeting = meeting.strip()
        admin_emails = attrs.pop('admins', [])
        admin_objs = []
        for email in admin_emails:
            try:
                user = User.find_one(Q('username', 'iexact', email))
                admin_objs.append(user)
            except ModularOdmException:
                raise RuntimeError('Username {0!r} is not registered.'.format(email))
        conf = Conference(
            endpoint=meeting, admins=admin_objs, **attrs
        )
        try:
            conf.save()
        except ModularOdmException:
            conf = Conference.find_one(Q('endpoint', 'eq', meeting))
            for key, value in attrs.items():
                setattr(conf, key, value)
            conf.admins = admin_objs
            changed_fields = conf.save()
            if changed_fields:
                print('Updated {}: {}'.format(meeting, changed_fields))
        else:
            print('Added new Conference: {}'.format(meeting))
开发者ID:Alpani,项目名称:osf.io,代码行数:28,代码来源:populate_conferences.py

示例2: populate_conferences

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def populate_conferences():
    for meeting, attrs in MEETING_DATA.iteritems():
        meeting = meeting.strip()
        admin_emails = attrs.pop("admins")
        admin_objs = []
        for email in admin_emails:
            try:
                user = User.find_one(Q("username", "iexact", email))
                admin_objs.append(user)
            except ModularOdmException:
                raise RuntimeError("Username {0!r} is not registered.".format(email))
        conf = Conference(endpoint=meeting, admins=admin_objs, **attrs)
        try:
            conf.save()
        except ModularOdmException:
            print("{0} Conference already exists. Updating existing record...".format(meeting))
            conf = Conference.find_one(Q("endpoint", "eq", meeting))
            for key, value in attrs.items():
                setattr(conf, key, value)
            conf.admins = admin_objs
            changed_fields = conf.save()
            if changed_fields:
                print("Changed: {}".format(changed_fields))
        else:
            print("Added new Conference: {}".format(meeting))
开发者ID:Kimberly-Yang,项目名称:osf.io,代码行数:27,代码来源:populate_conferences.py

示例3: conference_data

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def conference_data(meeting):
    try:
        Conference.find_one(Q('endpoint', 'iexact', meeting))
    except ModularOdmException:
        raise HTTPError(httplib.NOT_FOUND)

    nodes = Node.find(
        Q('tags', 'iexact', meeting) &
        Q('is_public', 'eq', True) &
        Q('is_deleted', 'eq', False)
    )

    ret = [
        _render_conference_node(each, idx)
        for idx, each in enumerate(nodes)
    ]
    return ret
开发者ID:kmjungersen,项目名称:osf.io,代码行数:19,代码来源:views.py

示例4: test_add_conference

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
    def test_add_conference(self):
        user = UserFactory()
        add_conference('spsp2014', name='SPSP', admins=[user.username], active=True)

        conf = Conference.find_one(Q('endpoint', 'eq', 'spsp2014'))
        assert_equal(conf.name, 'SPSP')
        assert_true(conf.active)
        assert_in(user, conf.admins)
开发者ID:545zhou,项目名称:osf.io,代码行数:10,代码来源:add_conference.py

示例5: conference_data

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def conference_data(meeting):
    try:
        conf = Conference.find_one(Q("endpoint", "iexact", meeting))
    except ModularOdmException:
        raise HTTPError(httplib.NOT_FOUND)

    nodes = Node.find(Q("tags", "iexact", meeting) & Q("is_public", "eq", True) & Q("is_deleted", "eq", False))

    ret = [_render_conference_node(each, idx, conf) for idx, each in enumerate(nodes)]
    return ret
开发者ID:danielneis,项目名称:osf.io,代码行数:12,代码来源:views.py

示例6: populate_conferences

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def populate_conferences():
    for meeting, attrs in MEETING_DATA.iteritems():
        conf = Conference(
            endpoint=meeting, **attrs
        )
        try:
            conf.save()
        except ModularOdmException:
            print('{0} Conference already exists. Updating existing record...'.format(meeting))
            conf = Conference.find_one(Q('endpoint', 'eq', meeting))
            for key, value in attrs.items():
                setattr(conf, key, value)
            conf.save()
开发者ID:hmoco,项目名称:osf.io,代码行数:15,代码来源:dev_populate_conferences.py

示例7: conference_results

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def conference_results(meeting):
    """Return the data for the grid view for a conference.

    :param str meeting: Endpoint name for a conference.
    """
    try:
        conf = Conference.find_one(Q('endpoint', 'iexact', meeting))
    except ModularOdmException:
        raise HTTPError(http.NOT_FOUND)

    data = conference_data(meeting)

    return {
        'data': json.dumps(data),
        'label': meeting,
        'meeting': conf.to_storage(),
    }
开发者ID:RafaelWillian,项目名称:osf.io,代码行数:19,代码来源:views.py

示例8: populate_conferences

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def populate_conferences(dev=False):
    if dev:
        Conference.remove()
    date_format = '%b %d %Y'
    for meeting, attrs in MEETING_DATA.iteritems():
        meeting = meeting.strip()
        admin_emails = attrs.pop('admins', [])
        admin_objs = []
        if not dev:
            for email in admin_emails:
                try:
                    user = User.find_one(Q('username', 'iexact', email))
                    admin_objs.append(user)
                except ModularOdmException:
                    raise RuntimeError('Username {0!r} is not registered.'.format(email))

        # Convert string into datetime object
        try:
            attrs['end_date'] = datetime.strptime(attrs.get('end_date'), date_format)
            attrs['start_date'] = datetime.strptime(attrs.get('start_date'), date_format)
        except TypeError:
            print '** Meeting {} does not have a start or end date. **'.format(meeting)
        custom_fields = attrs.pop('field_names', {})

        conf = Conference(
            endpoint=meeting, admins=admin_objs, **attrs
        )
        conf.field_names.update(custom_fields)
        try:
            conf.save()
        except ModularOdmException:
            conf = Conference.find_one(Q('endpoint', 'eq', meeting))
            for key, value in attrs.items():
                if isinstance(value, dict):
                    current = getattr(conf, key)
                    current.update(value)
                    setattr(conf, key, current)
                else:
                    setattr(conf, key, value)
            conf.admins = admin_objs
            changed_fields = conf.save()
            if changed_fields:
                print('Updated {}: {}'.format(meeting, changed_fields))
        else:
            print('Added new Conference: {}'.format(meeting))
开发者ID:atelic,项目名称:osf.io,代码行数:47,代码来源:populate_conferences.py

示例9: conference_results

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def conference_results(meeting):
    """Return the data for the grid view for a conference.

    :param str meeting: Endpoint name for a conference.
    """
    try:
        conf = Conference.find_one(Q('endpoint', 'iexact', meeting))
    except ModularOdmException:
        raise HTTPError(httplib.NOT_FOUND)

    data = conference_data(meeting)

    return {
        'data': data,
        'label': meeting,
        'meeting': conf.to_storage(),
        # Needed in order to use base.mako namespace
        'settings': settings,
    }
开发者ID:DataConservancy,项目名称:osf.io,代码行数:21,代码来源:views.py

示例10: conference_results

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def conference_results(meeting):
    """Return the data for the grid view for a conference.

    :param str meeting: Endpoint name for a conference.
    """
    try:
        conf = Conference.find_one(Q("endpoint", "iexact", meeting))
    except ModularOdmException:
        raise HTTPError(httplib.NOT_FOUND)

    data = conference_data(meeting)

    return {
        "data": json.dumps(data),
        "label": meeting,
        "meeting": conf.to_storage(),
        # Needed in order to use base.mako namespace
        "settings": settings,
    }
开发者ID:danielneis,项目名称:osf.io,代码行数:21,代码来源:views.py

示例11: populate_conferences

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def populate_conferences(email):
    for meeting, attrs in MEETING_DATA.iteritems():
        admin_objs = []
        try:
            user = User.find_one(Q('username', 'iexact', email))
            admin_objs.append(user)
        except ModularOdmException:
            raise RuntimeError('Username {0!r} is not registered.'.format(email))
        conf = Conference(
            endpoint=meeting, admins=admin_objs, **attrs
        )
        try:
            conf.save()
        except ModularOdmException:
            print('{0} Conference already exists. Updating existing record...'.format(meeting))
            conf = Conference.find_one(Q('endpoint', 'eq', meeting))
            for key, value in attrs.items():
                setattr(conf, key, value)
            conf.admins = admin_objs
            conf.save()
开发者ID:GageGaskins,项目名称:osf.io,代码行数:22,代码来源:dev_populate_conferences.py

示例12: populate_conferences

# 需要导入模块: from website.conferences.model import Conference [as 别名]
# 或者: from website.conferences.model.Conference import find_one [as 别名]
def populate_conferences():
    for meeting, attrs in MEETING_DATA.iteritems():
        custom_fields = attrs.pop("field_names", {})

        conf = Conference(endpoint=meeting, **attrs)
        conf.field_names.update(custom_fields)
        try:
            conf.save()
        except ModularOdmException:
            conf = Conference.find_one(Q("endpoint", "eq", meeting))
            for key, value in attrs.items():
                if isinstance(value, dict):
                    current = getattr(conf, key)
                    current.update(value)
                    setattr(conf, key, current)
                else:
                    setattr(conf, key, value)
            changed_fields = conf.save()
            if changed_fields:
                print("Updated {}: {}".format(meeting, changed_fields))
        else:
            print("Added new Conference: {}".format(meeting))
开发者ID:kch8qx,项目名称:osf.io,代码行数:24,代码来源:dev_populate_conferences.py


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