def user_page_subscribe(request, user_id): c = get_common_context(request) c['u'] = User.objects.get(id=user_id) if request.user.is_authenticated(): Subscribe.to_subsribe(request.user, c['u']) messages.success(request, u'Вы успешно подписались на данного автора.') else: messages.error(request, u'Для выполнения этого действия необходимо авторизироваться.') return HttpResponseRedirect('/user/%s/' % user_id)
def user_page(request, user_id): c = get_common_context(request) c['u'] = User.objects.get(id=user_id) c['u_profile'] = c['u'].get_profile if request.user.is_authenticated(): c['subscribed'] = Subscribe.has_subsribe(request.user, c['u']) c['is_me'] = (request.user == c['u']) c['fun_count'] = Work.objects.filter(author=request.user).count() c['collab_count'] = request.user.collaborator.all().count() c['comm_count'] = Comment.objects.filter(user=request.user).count() funfics = Work.get_by_author(c['u']) c['funfics_by_date'] = funfics.order_by('-last_editing_time')[:FUNCICS_COUNT_ON_PAGE] c['funfics_by_vizits'] = funfics.order_by('-vizits')[:FUNCICS_COUNT_ON_PAGE] c['funfics_by_comments'] = funfics.order_by('-commetns')[:FUNCICS_COUNT_ON_PAGE] c['funfics_by_rating'] = funfics.order_by('-mark')[:FUNCICS_COUNT_ON_PAGE] c['title'] = u'Автор - %s' % c['u'].get_profile().nick c['num_loop'] = ['#']+[i for i in range(10)] c['eng_loop'] = [chr(i) for i in xrange(ord('A'), ord('Z'))] c['rus_loop'] = [unichr(i) for i in xrange(ord(u'А'), ord(u'Я'))] return render_to_response('new_user.html', c, context_instance=RequestContext(request))
def get_subscribers(self): return Subscribe.get_subsribers(self.user)