<commit_before>from datetime import date

from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.utils.translation import ugettext_lazy as _

from involvement.forms import ApplicationForm, ReferenceFormSet
from involvement.models import Position, Team, Application


def open_positions(request, context):
    """View redirect for the currently open positions"""
    # TODO: Limit accorting to inclusion/exclusion rules
    context['positions'] = Position.objects.filter(
        commencement__lte=date.today()
    ).filter(
        deadline__gte=date.today()
    )
    context['teams'] = Team.objects.all()
    return render(request, 'involvement/open_positions.html', context)


@login_required
def my_applications(request, context):
    """View redirect for the applications by user"""
    if request.method == 'POST':
        # TODO: Use form?
        try:
            action = request.POST.get('action')
            appl_id = request.POST.get('application')
            appl = Application.objects.get(id=appl_id)
            if appl.applicant != request.user:
                context['error'] = _('You cannot delete an application that '
                                     'is not yours!')
            elif appl.position.deadline < date.today():
                context['error'] = _('You cannot delete an application after '
                                     'its deadline has passed!')
            else:
                if action == 'delete':
                    appl.delete()
                    context['message'] = _('Your application has been removed!')
                else:
                    context['error'] = _('No action has been supplied!')
        except ObjectDoesNotExist:
            context['error'] = _('This application does not exist!')

    applications = Application.objects.filter(applicant=request.user).order_by(
        'position__deadline'
    )

    context['drafts'] = applications.filter(
        position__deadline__gte=date.today(),
        status='draft',
    )
    context['submitted'] = applications.filter(
        position__deadline__gte=date.today(),
        status='submitted',
    )
    context['waiting'] = applications.filter(
        Q(position__deadline__lt=date.today(), status='submitted')
        | Q(status='approved')
    )
    context['old'] = applications.filter(
        status__in=['disapproved', 'appointed', 'turned_down'],
    )

    return render(request, 'involvement/my_applications.html', context)

<commit_msg>:green_heart: Fix line length<commit_after>from datetime import date

from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.utils.translation import ugettext_lazy as _

from involvement.forms import ApplicationForm, ReferenceFormSet
from involvement.models import Position, Team, Application


def open_positions(request, context):
    """View redirect for the currently open positions"""
    # TODO: Limit accorting to inclusion/exclusion rules
    context['positions'] = Position.objects.filter(
        commencement__lte=date.today()
    ).filter(
        deadline__gte=date.today()
    )
    context['teams'] = Team.objects.all()
    return render(request, 'involvement/open_positions.html', context)


@login_required
def my_applications(request, context):
    """View redirect for the applications by user"""
    if request.method == 'POST':
        # TODO: Use form?
        try:
            action = request.POST.get('action')
            appl_id = request.POST.get('application')
            appl = Application.objects.get(id=appl_id)
            if appl.applicant != request.user:
                context['error'] = _('You cannot delete an application that '
                                     'is not yours!')
            elif appl.position.deadline < date.today():
                context['error'] = _('You cannot delete an application after '
                                     'its deadline has passed!')
            else:
                if action == 'delete':
                    appl.delete()
                    context['message'] = _('Your application has been '
                                           'removed!')
                else:
                    context['error'] = _('No action has been supplied!')
        except ObjectDoesNotExist:
            context['error'] = _('This application does not exist!')

    applications = Application.objects.filter(applicant=request.user).order_by(
        'position__deadline'
    )

    context['drafts'] = applications.filter(
        position__deadline__gte=date.today(),
        status='draft',
    )
    context['submitted'] = applications.filter(
        position__deadline__gte=date.today(),
        status='submitted',
    )
    context['waiting'] = applications.filter(
        Q(position__deadline__lt=date.today(), status='submitted')
        | Q(status='approved')
    )
    context['old'] = applications.filter(
        status__in=['disapproved', 'appointed', 'turned_down'],
    )

    return render(request, 'involvement/my_applications.html', context)


{'fraction_non_alphanumeric': 0.10619469026548672, 'fraction_numerical': 0.0011061946902654867, 'mean_word_length': 2.6166666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3489961', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1381, 'n_words': 347}