<commit_before>from pprint import pprint
from datetime import timedelta
# import pandas as pd

from django.core import serializers
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db import connections, connection
from django.db.models import Count, Sum, Q, Value
from django.db.models.functions import Coalesce
from django.contrib.auth.mixins \
    import PermissionRequiredMixin, LoginRequiredMixin
from django.shortcuts import render
from django.views import View
from django.urls import reverse
from django.http import JsonResponse

from fo2.models import rows_to_dict_list_lower, GradeQtd
from fo2.template import group_rowspan

from utils.views import totalize_grouped_data
import lotes.models
from geral.functions import request_user, has_permission

import cd.models as models
import cd.forms


def index(request):
    context = {}
    return render(request, 'cd/index.html', context)


def teste_som(request):
    context = {}
    return render(request, 'cd/teste_som.html', context)


class LotelLocal(PermissionRequiredMixin, View):
    permission_required = 'lotes.can_inventorize_lote'
    Form_class = cd.forms.LoteForm
    template_name = 'cd/lote_local.html'
    title_name = 'Inventariar'

    def mount_context(self, request, form):
        cursor = connections['so'].cursor()

        endereco = form.cleaned_data['endereco']
        lote = form.cleaned_data['lote']
        periodo = lote[:4]
        ordem_confeccao = lote[-5:]
        identificado = form.cleaned_data['identificado']

        if endereco == 'SAI':
            endereco = None

        context = {'endereco': endereco}

        lote_sys = lotes.models.posicao_get_item(
            cursor, periodo, ordem_confeccao)
        if len(lote_sys) == 0:
            if endereco is not None:
                context.update({
                    'erro': 'Lote não encontrado no Systêxtil. Única ação '
                            'possivel é dar saída (Endereço "SAI").'})
                return context

        try:
            lote_rec = lotes.models.Lote.objects.get(lote=lote)
        except lotes.models.Lote.DoesNotExist:
            context.update({'erro': 'Lote não encontrado'})
            return context<commit_msg>lote de MD só pode sair do inventário<commit_after>from pprint import pprint
from datetime import timedelta
# import pandas as pd

from django.core import serializers
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db import connections, connection
from django.db.models import Count, Sum, Q, Value
from django.db.models.functions import Coalesce
from django.contrib.auth.mixins \
    import PermissionRequiredMixin, LoginRequiredMixin
from django.shortcuts import render
from django.views import View
from django.urls import reverse
from django.http import JsonResponse

from fo2.models import rows_to_dict_list_lower, GradeQtd
from fo2.template import group_rowspan

from utils.views import totalize_grouped_data
import lotes.models
from geral.functions import request_user, has_permission

import cd.models as models
import cd.forms


def index(request):
    context = {}
    return render(request, 'cd/index.html', context)


def teste_som(request):
    context = {}
    return render(request, 'cd/teste_som.html', context)


class LotelLocal(PermissionRequiredMixin, View):
    permission_required = 'lotes.can_inventorize_lote'
    Form_class = cd.forms.LoteForm
    template_name = 'cd/lote_local.html'
    title_name = 'Inventariar'

    def mount_context(self, request, form):
        cursor = connections['so'].cursor()

        endereco = form.cleaned_data['endereco']
        lote = form.cleaned_data['lote']
        periodo = lote[:4]
        ordem_confeccao = lote[-5:]
        identificado = form.cleaned_data['identificado']

        if endereco == 'SAI':
            endereco = None

        context = {'endereco': endereco}

        lote_sys = lotes.models.posicao_get_item(
            cursor, periodo, ordem_confeccao)
        if len(lote_sys) == 0:
            if endereco is not None:
                context.update({
                    'erro': 'Lote não encontrado no Systêxtil. Única ação '
                            'possivel é dar saída (Endereço "SAI").'})
                return context

        try:
            lote_rec = lotes.models.Lote.objects.get(lote=lote)
        except lotes.models.Lote.DoesNotExist:
            context.update({'erro': 'Lote não encontrado'})
            return context

        if lote_rec.referencia >= 'C0000':
            if endereco is not None:
                context.update({
                    'erro': 'Lote de MD. Única ação '
                            'possivel é dar saída (Endereço "SAI").'})
                return context
{'fraction_non_alphanumeric': 0.08476349937212223, 'fraction_numerical': 0.0029300962745918793, 'mean_word_length': 2.847826086956522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1949139', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1427, 'n_words': 379}