Skip to content
Snippets Groups Projects
Commit 71d886fa authored by dcz's avatar dcz
Browse files

Refactoring

parent e8060f67
Branches
Tags
No related merge requests found
......@@ -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'),
]
......@@ -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({})
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment