Permissions model Profile field id custom True self_protect True owner

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
@Permissions(model=Profile, field="id", custom=True, self_protect=True, owner_field="user_ptr")
@check_score(score=settings.PROFILE_VOTE_SCORE, rank=variables.NEWBIE)
def vote_down_profile(request, object_id):
user = get_object_or_404(Profile, pk=object_id)
content_type = ContentType.objects.get_for_model(user)
if not get_object_or_None(Vote, user=request.user, content_type=content_type, object_id=object_id):
Vote.objects.record_vote(user, request.user, -1)
title = _(u"New vote recived")
content = _(u"<a href='%(link)s'>%(username)s</a> has voted against you" % {'link': request.user.show_url(), 'username': request.user.title})
Report.objects.create(title=title, content=content, user=user)
return HttpResponseRedirect(user.show_url())