def render(self, request, place, content, context, *args, **kwargs): readonly = self.get_config().get('readonly').get_value() if self.match_type(content): return self.render_block(request, template_name='voting/block_voting.html', block_title=_('Vote content'), context={'content': content, 'can_vote': get_can_vote(content, request.user), 'readonly': readonly}) else: return ''
def voting(context, content, readonly=False): try: vote = content.vote_set.get() vote_value = vote.vote * DEFAULT_STAR_IMG_WIDTH except Vote.DoesNotExist: vote = None vote_value = 0 return {'content': content, 'vote': vote, 'vote_value': vote_value, 'stars': get_vote_choices(), 'user': context.get('user'), 'can_vote': get_can_vote(content, context.get('user')), 'readonly': readonly, }