From 71d886fafbc47f17540c7a718f6b8d6cf8db01de Mon Sep 17 00:00:00 2001 From: dcz <dcz@ipipan.waw.pl> Date: Mon, 30 Oct 2023 16:13:14 +0100 Subject: [PATCH] Refactoring --- freelus/urls.py | 3 ++- freelus/views.py | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/freelus/urls.py b/freelus/urls.py index 6b44695..d7de51e 100644 --- a/freelus/urls.py +++ b/freelus/urls.py @@ -10,7 +10,8 @@ urlpatterns = [ path('change_role/', views.change_role, name='change_role'), path('attach_examples_to_frame/', views.attach_examples_to_frame, name='attach_examples_to_frame'), path('attach_schema_to_argument/', views.attach_schema_to_argument, name='attach_schema_to_argument'), - path('delete_schema_to_argument_connection/', views.delete_schema_to_argument_connection, name='delete_schema_to_argument_connection'), + path('delete_schema_to_argument_connection/', views.delete_schema_to_argument_connection, + name='delete_schema_to_argument_connection'), path('finish_frame_processing/', views.finish_frame_processing, name='finish_frame_processing'), ] diff --git a/freelus/views.py b/freelus/views.py index fa482e2..a32a18c 100644 --- a/freelus/views.py +++ b/freelus/views.py @@ -4,10 +4,9 @@ from django.http import JsonResponse from common.decorators import ajax_required from connections.models import Entry, Status, ExampleConnection, SchemaHook, ArgumentConnection, RealisationDescription -from examples.models import Example from meanings.models import LexicalUnit -from semantics.models import Frame, FrameOpinion, Argument, ArgumentRole, SemanticRole, RoleAttribute, RoleSubAttribute, \ - RoleType +from semantics.models import Frame, FrameOpinion, Argument, ArgumentRole, SemanticRole, \ + RoleAttribute, RoleSubAttribute, RoleType @ajax_required @@ -17,7 +16,7 @@ def change_status(request): entry_id = request.POST['entry_id'] status = request.POST['status'] - entry = Entry.get(pk=entry_id) + entry = Entry.objects.get(pk=entry_id) entry.status = Status.objects.get(key=status) entry.save() return JsonResponse({}) @@ -88,7 +87,8 @@ def change_role_base(frame_argument, request): sub_attribute_id=sub_attribute_id).first() if argument_role is None: argument_role = ArgumentRole(role=SemanticRole.objects.get(pk=role_id), - attribute=None if attribute_id is None else RoleAttribute.objects.get(pk=attribute_id), + attribute=None if attribute_id is None else RoleAttribute.objects.get( + pk=attribute_id), sub_attribute=RoleSubAttribute.objects.get(pk=sub_attribute_id)) argument_role.save() @@ -133,13 +133,16 @@ def attach_schema_to_argument(request): schema_hooks = SchemaHook.objects.filter(schema_id=schema_id, position_id=schema_position_id) if len(schema_hooks) > 0: schema_hook = schema_hooks[0] - argument_connection, xxx = ArgumentConnection.objects.get_or_create(argument=argument, defaults={'argument': argument}) + argument_connection, xxx = ArgumentConnection.objects.get_or_create(argument=argument, + defaults={'argument': argument}) argument_connection.save() argument_connection.schema_connections.add(schema_hook) argument_connection.save() - realisation_description = RealisationDescription.objects.get_or_create(frame_id=frame_id, schema_id=schema_id, - defaults={'alternation': 1, 'description': ''}) + RealisationDescription.objects.get_or_create(frame_id=frame_id, + schema_id=schema_id, + defaults={'alternation': 1, + 'description': ''}) return JsonResponse({}) @@ -148,7 +151,6 @@ def attach_schema_to_argument(request): @transaction.atomic def delete_schema_to_argument_connection(request): if request.method == 'POST': - frame_id = request.POST['frame_id'] argument_id = request.POST['argument_id'] schema_id = request.POST['schema_id'] schema_position_id = request.POST['schema_position_id'] @@ -175,4 +177,3 @@ def finish_frame_processing(request): frame.save() return JsonResponse({}) - -- GitLab