def user_page(request, username, subpage=None): ''' profile page for a user ''' try: user = get_user_from_username(username) except models.User.DoesNotExist: return HttpResponseNotFound() if is_api_request(request): # we have a json request return JsonResponse(activitypub.get_actor(user)) # otherwise we're at a UI view # TODO: change display with privacy and authentication considerations data = { 'user': user, 'is_self': request.user.id == user.id, } if subpage == 'followers': data['followers'] = user.followers.all() return TemplateResponse(request, 'followers.html', data) elif subpage == 'following': data['following'] = user.following.all() return TemplateResponse(request, 'following.html', data) elif subpage == 'shelves': data['shelves'] = user.shelf_set.all() return TemplateResponse(request, 'user_shelves.html', data) else: shelves = get_user_shelf_preview(user) data['shelves'] = shelves activities = get_activity_feed(user, 'self')[:15] data['activities'] = activities return TemplateResponse(request, 'user.html', data)
def get_actor(request, username): ''' return an activitypub actor object ''' if request.method != 'GET': return HttpResponseBadRequest() user = models.User.objects.get(localname=username) return JsonResponse(activitypub.get_actor(user))
def get_actor(request, username): ''' return an activitypub actor object ''' if request.method != 'GET': return HttpResponseBadRequest() try: user = models.User.objects.get(localname=username) except models.User.DoesNotExist: return HttpResponseNotFound() return JsonResponse(activitypub.get_actor(user))
def handle_update_user(user): ''' broadcast editing a user's profile ''' actor = activitypub.get_actor(user) update_activity = activitypub.get_update(user, actor) broadcast(user, update_activity)
def activitypub_serialize(self): return activitypub.get_actor(self)
def handle_update_user(user): ''' broadcast editing a user's profile ''' actor = activitypub.get_actor(user) update_activity = activitypub.get_update(user, actor) recipients = get_recipients(user, 'public') broadcast(user, update_activity, recipients)