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


Python links.UserLink类代码示例

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


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

示例1: unlink_to

    def unlink_to(self, obj, role):
        """Removes a link between the user and an object

        :param obj: a legacy object
        :param role: the role to use in the link
        """
        return UserLink.remove_link(self, obj, role)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: link_to

    def link_to(self, obj, role):
        """Adds a link between the user and an object

        :param obj: a legacy object
        :param role: the role to use in the link
        """
        return UserLink.create_link(self, obj, role)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例3: migrate_links

    def migrate_links(self):
        print cformat('%{white!}migrating links')
        for avatars in grouper(self._iter_avatars(), 2500, skip_missing=True):
            avatars = {int(a.id): a for a in avatars}
            users = ((u, avatars[u.id]) for u in User.find(User.id.in_(avatars)))

            for user, avatar in committing_iterator(self.flushing_iterator(users, 250), 2500):
                registrants = set()
                user_shown = False
                for type_, entries in avatar.linkedTo.iteritems():
                    # store registrant roles, in order to avoid duplication below
                    for role, objects in entries.iteritems():
                        if (type_ == 'category' and role == 'favorite') or type_ == 'group':
                            continue
                        if not objects:
                            continue
                        if type_ == 'registration' and role == 'registrant':
                            registrants |= set(objects)
                        if not user_shown:
                            print cformat('%{green}+++%{reset} '
                                          '%{white!}{:6d}%{reset} %{cyan}{}%{reset}').format(user.id, user.full_name)
                            user_shown = True
                        print cformat('%{blue!}<->%{reset}        '
                                      '%{yellow!}{:4d}%{reset}x  %{green!}{:12}  %{cyan!}{}%{reset}').format(
                            len(objects), type_, role)
                        for obj in objects:
                            try:
                                UserLink.create_link(user, obj, role, type_)
                            except Exception as e:
                                print cformat('%{red!}!!!%{reset}        '
                                              '%{red!}linking failed%{reset} (%{yellow!}{}%{reset}): '
                                              '{}').format(unicode(e), obj)

                # add old "registrant" entries to registration/registrant
                for reg in getattr(avatar, 'registrants', {}).itervalues():
                    if reg.getConference().getOwner() and reg not in registrants:
                        UserLink.create_link(user, reg, 'registrant', 'registration')
                        print cformat('%{cyan!}<->%{reset}        '
                                      '%{yellow!}   1%{reset}x  %{green!}{:12}  %{cyan!}{}%{reset}').format(
                            'registration', 'registrant')
开发者ID:fph,项目名称:indico,代码行数:40,代码来源:users.py

示例4: get_linked_objects

 def get_linked_objects(self, type_, role):
     """Retrieves linked objects for the user"""
     return UserLink.get_links(self, type_, role)
开发者ID:,项目名称:,代码行数:3,代码来源:

示例5: get_linked_roles

 def get_linked_roles(self, type_):
     """Retrieves the roles the user is linked to for a given type"""
     return UserLink.get_linked_roles(self, type_)
开发者ID:,项目名称:,代码行数:3,代码来源:


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