Пример #1
0
    def test_profile(self):
        from motion.models import LocalProfile
        p = LocalProfile(user_id='6paf37603c44724b3a', hiphop_name='dj fred')
        p.save()

        u = User(id='6paf37603c44724b3a')

        self.assertEquals(u.get_profile(), p)
Пример #2
0
    def test_profile(self):
        from motion.models import LocalProfile
        p = LocalProfile(user_id='6paf37603c44724b3a',
            hiphop_name='dj fred')
        p.save()

        u = User(id='6paf37603c44724b3a')

        self.assertEquals(u.get_profile(), p)
Пример #3
0
def backface(request):
    TypePadObject.batch_requests = False

    faces = list(all_items(request.group.events))

    # Get all the faces.
    author_faces = defaultdict(list)
    for newface in faces:
        if 'tag:api.typepad.com,2009:NewAsset' not in newface.verbs:
            continue
        face = newface.object
        if face is None:
            continue
        au = face.author.xid
        author_faces[au].append(face)

    # Put each author's faces in published order (though they're probably already in that order).
    for author, au_faces in author_faces.items():
        author_faces[author] = sorted(au_faces, key=lambda x: x.published)

    for author, au_faces in author_faces.items():
        # Missing Lastface? Add one in.
        try:
            Lastface.objects.get(owner=author)
        except Lastface.DoesNotExist:
            # OHNOES MISSING LASTFACE
            log.info("Filling in %r's Lastface", au_faces[-1].author.display_name)
            au_face = au_faces[-1]
            Lastface(owner=author, face=au_face.xid,
                created=au_face.published).save()

        # Go through the author's favorites, filling in any missing Favoritefaces.
        events = User.get_by_url_id(author).events.filter(by_group=request.group.xid)
        for fav in all_items(events):
            if 'tag:api.typepad.com,2009:AddedFavorite' not in fav.verbs:
                continue

            # Is there a Favoriteface for that?
            favoriter = fav.actor.xid
            try:
                Favoriteface.objects.get(favoriter=favoriter,
                    favorited=fav.object.xid)
            except Favoriteface.DoesNotExist:
                # NO FAVFACE OHNOES
                log.info("Filling in %r's Favoriteface for %r", au_faces[-1].author.display_name, fav.object.xid)
                when = fav.published
                au_faces_before = [x for x in au_faces if x.published < when]
                if not au_faces_before:
                    continue
                au_face = au_faces_before[-1]

                favface = Favoriteface(favoriter=favoriter, favorited=fav.object.xid)
                favface.lastface = au_face.xid
                favface.created = fav.published
                favface.save()

    return HttpResponse('OK', content_type='text/plain')
Пример #4
0
 def select_from_typepad(self, request, page=1, view='popular', *args, **kwargs):
     self.paginate_template = reverse('popular') + '/page/%d'
     user = User.get_by_url_id(settings.POPULAR_USER[0])
     self.context['favorites'] = user.favorites.filter(
         start_index=self.offset, max_results=self.limit)
     self.context['following'] = user.following(group=request.group)
Пример #5
0
 def user(self):
     return User.get_by_id(self.user_id)
Пример #6
0
 def user(self):
     return User.get_by_id(self.user_id)