Skip to content
Snippets Groups Projects
Commit 8192a147 authored by dcz's avatar dcz
Browse files

Send delete slowal frame API request only after superleksykograf acceptance.

Full fake API func.
parent 8efeabb4
No related merge requests found
...@@ -78,24 +78,6 @@ export default { ...@@ -78,24 +78,6 @@ export default {
show_error(errorType + ' (' + errorMessage + ')'); show_error(errorType + ' (' + errorMessage + ')');
}, },
300000) 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 { } else {
alert(gettext("Nazwa zunifikowanej ramy nie jest unikalna. Proszę wybrać inną nazwę.")); alert(gettext("Nazwa zunifikowanej ramy nie jest unikalna. Proszę wybrać inną nazwę."));
} }
...@@ -166,17 +148,6 @@ export default { ...@@ -166,17 +148,6 @@ export default {
setup () { setup () {
$('#lexical-unit-notes').html(''); $('#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 }; var data = { 'entry' : this.entryId, 'no_filters' : false, 'lexical_unit_id': this.lexicalUnitId };
$.ajax({ $.ajax({
type : 'post', type : 'post',
......
import urllib3
from django.contrib.auth.decorators import permission_required from django.contrib.auth.decorators import permission_required
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import transaction from django.db import transaction
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from common.decorators import ajax from common.decorators import ajax
from shellvalier import settings
from unifier.models import UnifiedFrame, UnifiedFrame2SlowalFrameMapping, UnifiedFrameArgumentSlowalFrameMapping from unifier.models import UnifiedFrame, UnifiedFrame2SlowalFrameMapping, UnifiedFrameArgumentSlowalFrameMapping
from users.models import Assignment from users.models import Assignment
...@@ -28,6 +30,10 @@ def frame_confirm_invalid(request, frame_pk): ...@@ -28,6 +30,10 @@ def frame_confirm_invalid(request, frame_pk):
frame.status = choices.FrameStatus.BAD frame.status = choices.FrameStatus.BAD
frame.save() frame.save()
removeSlovalFrameMappingsAndAssigments(frame_pk) removeSlovalFrameMappingsAndAssigments(frame_pk)
http = urllib3.PoolManager()
r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(frame_pk))
return {} return {}
...@@ -39,8 +45,13 @@ def frame_reject_invalid(request, frame_pk): ...@@ -39,8 +45,13 @@ def frame_reject_invalid(request, frame_pk):
frame.status = choices.FrameStatus.NEW frame.status = choices.FrameStatus.NEW
frame.save() frame.save()
removeSlovalFrameMappingsAndAssigments(frame_pk) removeSlovalFrameMappingsAndAssigments(frame_pk)
http = urllib3.PoolManager()
r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(frame_pk))
return {} return {}
@ajax(login_required=True, method='post') @ajax(login_required=True, method='post')
@transaction.atomic @transaction.atomic
@permission_required('semantics.manage_invalid_lexical_units') @permission_required('semantics.manage_invalid_lexical_units')
...@@ -49,18 +60,24 @@ def frame_mark_as_bad(request, frame_pk): ...@@ -49,18 +60,24 @@ def frame_mark_as_bad(request, frame_pk):
frame.status = choices.FrameStatus.BAD frame.status = choices.FrameStatus.BAD
frame.save() frame.save()
removeSlovalFrameMappingsAndAssigments(frame_pk) removeSlovalFrameMappingsAndAssigments(frame_pk)
http = urllib3.PoolManager()
r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(frame_pk))
return {} return {}
def removeSlovalFrameMappingsAndAssigments(frame_pk): def removeSlovalFrameMappingsAndAssigments(frame_pk):
#odpianie z ramy zunifikowanej #odpianie z ramy zunifikowanej
unifiedFrame2SlowalFrameMappings = UnifiedFrame2SlowalFrameMapping.objects.filter(slowal_frame_id=frame_pk) unified_frame2_slowal_frame_mappings = UnifiedFrame2SlowalFrameMapping.objects.filter(slowal_frame_id=frame_pk)
for unifiedFrame2SlowalFrameMapping in unifiedFrame2SlowalFrameMappings: for unified_frame2_slowal_frame_mapping in unified_frame2_slowal_frame_mappings:
unifiedFrameArgumentSlowalFrameMappings = UnifiedFrameArgumentSlowalFrameMapping.objects.filter(unified_frame_mapping=unifiedFrame2SlowalFrameMapping) unified_frame_argument_slowal_frame_mappings = UnifiedFrameArgumentSlowalFrameMapping.objects.filter(unified_frame_mapping=unified_frame2_slowal_frame_mapping)
for unifiedFrameArgumentSlowalFrameMapping in unifiedFrameArgumentSlowalFrameMappings: for unified_frame_argument_slowal_frame_mapping in unified_frame_argument_slowal_frame_mappings:
unifiedFrameArgumentSlowalFrameMapping.delete() unified_frame_argument_slowal_frame_mapping.delete()
unifiedFrame2SlowalFrameMapping.delete() unified_frame2_slowal_frame_mapping.delete()
Assignment.delete(subject_id=frame_pk) Assignment.delete(subject_id=frame_pk)
@ajax(login_required=True, method='post') @ajax(login_required=True, method='post')
@transaction.atomic @transaction.atomic
@permission_required('semantics.manage_invalid_lexical_units') @permission_required('semantics.manage_invalid_lexical_units')
...@@ -70,6 +87,7 @@ def frame_reject_as_not_matching_unified_frame(request, frame_pk): ...@@ -70,6 +87,7 @@ def frame_reject_as_not_matching_unified_frame(request, frame_pk):
frame.save() frame.save()
return {} return {}
@ajax(login_required=True, method='post') @ajax(login_required=True, method='post')
@transaction.atomic @transaction.atomic
@permission_required('semantics.manage_invalid_lexical_units') @permission_required('semantics.manage_invalid_lexical_units')
...@@ -78,5 +96,9 @@ def frame_confirm_as_not_matching_unified_frame(request, frame_pk): ...@@ -78,5 +96,9 @@ def frame_confirm_as_not_matching_unified_frame(request, frame_pk):
frame.status = choices.FrameStatus.NEW frame.status = choices.FrameStatus.NEW
frame.save() frame.save()
removeSlovalFrameMappingsAndAssigments(frame_pk) removeSlovalFrameMappingsAndAssigments(frame_pk)
http = urllib3.PoolManager()
r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + str(frame_pk))
return {} return {}
...@@ -22,6 +22,9 @@ urlpatterns = [ ...@@ -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('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('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('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('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('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'), 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'),
......
...@@ -478,10 +478,6 @@ def change_slowal_frame_status(request): ...@@ -478,10 +478,6 @@ def change_slowal_frame_status(request):
frame.status = status frame.status = status
frame.save() 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({})
return JsonResponse({}) return JsonResponse({})
...@@ -655,6 +651,18 @@ def create_unified_frame(frame_id): ...@@ -655,6 +651,18 @@ def create_unified_frame(frame_id):
return unified_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 @csrf_exempt
def build_unified_frame_xml(request): def build_unified_frame_xml(request):
if request.method == 'GET': if request.method == 'GET':
...@@ -768,8 +776,9 @@ def delete_unified_frame(request, unified_frame_id): ...@@ -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 = UnifiedFrame2SlowalFrameMapping.objects.filter(unified_frame_id=unified_frame_id).all()
slowal_frames_ids = ','.join(list(map(lambda slowal_frame: slowal_frame.id, slowal_frames))) slowal_frames_ids = ','.join(list(map(lambda slowal_frame: slowal_frame.id, slowal_frames)))
http = urllib3.PoolManager() if len(slowal_frames_ids) > 0:
r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + slowal_frames_ids) http = urllib3.PoolManager()
r = http.request('GET', settings.SLOWAL_FRAME_REMOVE_SERVICE_URL + slowal_frames_ids)
UnifiedFrame.objects.get(id=unified_frame_id).delete() UnifiedFrame.objects.get(id=unified_frame_id).delete()
......
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