diff --git a/mamweb/routers.py b/mamweb/routers.py index f2a172cb..5a75d39d 100644 --- a/mamweb/routers.py +++ b/mamweb/routers.py @@ -7,4 +7,5 @@ router.register(r'ulohavzoraknode', vs.UlohaVzorakNodeViewSet,basename='ulohavzo router.register(r'text', vs.TextViewSet) router.register(r'textnode', vs.TextNodeViewSet) router.register(r'castnode', vs.CastNodeViewSet) +router.register(r'problem', vs.ProblemViewSet, basename='problem') diff --git a/seminar/migrations/0090_auto_20201110_1958.py b/seminar/migrations/0090_auto_20201110_1958.py new file mode 100644 index 00000000..97949f58 --- /dev/null +++ b/seminar/migrations/0090_auto_20201110_1958.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.12 on 2020-11-10 18:58 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0089_cislo_datum_preddeadline'), + ] + + operations = [ + migrations.AlterField( + model_name='textnode', + name='text', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Text', verbose_name='text'), + ), + ] diff --git a/seminar/models.py b/seminar/models.py index cf8cd6a9..db9f67f9 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -1475,7 +1475,7 @@ class TextNode(TreeNode): verbose_name = 'Text (Node)' verbose_name_plural = 'Text (Node)' text = models.ForeignKey(Text, - on_delete=models.PROTECT, + on_delete=models.CASCADE, verbose_name = 'text') def aktualizuj_nazev(self): diff --git a/seminar/views/views_rest.py b/seminar/views/views_rest.py index aa3fca55..739c57c9 100644 --- a/seminar/views/views_rest.py +++ b/seminar/views/views_rest.py @@ -11,7 +11,10 @@ class TextSerializer(serializers.ModelSerializer): model = m.Text fields = '__all__' - +class ProblemSerializer(serializers.ModelSerializer): + class Meta: + model = m.Problem + fields = '__all__' class UlohaVzorakNodeSerializer(serializers.ModelSerializer): class Meta: diff --git a/seminar/viewsets.py b/seminar/viewsets.py index 8c83c067..67b13b3d 100644 --- a/seminar/viewsets.py +++ b/seminar/viewsets.py @@ -1,4 +1,8 @@ from rest_framework import viewsets,filters +from rest_framework import status +from rest_framework.response import Response +from django.core.exceptions import PermissionDenied + from . import models as m from . import views @@ -66,6 +70,14 @@ class CastNodeViewSet(ReadWriteSerializerMixin,viewsets.ModelViewSet): write_serializer_class = views.CastNodeSerializer create_serializer_class = views.CastNodeCreateSerializer + def destroy(self, request, *args, **kwargs): + obj = self.get_object() + print(obj) + if obj.first_child is None: + return super().destroy(request,*args,**kwargs) + raise PermissionDenied('Nelze smazat CastNode, který má děti!') + + class UlohaVzorakNodeViewSet(viewsets.ModelViewSet): serializer_class = views.UlohaVzorakNodeSerializer @@ -75,3 +87,10 @@ class UlohaVzorakNodeViewSet(viewsets.ModelViewSet): if nazev is not None: queryset = queryset.filter(nazev__contains=nazev) return queryset + +class ProblemViewSet(viewsets.ModelViewSet): + serializer_class = views.ProblemSerializer + + def get_queryset(self): + queryset = m.Problem.objects.all() + return queryset diff --git a/vue_frontend/src/components/CastNode.vue b/vue_frontend/src/components/CastNode.vue index 146bf5de..35390136 100644 --- a/vue_frontend/src/components/CastNode.vue +++ b/vue_frontend/src/components/CastNode.vue @@ -7,7 +7,9 @@
-

{{ currentText }}

+

{{ currentText }}

+ +
@@ -25,6 +27,7 @@ export default { props: { item: Object, editorShow: Boolean, + editorMode: Boolean, create: Boolean, where: String, refnode: Object @@ -76,11 +79,27 @@ export default { } this.editorShow = false; + }, + deleteCast: function() { + console.log("Deleting cast"); + axios.delete('/api/castnode/'+this.item.node.id+'/' + ).then( () => { + this.loading = false; + this.$root.$emit('updateData',"castNode delete update"); + }).catch(e => { + this.errors.push(e); + }); } - } + } } diff --git a/vue_frontend/src/components/TextNode.vue b/vue_frontend/src/components/TextNode.vue index aaa02fdb..b565d229 100644 --- a/vue_frontend/src/components/TextNode.vue +++ b/vue_frontend/src/components/TextNode.vue @@ -23,7 +23,8 @@ @@ -162,6 +163,16 @@ export default { } this.editorShow = false; }, + deleteText: function() { + console.log("Deleting text"); + axios.delete('/api/textnode/'+this.item.node.id+'/' + ).then( () => { + this.loading = false; + this.$root.$emit('updateData',"textNode delete update"); + }).catch(e => { + this.errors.push(e); + }); + }, } } @@ -169,6 +180,9 @@ export default { diff --git a/vue_frontend/src/components/TreeNodeRoot.vue b/vue_frontend/src/components/TreeNodeRoot.vue index 20cf47ac..674d0fda 100644 --- a/vue_frontend/src/components/TreeNodeRoot.vue +++ b/vue_frontend/src/components/TreeNodeRoot.vue @@ -3,6 +3,7 @@
Loading...
+
@@ -11,6 +12,7 @@ +
diff --git a/vue_frontend/vue.config.js b/vue_frontend/vue.config.js index 8d61b6ce..e4fc61ce 100644 --- a/vue_frontend/vue.config.js +++ b/vue_frontend/vue.config.js @@ -15,7 +15,7 @@ const pages = { module.exports = { pages: pages, filenameHashing: false, - productionSourceMap: false, + productionSourceMap: true, publicPath: process.env.NODE_ENV === 'production' ? '/static/seminar/vue/' : 'http://localhost:8080/', @@ -23,6 +23,7 @@ module.exports = { chainWebpack: config => { + config.optimization.minimize(false) config.optimization .splitChunks({ cacheGroups: { @@ -33,7 +34,7 @@ module.exports = { priority: 1 }, }, - }); + }).minimize(false); Object.keys(pages).forEach(page => { config.plugins.delete(`html-${page}`);