<commit_before>from django.contrib import messages
from django.http import HttpResponseRedirect, Http404
from django_filters.views import FilterView
from django_tables2 import SingleTableMixin

from app.mixins import TabsViewMixin
from app.views import TabsView
from applications import models
from checkin.models import CheckIn
from checkin.tables import ApplicationsCheckInTable, ApplicationCheckinFilter, \
    SponsorApplicationsCheckInTable, SponsorApplicationCheckinFilter
from user.mixins import IsVolunteerMixin, HaveVolunteerPermissionMixin, HaveMentorPermissionMixin, \
    HaveSponsorPermissionMixin
from organizers.views import volunteer_tabs, mentor_tabs, hacker_tabs, sponsor_tabs


def get_application_by_type(type, uuid):
    if type == models.userModels.USR_HACKER:
        return models.HackerApplication.objects.filter(uuid=uuid).first()
    elif type == models.userModels.USR_VOLUNTEER:
        return models.VolunteerApplication.objects.filter(uuid=uuid).first()
    elif type == models.userModels.USR_SPONSOR:
        return models.SponsorApplication.objects.filter(uuid=uuid).first()
    elif type == models.userModels.USR_MENTOR:
        return models.MentorApplication.objects.filter(uuid=uuid).first()
    return None


class CheckInList(IsVolunteerMixin, TabsViewMixin, SingleTableMixin, FilterView):
    template_name = 'checkin/list.html'
    table_class = ApplicationsCheckInTable
    filterset_class = ApplicationCheckinFilter
    table_pagination = {'per_page': 50}

    def get_current_tabs(self):
        return hacker_tabs(self.request.user)

    def get_queryset(self):
        return models.HackerApplication.objects.filter(status=models.APP_CONFIRMED)


class CheckInHackerView(IsVolunteerMixin, TabsView):
    template_name = 'checkin/hacker.html'

    def get_back_url(self):
        return 'javascript:history.back()'

    def get_context_data(self, **kwargs):
        context = super(CheckInHackerView, self).get_context_data(**kwargs)
        appid = kwargs['id']
        type = kwargs['type']
        type = models.userModels.USR_URL_TYPE_CHECKIN[type]
        app = get_application_by_type(type, appid)
        if not app:
            raise Http404<commit_msg>Fix tab volunteers on checkin<commit_after>from django.contrib import messages
from django.http import HttpResponseRedirect, Http404
from django_filters.views import FilterView
from django_tables2 import SingleTableMixin

from app.mixins import TabsViewMixin
from app.views import TabsView
from applications import models
from checkin.models import CheckIn
from checkin.tables import ApplicationsCheckInTable, ApplicationCheckinFilter, \
    SponsorApplicationsCheckInTable, SponsorApplicationCheckinFilter
from user.mixins import IsVolunteerMixin, HaveVolunteerPermissionMixin, HaveMentorPermissionMixin, \
    HaveSponsorPermissionMixin
from organizers.views import volunteer_tabs, mentor_tabs, hacker_tabs, sponsor_tabs


def get_application_by_type(type, uuid):
    if type == models.userModels.USR_HACKER:
        return models.HackerApplication.objects.filter(uuid=uuid).first()
    elif type == models.userModels.USR_VOLUNTEER:
        return models.VolunteerApplication.objects.filter(uuid=uuid).first()
    elif type == models.userModels.USR_SPONSOR:
        return models.SponsorApplication.objects.filter(uuid=uuid).first()
    elif type == models.userModels.USR_MENTOR:
        return models.MentorApplication.objects.filter(uuid=uuid).first()
    return None


class CheckInList(IsVolunteerMixin, TabsViewMixin, SingleTableMixin, FilterView):
    template_name = 'checkin/list.html'
    table_class = ApplicationsCheckInTable
    filterset_class = ApplicationCheckinFilter
    table_pagination = {'per_page': 50}

    def get_current_tabs(self):
        if self.request.user.is_volunteer_accepted:
            return None
        return hacker_tabs(self.request.user)

    def get_queryset(self):
        return models.HackerApplication.objects.filter(status=models.APP_CONFIRMED)


class CheckInHackerView(IsVolunteerMixin, TabsView):
    template_name = 'checkin/hacker.html'

    def get_back_url(self):
        return 'javascript:history.back()'

    def get_context_data(self, **kwargs):
        context = super(CheckInHackerView, self).get_context_data(**kwargs)
        appid = kwargs['id']
        type = kwargs['type']
        type = models.userModels.USR_URL_TYPE_CHECKIN[type]
        app = get_application_by_type(type, appid)
        if not app:
            raise Http404
{'fraction_non_alphanumeric': 0.07774322523322967, 'fraction_numerical': 0.003998223011994669, 'mean_word_length': 4.614713216957606, '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': '3463757', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1307, 'n_words': 267}