<commit_before>from django.http.response import Http404, HttpResponseRedirect
import models
import constants

from django.views.generic import DetailView
from django.views.generic.detail import SingleObjectMixin
from django.views.generic.base import View

from core.utils import LoginMixin
from class_based_comments.views import CommentViewGeneric


class VotingDetail(LoginMixin, DetailView, CommentViewGeneric):
    template_name = 'voting_round.html'
    view_name = 'voting'
    model = models.VotingRound
    context_object_name = 'voting_round'


class CastVote(LoginMixin, SingleObjectMixin, View):
    """
    View for casting votes... Be design it is not secure against malicious
    linking.
    """
    model = models.VotingRound

    def get(self, request, **kwargs):
        voting_round = self.get_object()
        action = kwargs['action']
        if action not in constants.VOTES:
            raise Http404()

        vote, created = models.Vote.objects.get_or_create(
            author=request.user,<commit_msg>I like my imports sorted<commit_after>import models
import constants

from django.views.generic import DetailView
from django.views.generic.detail import SingleObjectMixin
from django.views.generic.base import View
from django.http.response import Http404, HttpResponseRedirect

from core.utils import LoginMixin
from class_based_comments.views import CommentViewGeneric


class VotingDetail(LoginMixin, DetailView, CommentViewGeneric):
    template_name = 'voting_round.html'
    view_name = 'voting'
    model = models.VotingRound
    context_object_name = 'voting_round'


class CastVote(LoginMixin, SingleObjectMixin, View):
    """
    View for casting votes... Be design it is not secure against malicious
    linking.
    """
    model = models.VotingRound

    def get(self, request, **kwargs):
        voting_round = self.get_object()
        action = kwargs['action']
        if action not in constants.VOTES:
            raise Http404()

        vote, created = models.Vote.objects.get_or_create(
            author=request.user,
{'fraction_non_alphanumeric': 0.0763653939101015, 'fraction_numerical': 0.005799903334944417, 'mean_word_length': 3.715261958997722, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2844467', 'n_tokens_mistral': 589, 'n_tokens_neox': 572, 'n_words': 161}