diff --git a/frontend/src/components/unification/shared/LexicalUnitDisplay.vue b/frontend/src/components/unification/shared/LexicalUnitDisplay.vue index d72961c6fad2c395fda3743b6a4a5b0b3d8e77f9..1fcce5021bdf1e0c658a5a6f17ecbe57738dd3db 100644 --- a/frontend/src/components/unification/shared/LexicalUnitDisplay.vue +++ b/frontend/src/components/unification/shared/LexicalUnitDisplay.vue @@ -78,24 +78,6 @@ export default { show_error(errorType + ' (' + errorMessage + ')'); }, 300000) - - // $("#overlay").fadeIn(300); - // $.ajax({ - // type : 'post', - // url : `/${lang}/unifier/frame_assign/`, - // dataType : 'json', - // data: data, - // timeout : 300000, - // success: function (response) { - // $("#overlay").fadeOut(300); - // show_info('Rama została stworzona oraz przypisana użytkownikowi.'); - // this.goToEdit(response.unified_frame_id, this.entryId, this.lexicalUnitId); - // }.bind(this), - // error: function (request, errorType, errorMessage) { - // $("#overlay").fadeOut(300); - // show_error(errorType + ' (' + errorMessage + ')'); - // } - // }); } else { alert(gettext("Nazwa zunifikowanej ramy nie jest unikalna. Proszę wybrać inną nazwę.")); } @@ -166,17 +148,6 @@ export default { setup () { $('#lexical-unit-notes').html(''); - // get_entry(this.entryId, false, this.lexicalUnitId).then(entry => { - // this.frame = entry.frames[0]; - // this.unifiedFrame = entry.unified_frame; - // this.subentries = entry.subentries; - // this.alternations = entry.alternations; - // this.realisation_phrases = entry.realisation_phrases; - // this.realisation_descriptions = entry.realisation_descriptions; - // this.examples = entry.examples; - // setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes); - // }); - var data = { 'entry' : this.entryId, 'no_filters' : false, 'lexical_unit_id': this.lexicalUnitId }; $.ajax({ type : 'post', diff --git a/semantics/views.py b/semantics/views.py index da49e6a191ad1da53c4dc6ee9bef47f8677fe582..8e7a313296351b695e7d62a489dce3aeb8c6edde 100644 --- a/semantics/views.py +++ b/semantics/views.py @@ -1,9 +1,11 @@ +import urllib3 from django.contrib.auth.decorators import permission_required from django.core.exceptions import ValidationError from django.db import transaction from django.shortcuts import get_object_or_404 from common.decorators import ajax +from shellvalier import settings from unifier.models import UnifiedFrame, UnifiedFrame2SlowalFrameMapping, UnifiedFrameArgumentSlowalFrameMapping from users.models import Assignment @@ -28,6 +30,10 @@ def frame_confirm_invalid(request, frame_pk): frame.status = choices.FrameStatus.BAD frame.save() removeSlovalFrameMappingsAndAssigments(frame_pk) + + http = urllib3.PoolManager() + r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(frame_pk)) + return {} @@ -39,8 +45,13 @@ def frame_reject_invalid(request, frame_pk): frame.status = choices.FrameStatus.NEW frame.save() removeSlovalFrameMappingsAndAssigments(frame_pk) + + http = urllib3.PoolManager() + r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(frame_pk)) + return {} + @ajax(login_required=True, method='post') @transaction.atomic @permission_required('semantics.manage_invalid_lexical_units') @@ -49,18 +60,24 @@ def frame_mark_as_bad(request, frame_pk): frame.status = choices.FrameStatus.BAD frame.save() removeSlovalFrameMappingsAndAssigments(frame_pk) + + http = urllib3.PoolManager() + r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(frame_pk)) + return {} + def removeSlovalFrameMappingsAndAssigments(frame_pk): #odpianie z ramy zunifikowanej - unifiedFrame2SlowalFrameMappings = UnifiedFrame2SlowalFrameMapping.objects.filter(slowal_frame_id=frame_pk) - for unifiedFrame2SlowalFrameMapping in unifiedFrame2SlowalFrameMappings: - unifiedFrameArgumentSlowalFrameMappings = UnifiedFrameArgumentSlowalFrameMapping.objects.filter(unified_frame_mapping=unifiedFrame2SlowalFrameMapping) - for unifiedFrameArgumentSlowalFrameMapping in unifiedFrameArgumentSlowalFrameMappings: - unifiedFrameArgumentSlowalFrameMapping.delete() - unifiedFrame2SlowalFrameMapping.delete() + unified_frame2_slowal_frame_mappings = UnifiedFrame2SlowalFrameMapping.objects.filter(slowal_frame_id=frame_pk) + for unified_frame2_slowal_frame_mapping in unified_frame2_slowal_frame_mappings: + unified_frame_argument_slowal_frame_mappings = UnifiedFrameArgumentSlowalFrameMapping.objects.filter(unified_frame_mapping=unified_frame2_slowal_frame_mapping) + for unified_frame_argument_slowal_frame_mapping in unified_frame_argument_slowal_frame_mappings: + unified_frame_argument_slowal_frame_mapping.delete() + unified_frame2_slowal_frame_mapping.delete() Assignment.delete(subject_id=frame_pk) + @ajax(login_required=True, method='post') @transaction.atomic @permission_required('semantics.manage_invalid_lexical_units') @@ -70,6 +87,7 @@ def frame_reject_as_not_matching_unified_frame(request, frame_pk): frame.save() return {} + @ajax(login_required=True, method='post') @transaction.atomic @permission_required('semantics.manage_invalid_lexical_units') @@ -78,5 +96,9 @@ def frame_confirm_as_not_matching_unified_frame(request, frame_pk): frame.status = choices.FrameStatus.NEW frame.save() removeSlovalFrameMappingsAndAssigments(frame_pk) + + http = urllib3.PoolManager() + r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(frame_pk)) + return {} diff --git a/unifier/urls.py b/unifier/urls.py index fe76fed1fbad0c80ea2a812e7741637ba5b70ca8..b7ecbf783deba80e5110ee1c3feb453962c1c456 100644 --- a/unifier/urls.py +++ b/unifier/urls.py @@ -22,6 +22,9 @@ urlpatterns = [ path('change_unified_frame_status_to_ready/', views.change_unified_frame_status_to_ready, name='change_unified_frame_status_to_ready'), path('remove_selectional_preference/', views.remove_selectional_preference, name='remove_selectional_preference'), path('build_unified_frame_xml/', views.build_unified_frame_xml, name='build_unified_frame_xml'), + path('frame_statuses_free/', views.frame_statuses_free, name='frame_statuses_free'), + path('frame_statuses_take/', views.frame_statuses_take, name='frame_statuses_take'), + path('frame_assign/', views.frame_assign, name='frame_assign'), path('delete_unified_frame/<int:unified_frame_id>/', views.delete_unified_frame, name='delete_unified_frame'), path('change_unified_frame_status_to_verified_by_superleksykograf/', views.change_unified_frame_status_to_verified_by_superleksykograf, name='change_unified_frame_status_to_verified_by_superleksykograf'), diff --git a/unifier/views.py b/unifier/views.py index c164dbd9994006b977f076119c379f46be8986af..5dd03ee7f42cd6fcae16a3572847495198b55ed7 100644 --- a/unifier/views.py +++ b/unifier/views.py @@ -478,10 +478,6 @@ def change_slowal_frame_status(request): frame.status = status frame.save() - if status == FrameStatus.BAD or FrameStatus.INVALID: - http = urllib3.PoolManager() - r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(slowal_frame_id)) - return JsonResponse({}) return JsonResponse({}) @@ -655,6 +651,18 @@ def create_unified_frame(frame_id): return unified_frame_id +@csrf_exempt +def frame_statuses_free(request): + if request.method == 'GET': + return HttpResponse() + + +@csrf_exempt +def frame_statuses_take(request): + if request.method == 'GET': + return HttpResponse() + + @csrf_exempt def build_unified_frame_xml(request): if request.method == 'GET': @@ -768,8 +776,9 @@ def delete_unified_frame(request, unified_frame_id): slowal_frames = UnifiedFrame2SlowalFrameMapping.objects.filter(unified_frame_id=unified_frame_id).all() slowal_frames_ids = ','.join(list(map(lambda slowal_frame: slowal_frame.id, slowal_frames))) - http = urllib3.PoolManager() - r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + slowal_frames_ids) + if len(slowal_frames_ids) > 0: + http = urllib3.PoolManager() + r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + slowal_frames_ids) UnifiedFrame.objects.get(id=unified_frame_id).delete()