Compare commits
2 commits
cb8f0aab18
...
0c43c56698
Author | SHA1 | Date | |
---|---|---|---|
0c43c56698 | |||
c1eb44e599 |
3 changed files with 20 additions and 5 deletions
|
@ -1,15 +1,14 @@
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from django.http import HttpResponseForbidden, JsonResponse, HttpResponse
|
from django.http import JsonResponse, HttpResponse
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.utils.html import linebreaks
|
from django.utils.html import linebreaks
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from korektury.utils import send_email_notification_komentar
|
from korektury.utils import send_email_notification_komentar
|
||||||
from korektury.models import Oprava, KorekturovanePDF, Komentar, KorekturaTag
|
from korektury.models import Oprava, KorekturovanePDF, Komentar, KorekturaTag
|
||||||
from personalni.models import Organizator, Osoba
|
from personalni.models import Organizator
|
||||||
|
|
||||||
|
|
||||||
def korektury_stav_view(request, pdf_id: int, **kwargs):
|
def korektury_stav_view(request, pdf_id: int, **kwargs):
|
||||||
|
@ -122,6 +121,7 @@ def opravy_a_komentare_view(request, pdf_id: int, **kwargs):
|
||||||
tagy = list(map(int, tagy_raw.split(",")))
|
tagy = list(map(int, tagy_raw.split(",")))
|
||||||
oprava.tagy.add(*KorekturaTag.objects.filter(id__in=tagy))
|
oprava.tagy.add(*KorekturaTag.objects.filter(id__in=tagy))
|
||||||
Komentar.objects.create(oprava=oprava, autor=autor, text=text)
|
Komentar.objects.create(oprava=oprava, autor=autor, text=text)
|
||||||
|
send_email_notification_komentar(oprava, autor, request)
|
||||||
|
|
||||||
|
|
||||||
opravy = Oprava.objects.filter(pdf=pdf_id).all()
|
opravy = Oprava.objects.filter(pdf=pdf_id).all()
|
||||||
|
|
|
@ -91,11 +91,16 @@
|
||||||
fetch('{% url "korektury_api_komentar_smaz" %}', {method: 'POST', body: data})
|
fetch('{% url "korektury_api_komentar_smaz" %}', {method: 'POST', body: data})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
||||||
this.htmlElement.remove();
|
this.smaz_pouze_na_strance();
|
||||||
place_comments();
|
place_comments();
|
||||||
})
|
})
|
||||||
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smaz_pouze_na_strance() {
|
||||||
|
delete komentare[this.id];
|
||||||
|
this.htmlElement.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -163,11 +163,21 @@
|
||||||
fetch('{% url "korektury_api_oprava_smaz" %}', {method: 'POST', body: data})
|
fetch('{% url "korektury_api_oprava_smaz" %}', {method: 'POST', body: data})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
||||||
comments[this.img_id].splice(comments[this.img_id].indexOf(this), 1);
|
this.#smaz_pouze_na_strance()
|
||||||
|
updatuj_pocty_stavu();
|
||||||
|
updatuj_pocty_zasluh();
|
||||||
place_comments();
|
place_comments();
|
||||||
})
|
})
|
||||||
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#smaz_pouze_na_strance() {
|
||||||
|
comments[this.img_id].splice(comments[this.img_id].indexOf(this), 1);
|
||||||
|
delete opravy[this.id];
|
||||||
|
for (const komentar of Object.values(komentare)) if (komentar.oprava === this) komentar.smaz_pouze_na_strance();
|
||||||
|
this.htmlElement.remove();
|
||||||
|
this.pointer.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue