<commit_before>import csv
import operator

from django.template import RequestContext
from django.forms.extras.widgets import SelectDateWidget
from django.db import connection
from django.db.models import Q
from django.utils import simplejson as json
from django.http import HttpResponse, HttpResponseRedirect
from django.core.mail import send_mail

import forms
import models
from systems import models as system_models
from datetime import datetime, timedelta
from libs import ldap_lib
import settings
from settings.local import USER_SYSTEM_ALLOWED_DELETE, FROM_EMAIL_ADDRESS, UNAUTHORIZED_EMAIL_ADDRESS
from django.shortcuts import render_to_response, redirect, get_object_or_404
from django.views.decorators.csrf import csrf_exempt
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
@csrf_exempt
def owners_quicksearch_ajax(request):
    """Returns systems sort table"""
    search = request.POST['quicksearch']
    filters = [Q(**{"%s__icontains" % t: search})
                    for t in models.Owner.search_fields]

    owners = models.Owner.objects.filter(
                reduce(operator.or_, filters))

    return render_to_response('user_systems/owners_quicksearch.html', {
            'owners': owners,
           },
           RequestContext(request))
@csrf_exempt
def license_edit(request, object_id):
    license = get_object_or_404(models.UserLicense, pk=object_id)
    if request.method == 'POST':
        form = forms.UserLicenseForm(request.POST, instance=license)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/user_systems/licenses/')
    else:
        form = forms.UserLicenseForm(instance=license)

    return render_to_response('user_systems/userlicense_form.html', {
            'form': form,
           },
           RequestContext(request))
def owner_list(request):
    owners = models.Owner.objects.select_related('user_location').all()
    upgradeable_users = models.Owner.objects.filter(unmanagedsystem__date_purchased__lt=datetime.now() - timedelta(days=730)).distinct().count()
    return render_to_response('user_systems/owner_list.html', {
            'owner_list': owners,
            'upgradeable_users':upgradeable_users,
           },
           RequestContext(request))
def owner_show(request, object_id):
    owner = get_object_or_404(models.UserLicense, pk=object_id)

    return render_to_response('user_systems/owner_detail.html', {
            'owner': owner,
           },
           RequestContext(request))
@csrf_exempt
def owner_create(request):
    initial = {}
    if request.method == 'POST':<commit_msg>Resolved issue with owner display page not working<commit_after>import csv
import operator

from django.template import RequestContext
from django.forms.extras.widgets import SelectDateWidget
from django.db import connection
from django.db.models import Q
from django.utils import simplejson as json
from django.http import HttpResponse, HttpResponseRedirect
from django.core.mail import send_mail

import forms
import models
from systems import models as system_models
from datetime import datetime, timedelta
from libs import ldap_lib
import settings
from settings.local import USER_SYSTEM_ALLOWED_DELETE, FROM_EMAIL_ADDRESS, UNAUTHORIZED_EMAIL_ADDRESS
from django.shortcuts import render_to_response, redirect, get_object_or_404
from django.views.decorators.csrf import csrf_exempt
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
@csrf_exempt
def owners_quicksearch_ajax(request):
    """Returns systems sort table"""
    search = request.POST['quicksearch']
    filters = [Q(**{"%s__icontains" % t: search})
                    for t in models.Owner.search_fields]

    owners = models.Owner.objects.filter(
                reduce(operator.or_, filters))

    return render_to_response('user_systems/owners_quicksearch.html', {
            'owners': owners,
           },
           RequestContext(request))
@csrf_exempt
def license_edit(request, object_id):
    license = get_object_or_404(models.UserLicense, pk=object_id)
    if request.method == 'POST':
        form = forms.UserLicenseForm(request.POST, instance=license)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/user_systems/licenses/')
    else:
        form = forms.UserLicenseForm(instance=license)

    return render_to_response('user_systems/userlicense_form.html', {
            'form': form,
           },
           RequestContext(request))
def owner_list(request):
    owners = models.Owner.objects.select_related('user_location').all()
    upgradeable_users = models.Owner.objects.filter(unmanagedsystem__date_purchased__lt=datetime.now() - timedelta(days=730)).distinct().count()
    return render_to_response('user_systems/owner_list.html', {
            'owner_list': owners,
            'upgradeable_users':upgradeable_users,
           },
           RequestContext(request))
def owner_show(request, object_id):
    owner = get_object_or_404(models.Owner, pk=object_id)

    return render_to_response('user_systems/owner_detail.html', {
            'owner': owner,
           },
           RequestContext(request))
@csrf_exempt
def owner_create(request):
    initial = {}
    if request.method == 'POST':
{'fraction_non_alphanumeric': 0.09089187653853437, 'fraction_numerical': 0.0045445938269267185, 'mean_word_length': 3.8458715596330277, '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': '7182731', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1463, 'n_words': 328}