<commit_before>from elections.views import SoulMateDetailView
from votai_theme.calculator import YQSCalculator
from django.http import JsonResponse
from candidator.models import TakenPosition
from votai_theme.models import AnswerValue
from sorl.thumbnail import get_thumbnail
from django.views.decorators.clickjacking import xframe_options_exempt

class juegoView(SoulMateDetailView):
    @xframe_options_exempt
    def dispatch(self, *args, **kwargs):
        return super(juegoView, self).dispatch(*args, **kwargs)


class MediaNaranjaView(SoulMateDetailView):
    calculator_class = YQSCalculator

    @xframe_options_exempt
    def dispatch(self, *args, **kwargs):
        return super(MediaNaranjaView, self).dispatch(*args, **kwargs)


class MedianaranjaJsonView(MediaNaranjaView):
    @xframe_options_exempt
    def dispatch(self, *args, **kwargs):
        super(MedianaranjaJsonView, self).dispatch(*args, **kwargs)
        election = self.object
        response = {
            'election_id': election.id,
            "election_name": election.name,
            "district": election.area.name,
            # "level": election.extra_info['nivel'],
            # "post": election.extra_info['cargo'],
            "categories": [],
            "candidates": []

        }
        for category in election.categories.all():
            category_dict = {'category_id': category.id,
                             'name': category.name,
                             'questions': []
                             }
            for topic in category.topics.all():
                question_dict = {"question_id": topic.id,
                                 "question_text": topic.label,
                                 "answers": []
                                 }
                for position in topic.positions.all():
                    position_dict = {"answer_id": position.id,
                                     "answer_text": position.label
                                     }
                    try:
                        position_dict['answer_value'] = position.answervalue.value<commit_msg>Filtrando en el json por aquellas categorías que están ocultas<commit_after>from elections.views import SoulMateDetailView
from votai_theme.calculator import YQSCalculator
from django.http import JsonResponse
from candidator.models import TakenPosition
from votai_theme.models import AnswerValue, ExtraInfoTopic
from sorl.thumbnail import get_thumbnail
from django.views.decorators.clickjacking import xframe_options_exempt

class juegoView(SoulMateDetailView):
    @xframe_options_exempt
    def dispatch(self, *args, **kwargs):
        return super(juegoView, self).dispatch(*args, **kwargs)


class MediaNaranjaView(SoulMateDetailView):
    calculator_class = YQSCalculator

    @xframe_options_exempt
    def dispatch(self, *args, **kwargs):
        return super(MediaNaranjaView, self).dispatch(*args, **kwargs)


class MedianaranjaJsonView(MediaNaranjaView):
    @xframe_options_exempt
    def dispatch(self, *args, **kwargs):
        super(MedianaranjaJsonView, self).dispatch(*args, **kwargs)
        election = self.object
        response = {
            'election_id': election.id,
            "election_name": election.name,
            "district": election.area.name,
            # "level": election.extra_info['nivel'],
            # "post": election.extra_info['cargo'],
            "categories": [],
            "candidates": []

        }
        for category in election.categories.all():
            category_dict = {'category_id': category.id,
                             'name': category.name,
                             'questions': []
                             }
            extra_infos = [e.topic.id for e in ExtraInfoTopic.objects.filter(is_hidden=True, topic__category=category)]
            for topic in category.topics.exclude(id__in=extra_infos):
                question_dict = {"question_id": topic.id,
                                 "question_text": topic.label,
                                 "answers": []
                                 }
                for position in topic.positions.all():
                    position_dict = {"answer_id": position.id,
                                     "answer_text": position.label
                                     }
                    try:
                        position_dict['answer_value'] = position.answervalue.value
{'fraction_non_alphanumeric': 0.0944632768361582, 'fraction_numerical': 0.0, 'mean_word_length': 2.0252904989747096, 'pattern_counts': {'":': 22, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1418329', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1127, 'n_words': 234}