當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。