<commit_before># coding=utf8
from datetime import datetime, date

import simplejson as json
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.http import HttpResponse
from django.shortcuts import render
from django.utils import dateformat
from django.views.decorators.csrf import csrf_exempt

import directory.models as directory
import slog.models as slog
import users.models as users
from appconf.manager import SettingManager
from directions.models import Issledovaniya, TubesRegistration
from laboratory import settings
from laboratory.decorators import group_required
from podrazdeleniya.models import Podrazdeleniya, Subgroups


@csrf_exempt
@login_required
@group_required("Получатель биоматериала")
def receive(request):
    """Представление для приемщика материала в лаборатории"""

    if request.method == "GET":
        podrazdeleniya = Podrazdeleniya.objects.filter(isLab=False, hide=False).order_by("title")
        labs = Podrazdeleniya.objects.filter(isLab=True, hide=False).order_by("title")
        return render(request, 'dashboard/receive.html', {"labs": labs, "podrazdeleniya": podrazdeleniya})
    else:
        tubes = json.loads(request.POST["data"])
        for tube_get in tubes:
            tube = TubesRegistration.objects.get(id=tube_get["id"])
            if tube_get["status"]:
                tube.set_r(request.user.doctorprofile)
            elif tube_get["notice"] != "":
                tube.set_notice(request.user.doctorprofile, tube_get["notice"])

        result = {"r": True}
        return HttpResponse(json.dumps(result), content_type="application/json")


@csrf_exempt
@login_required
@group_required("Получатель биоматериала")
def receive_obo(request):
    if request.method == "GET":
        return render(request, 'dashboard/receive_one-by-one.html')
    if request.POST["pk"].isdigit():
        pk = int(request.POST["pk"])
        if TubesRegistration.objects.filter(pk=pk).exists() and Issledovaniya.objects.filter(tubes__id=pk).exists():
            tube = TubesRegistration.objects.get(pk=pk)
            if tube.getstatus():
                if tube.issledovaniya_set.first().research.subgroup.podrazdeleniye == request.user.doctorprofile.podrazileniye:
                    status = tube.day_num(request.user.doctorprofile, int(request.POST["num"]))
                    result = {"r": 1, "n": status["n"], "new": status["new"],
                              "receivedate": tube.time_recive.strftime("%d.%m.%Y"),
                              "researches": [x.research.title for x in Issledovaniya.objects.filter(tubes__id=pk)]}
                else:
                    result = {"r": 2, "lab": str(tube.issledovaniya_set.first().research.subgroup.podrazdeleniye)}
            else:
                otd = tube.issledovaniya_set.first().napravleniye.doc.podrazileniye
                if tube.issledovaniya_set.first().napravleniye.doc_who_create:
                    otd = tube.issledovaniya_set.first().napravleniye.doc_who_create.podrazileniye
                result = {"r": 4, "otd": str(otd), "direction": tube.issledovaniya_set.first().napravleniye.pk}
        else:
            result = {"r": 3}<commit_msg>добавление использования one_by_one<commit_after># coding=utf8
from datetime import datetime, date

import simplejson as json
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.http import HttpResponse
from django.shortcuts import render
from django.utils import dateformat
from django.views.decorators.csrf import csrf_exempt

import directory.models as directory
import slog.models as slog
import users.models as users
from appconf.manager import SettingManager
from directions.models import Issledovaniya, TubesRegistration
from laboratory import settings
from laboratory.decorators import group_required
from podrazdeleniya.models import Podrazdeleniya, Subgroups


@csrf_exempt
@login_required
@group_required("Получатель биоматериала")
def receive(request):
    """Представление для приемщика материала в лаборатории"""

    if request.method == "GET":
        podrazdeleniya = Podrazdeleniya.objects.filter(isLab=False, hide=False).order_by("title")
        labs = Podrazdeleniya.objects.filter(isLab=True, hide=False).order_by("title")
        return render(request, 'dashboard/receive.html', {"labs": labs, "podrazdeleniya": podrazdeleniya})
    else:
        tubes = json.loads(request.POST["data"])
        for tube_get in tubes:
            tube = TubesRegistration.objects.get(id=tube_get["id"])
            if tube_get["status"]:
                tube.set_r(request.user.doctorprofile)
            elif tube_get["notice"] != "":
                tube.set_notice(request.user.doctorprofile, tube_get["notice"])

        result = {"r": True}
        return HttpResponse(json.dumps(result), content_type="application/json")


@csrf_exempt
@login_required
@group_required("Получатель биоматериала")
def receive_obo(request):
    if request.method == "GET":
        return render(request, 'dashboard/receive_one-by-one.html')
    if request.POST["pk"].isdigit():
        pk = int(request.POST["pk"])
        if TubesRegistration.objects.filter(pk=pk).exists() and Issledovaniya.objects.filter(tubes__id=pk).exists():
            tube = TubesRegistration.objects.get(pk=pk)
            if tube.getstatus(one_by_one=True):
                if tube.issledovaniya_set.first().research.subgroup.podrazdeleniye == request.user.doctorprofile.podrazileniye:
                    status = tube.day_num(request.user.doctorprofile, int(request.POST["num"]))
                    result = {"r": 1, "n": status["n"], "new": status["new"],
                              "receivedate": tube.time_recive.strftime("%d.%m.%Y"),
                              "researches": [x.research.title for x in Issledovaniya.objects.filter(tubes__id=pk)]}
                else:
                    result = {"r": 2, "lab": str(tube.issledovaniya_set.first().research.subgroup.podrazdeleniye)}
            else:
                otd = tube.issledovaniya_set.first().napravleniye.doc.podrazileniye
                if tube.issledovaniya_set.first().napravleniye.doc_who_create:
                    otd = tube.issledovaniya_set.first().napravleniye.doc_who_create.podrazileniye
                result = {"r": 4, "otd": str(otd), "direction": tube.issledovaniya_set.first().napravleniye.pk}
        else:
            result = {"r": 3}
{'fraction_non_alphanumeric': 0.11597104574156784, 'fraction_numerical': 0.0015401201293700909, 'mean_word_length': 3.2808174027686223, 'pattern_counts': {'":': 34, '<': 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': '1040538', 'n_tokens_mistral': 2053, 'n_tokens_neox': 1964, 'n_words': 377}