Commit 80ca0cbd035edf6d37e5b147e60d6c8f77d51474
1 parent
59f8fd90
Exists in
master
and in
2 other branches
Restoring simple backup working (minor adjusts to be made)
Showing
8 changed files
with
396 additions
and
11 deletions
Show diff stats
file_link/serializers.py
... | ... | @@ -2,7 +2,9 @@ import os |
2 | 2 | import zipfile |
3 | 3 | import time |
4 | 4 | from django.conf import settings |
5 | +from django.core.files import File | |
5 | 6 | from rest_framework import serializers |
7 | +from django.shortcuts import get_object_or_404 | |
6 | 8 | |
7 | 9 | from subjects.serializers import TagSerializer |
8 | 10 | from topics.serializers import TopicSerializer |
... | ... | @@ -10,6 +12,10 @@ from pendencies.serializers import PendenciesSerializer |
10 | 12 | from students_group.serializers import StudentsGroupSerializer |
11 | 13 | from users.serializers import UserBackupSerializer |
12 | 14 | |
15 | +from subjects.models import Tag | |
16 | +from topics.models import Topic, Resource | |
17 | +from pendencies.models import Pendencies | |
18 | + | |
13 | 19 | from .models import FileLink |
14 | 20 | |
15 | 21 | class SimpleFileLinkSerializer(serializers.ModelSerializer): |
... | ... | @@ -55,6 +61,67 @@ class SimpleFileLinkSerializer(serializers.ModelSerializer): |
55 | 61 | exclude = ('students', 'groups',) |
56 | 62 | validators = [] |
57 | 63 | |
64 | + def create(self, data): | |
65 | + topic = data['topic'] | |
66 | + | |
67 | + file_link = None | |
68 | + | |
69 | + if not topic["id"] is None: | |
70 | + if topic['id'] == "": | |
71 | + topic_exist = Topic.objects.filter(subject = topic['subject'], name__unaccent__iexact = topic["name"]) | |
72 | + | |
73 | + if topic_exist.exists(): | |
74 | + topic = topic_exist[0] | |
75 | + else: | |
76 | + topic = Topic.objects.create(name = topic['name'], subject = topic['subject'], repository = topic['repository'], visible = topic['visible'], order = topic['order']) | |
77 | + | |
78 | + data["topic"] = topic | |
79 | + else: | |
80 | + data["topic"] = get_object_or_404(Topic, id = topic["id"]) | |
81 | + | |
82 | + | |
83 | + f = open(os.path.join(settings.MEDIA_ROOT, data["file_content"]), encoding="latin-1") | |
84 | + file = File(f) | |
85 | + | |
86 | + data["file_content"] = file | |
87 | + | |
88 | + file_link_data = data | |
89 | + | |
90 | + pendencies = file_link_data["pendencies_resource"] | |
91 | + del file_link_data["pendencies_resource"] | |
92 | + | |
93 | + file_link = FileLink() | |
94 | + file_link.name = file_link_data["name"] | |
95 | + file_link.brief_description = file_link_data["brief_description"] | |
96 | + file_link.show_window = file_link_data["show_window"] | |
97 | + file_link.all_students = file_link_data["all_students"] | |
98 | + file_link.visible = file_link_data["visible"] | |
99 | + file_link.order = file_link_data["order"] | |
100 | + file_link.topic = file_link_data["topic"] | |
101 | + file_link.file_content = file_link_data["file_content"] | |
102 | + | |
103 | + file_link.save() | |
104 | + | |
105 | + tags = data["tags"] | |
106 | + | |
107 | + for tag in tags: | |
108 | + if tag["id"] == "": | |
109 | + tag = Tag.objects.create(name = tag["name"]) | |
110 | + else: | |
111 | + tag = get_object_or_404(Tag, id = tag["id"]) | |
112 | + | |
113 | + file_link.tags.add(tag) | |
114 | + | |
115 | + resource = get_object_or_404(Resource, id = file_link.id) | |
116 | + | |
117 | + for pend in pendencies: | |
118 | + Pendencies.objects.create(resource = resource, **pend) | |
119 | + | |
120 | + return file_link | |
121 | + | |
122 | + def update(self, instance, data): | |
123 | + return instance | |
124 | + | |
58 | 125 | class CompleteFileLinkSerializer(serializers.ModelSerializer): |
59 | 126 | file_content = serializers.CharField(required = False, allow_blank = True) |
60 | 127 | topic = TopicSerializer() | ... | ... |
goals/serializers.py
1 | 1 | from rest_framework import serializers |
2 | +from django.shortcuts import get_object_or_404 | |
2 | 3 | |
3 | 4 | from subjects.serializers import TagSerializer |
4 | 5 | from topics.serializers import TopicSerializer |
... | ... | @@ -6,6 +7,10 @@ from pendencies.serializers import PendenciesSerializer |
6 | 7 | from students_group.serializers import StudentsGroupSerializer |
7 | 8 | from users.serializers import UserBackupSerializer |
8 | 9 | |
10 | +from subjects.models import Tag | |
11 | +from topics.models import Topic, Resource | |
12 | +from pendencies.models import Pendencies | |
13 | + | |
9 | 14 | from .models import Goals, GoalItem |
10 | 15 | |
11 | 16 | class GoalItemSerializer(serializers.ModelSerializer): |
... | ... | @@ -28,6 +33,68 @@ class SimpleGoalSerializer(serializers.ModelSerializer): |
28 | 33 | model = Goals |
29 | 34 | exclude = ('students', 'groups',) |
30 | 35 | |
36 | + def create(self, data): | |
37 | + topic = data['topic'] | |
38 | + | |
39 | + goals = None | |
40 | + | |
41 | + if not topic["id"] is None: | |
42 | + if topic['id'] == "": | |
43 | + topic_exist = Topic.objects.filter(subject = topic['subject'], name__unaccent__iexact = topic["name"]) | |
44 | + | |
45 | + if topic_exist.exists(): | |
46 | + topic = topic_exist[0] | |
47 | + else: | |
48 | + topic = Topic.objects.create(name = topic['name'], subject = topic['subject'], repository = topic['repository'], visible = topic['visible'], order = topic['order']) | |
49 | + | |
50 | + data["topic"] = topic | |
51 | + else: | |
52 | + data["topic"] = get_object_or_404(Topic, id = topic["id"]) | |
53 | + | |
54 | + goals_data = data | |
55 | + | |
56 | + pendencies = goals_data["pendencies_resource"] | |
57 | + del goals_data["pendencies_resource"] | |
58 | + | |
59 | + goal_items = goals_data["item_goal"] | |
60 | + del goals_data["item_goal"] | |
61 | + | |
62 | + goals = Goals() | |
63 | + goals.name = goals_data["name"] | |
64 | + goals.brief_description = goals_data["brief_description"] | |
65 | + goals.show_window = goals_data["show_window"] | |
66 | + goals.all_students = goals_data["all_students"] | |
67 | + goals.visible = goals_data["visible"] | |
68 | + goals.order = goals_data["order"] | |
69 | + goals.topic = goals_data["topic"] | |
70 | + goals.presentation = goals_data["presentation"] | |
71 | + goals.limit_submission_date = goals_data["limit_submission_date"] | |
72 | + | |
73 | + goals.save() | |
74 | + | |
75 | + tags = data["tags"] | |
76 | + | |
77 | + for tag in tags: | |
78 | + if tag["id"] == "": | |
79 | + tag = Tag.objects.create(name = tag["name"]) | |
80 | + else: | |
81 | + tag = get_object_or_404(Tag, id = tag["id"]) | |
82 | + | |
83 | + goals.tags.add(tag) | |
84 | + | |
85 | + resource = get_object_or_404(Resource, id = goals.id) | |
86 | + | |
87 | + for item in goal_items: | |
88 | + GoalItem.objects.create(goal = goals, **item) | |
89 | + | |
90 | + for pend in pendencies: | |
91 | + Pendencies.objects.create(resource = resource, **pend) | |
92 | + | |
93 | + return goals | |
94 | + | |
95 | + def update(self, instance, data): | |
96 | + return instance | |
97 | + | |
31 | 98 | class CompleteGoalSerializer(serializers.ModelSerializer): |
32 | 99 | topic = TopicSerializer() |
33 | 100 | tags = TagSerializer(many = True) | ... | ... |
links/serializers.py
1 | 1 | from rest_framework import serializers |
2 | +from django.shortcuts import get_object_or_404 | |
2 | 3 | |
3 | 4 | from subjects.serializers import TagSerializer |
4 | 5 | from topics.serializers import TopicSerializer |
... | ... | @@ -6,6 +7,10 @@ from pendencies.serializers import PendenciesSerializer |
6 | 7 | from students_group.serializers import StudentsGroupSerializer |
7 | 8 | from users.serializers import UserBackupSerializer |
8 | 9 | |
10 | +from subjects.models import Tag | |
11 | +from topics.models import Topic, Resource | |
12 | +from pendencies.models import Pendencies | |
13 | + | |
9 | 14 | from .models import Link |
10 | 15 | |
11 | 16 | class SimpleLinkSerializer(serializers.ModelSerializer): |
... | ... | @@ -22,6 +27,61 @@ class SimpleLinkSerializer(serializers.ModelSerializer): |
22 | 27 | model = Link |
23 | 28 | exclude = ('students', 'groups',) |
24 | 29 | |
30 | + def create(self, data): | |
31 | + topic = data['topic'] | |
32 | + | |
33 | + link = None | |
34 | + | |
35 | + if not topic["id"] is None: | |
36 | + if topic['id'] == "": | |
37 | + topic_exist = Topic.objects.filter(subject = topic['subject'], name__unaccent__iexact = topic["name"]) | |
38 | + | |
39 | + if topic_exist.exists(): | |
40 | + topic = topic_exist[0] | |
41 | + else: | |
42 | + topic = Topic.objects.create(name = topic['name'], subject = topic['subject'], repository = topic['repository'], visible = topic['visible'], order = topic['order']) | |
43 | + | |
44 | + data["topic"] = topic | |
45 | + else: | |
46 | + data["topic"] = get_object_or_404(Topic, id = topic["id"]) | |
47 | + | |
48 | + link_data = data | |
49 | + | |
50 | + pendencies = link_data["pendencies_resource"] | |
51 | + del link_data["pendencies_resource"] | |
52 | + | |
53 | + link = Link() | |
54 | + link.name = link_data["name"] | |
55 | + link.brief_description = link_data["brief_description"] | |
56 | + link.show_window = link_data["show_window"] | |
57 | + link.all_students = link_data["all_students"] | |
58 | + link.visible = link_data["visible"] | |
59 | + link.order = link_data["order"] | |
60 | + link.topic = link_data["topic"] | |
61 | + link.link_url = link_data["link_url"] | |
62 | + | |
63 | + link.save() | |
64 | + | |
65 | + tags = data["tags"] | |
66 | + | |
67 | + for tag in tags: | |
68 | + if tag["id"] == "": | |
69 | + tag = Tag.objects.create(name = tag["name"]) | |
70 | + else: | |
71 | + tag = get_object_or_404(Tag, id = tag["id"]) | |
72 | + | |
73 | + link.tags.add(tag) | |
74 | + | |
75 | + resource = get_object_or_404(Resource, id = link.id) | |
76 | + | |
77 | + for pend in pendencies: | |
78 | + Pendencies.objects.create(resource = resource, **pend) | |
79 | + | |
80 | + return link | |
81 | + | |
82 | + def update(self, instance, data): | |
83 | + return instance | |
84 | + | |
25 | 85 | class CompleteLinkSerializer(serializers.ModelSerializer): |
26 | 86 | topic = TopicSerializer() |
27 | 87 | tags = TagSerializer(many = True) | ... | ... |
pdf_file/serializers.py
1 | +import os | |
2 | +import zipfile | |
3 | +import time | |
4 | +from django.conf import settings | |
5 | +from django.core.files import File | |
1 | 6 | from rest_framework import serializers |
7 | +from django.shortcuts import get_object_or_404 | |
2 | 8 | |
3 | 9 | from subjects.serializers import TagSerializer |
4 | 10 | from topics.serializers import TopicSerializer |
... | ... | @@ -6,6 +12,10 @@ from pendencies.serializers import PendenciesSerializer |
6 | 12 | from students_group.serializers import StudentsGroupSerializer |
7 | 13 | from users.serializers import UserBackupSerializer |
8 | 14 | |
15 | +from subjects.models import Tag | |
16 | +from topics.models import Topic, Resource | |
17 | +from pendencies.models import Pendencies | |
18 | + | |
9 | 19 | from .models import PDFFile |
10 | 20 | |
11 | 21 | class SimplePDFFileSerializer(serializers.ModelSerializer): |
... | ... | @@ -23,20 +33,20 @@ class SimplePDFFileSerializer(serializers.ModelSerializer): |
23 | 33 | files = self.context.get('files', None) |
24 | 34 | |
25 | 35 | if files: |
26 | - file_path = os.path.join(settings.MEDIA_ROOT, data["file_content"]) | |
36 | + file_path = os.path.join(settings.MEDIA_ROOT, data["file"]) | |
27 | 37 | |
28 | 38 | if os.path.isfile(file_path): |
29 | 39 | dst_path = os.path.join(settings.MEDIA_ROOT, "tmp") |
30 | 40 | |
31 | - path = files.extract(data["file_content"], dst_path) | |
41 | + path = files.extract(data["file"], dst_path) | |
32 | 42 | |
33 | - new_name = "files/file_" + str(time.time()) + os.path.splitext(data["file_content"])[1] | |
43 | + new_name = "files/file_" + str(time.time()) + os.path.splitext(data["file"])[1] | |
34 | 44 | |
35 | 45 | os.rename(os.path.join(dst_path, path), os.path.join(settings.MEDIA_ROOT, new_name)) |
36 | 46 | |
37 | - data["file_content"] = new_name | |
47 | + data["file"] = new_name | |
38 | 48 | else: |
39 | - path = files.extract(data["file_content"], settings.MEDIA_ROOT) | |
49 | + path = files.extract(data["file"], settings.MEDIA_ROOT) | |
40 | 50 | |
41 | 51 | return data |
42 | 52 | |
... | ... | @@ -44,6 +54,67 @@ class SimplePDFFileSerializer(serializers.ModelSerializer): |
44 | 54 | model = PDFFile |
45 | 55 | exclude = ('students', 'groups',) |
46 | 56 | |
57 | + def create(self, data): | |
58 | + topic = data['topic'] | |
59 | + | |
60 | + pdf = None | |
61 | + | |
62 | + if not topic["id"] is None: | |
63 | + if topic['id'] == "": | |
64 | + topic_exist = Topic.objects.filter(subject = topic['subject'], name__unaccent__iexact = topic["name"]) | |
65 | + | |
66 | + if topic_exist.exists(): | |
67 | + topic = topic_exist[0] | |
68 | + else: | |
69 | + topic = Topic.objects.create(name = topic['name'], subject = topic['subject'], repository = topic['repository'], visible = topic['visible'], order = topic['order']) | |
70 | + | |
71 | + data["topic"] = topic | |
72 | + else: | |
73 | + data["topic"] = get_object_or_404(Topic, id = topic["id"]) | |
74 | + | |
75 | + | |
76 | + f = open(os.path.join(settings.MEDIA_ROOT, data["file"]), encoding="latin-1") | |
77 | + file = File(f) | |
78 | + | |
79 | + data["file"] = file | |
80 | + | |
81 | + pdf_data = data | |
82 | + | |
83 | + pendencies = pdf_data["pendencies_resource"] | |
84 | + del pdf_data["pendencies_resource"] | |
85 | + | |
86 | + pdf = PDFFile() | |
87 | + pdf.name = pdf_data["name"] | |
88 | + pdf.brief_description = pdf_data["brief_description"] | |
89 | + pdf.show_window = pdf_data["show_window"] | |
90 | + pdf.all_students = pdf_data["all_students"] | |
91 | + pdf.visible = pdf_data["visible"] | |
92 | + pdf.order = pdf_data["order"] | |
93 | + pdf.topic = pdf_data["topic"] | |
94 | + pdf.file = pdf_data["file"] | |
95 | + | |
96 | + pdf.save() | |
97 | + | |
98 | + tags = data["tags"] | |
99 | + | |
100 | + for tag in tags: | |
101 | + if tag["id"] == "": | |
102 | + tag = Tag.objects.create(name = tag["name"]) | |
103 | + else: | |
104 | + tag = get_object_or_404(Tag, id = tag["id"]) | |
105 | + | |
106 | + pdf.tags.add(tag) | |
107 | + | |
108 | + resource = get_object_or_404(Resource, id = pdf.id) | |
109 | + | |
110 | + for pend in pendencies: | |
111 | + Pendencies.objects.create(resource = resource, **pend) | |
112 | + | |
113 | + return pdf | |
114 | + | |
115 | + def update(self, instance, data): | |
116 | + return instance | |
117 | + | |
47 | 118 | class CompletePDFFileSerializer(serializers.ModelSerializer): |
48 | 119 | file = serializers.CharField(required = False, allow_blank = True) |
49 | 120 | topic = TopicSerializer() | ... | ... |
subjects/views.py
... | ... | @@ -907,9 +907,6 @@ def realize_restore(request, subject): |
907 | 907 | serial = SimpleYTVideoSerializer(data = line, many = True, context = {'subject': subject}) |
908 | 908 | |
909 | 909 | serial.is_valid() |
910 | - print(serial.errors) | |
911 | - print("\n") | |
912 | - print(serial.validated_data) | |
913 | - print("\n\n\n") | |
910 | + serial.save() | |
914 | 911 | |
915 | 912 | return JsonResponse({'message': 'ok'}) |
916 | 913 | \ No newline at end of file | ... | ... |
topics/serializers.py
... | ... | @@ -14,14 +14,16 @@ class TopicSerializer(serializers.ModelSerializer): |
14 | 14 | topic = Topic.objects.filter(subject = subject, name__unaccent__iexact = data["name"]) |
15 | 15 | |
16 | 16 | if topic.exists(): |
17 | - data = topic[0] | |
17 | + data = topic[0].__dict__ | |
18 | 18 | else: |
19 | 19 | topic = Topic.objects.filter(subject = subject, repository = True) |
20 | 20 | |
21 | 21 | if topic.exists(): |
22 | - data = topic[0] | |
22 | + data = topic[0].__dict__ | |
23 | 23 | else: |
24 | 24 | data["id"] = "" |
25 | + data["subject"] = subject | |
26 | + data["order"] = Topic.objects.filter(subject = subject).count() + 1 | |
25 | 27 | |
26 | 28 | return data |
27 | 29 | ... | ... |
webpage/serializers.py
1 | 1 | from rest_framework import serializers |
2 | +from django.shortcuts import get_object_or_404 | |
2 | 3 | |
3 | 4 | from subjects.serializers import TagSerializer |
4 | 5 | from topics.serializers import TopicSerializer |
... | ... | @@ -6,6 +7,10 @@ from pendencies.serializers import PendenciesSerializer |
6 | 7 | from students_group.serializers import StudentsGroupSerializer |
7 | 8 | from users.serializers import UserBackupSerializer |
8 | 9 | |
10 | +from subjects.models import Tag | |
11 | +from topics.models import Topic, Resource | |
12 | +from pendencies.models import Pendencies | |
13 | + | |
9 | 14 | from .models import Webpage |
10 | 15 | |
11 | 16 | class SimpleWebpageSerializer(serializers.ModelSerializer): |
... | ... | @@ -22,6 +27,61 @@ class SimpleWebpageSerializer(serializers.ModelSerializer): |
22 | 27 | model = Webpage |
23 | 28 | exclude = ('students', 'groups',) |
24 | 29 | |
30 | + def create(self, data): | |
31 | + topic = data['topic'] | |
32 | + | |
33 | + webpage = None | |
34 | + | |
35 | + if not topic["id"] is None: | |
36 | + if topic['id'] == "": | |
37 | + topic_exist = Topic.objects.filter(subject = topic['subject'], name__unaccent__iexact = topic["name"]) | |
38 | + | |
39 | + if topic_exist.exists(): | |
40 | + topic = topic_exist[0] | |
41 | + else: | |
42 | + topic = Topic.objects.create(name = topic['name'], subject = topic['subject'], repository = topic['repository'], visible = topic['visible'], order = topic['order']) | |
43 | + | |
44 | + data["topic"] = topic | |
45 | + else: | |
46 | + data["topic"] = get_object_or_404(Topic, id = topic["id"]) | |
47 | + | |
48 | + webpage_data = data | |
49 | + | |
50 | + pendencies = webpage_data["pendencies_resource"] | |
51 | + del webpage_data["pendencies_resource"] | |
52 | + | |
53 | + webpage = Webpage() | |
54 | + webpage.name = webpage_data["name"] | |
55 | + webpage.brief_description = webpage_data["brief_description"] | |
56 | + webpage.show_window = webpage_data["show_window"] | |
57 | + webpage.all_students = webpage_data["all_students"] | |
58 | + webpage.visible = webpage_data["visible"] | |
59 | + webpage.order = webpage_data["order"] | |
60 | + webpage.topic = webpage_data["topic"] | |
61 | + webpage.content = webpage_data["content"] | |
62 | + | |
63 | + webpage.save() | |
64 | + | |
65 | + tags = data["tags"] | |
66 | + | |
67 | + for tag in tags: | |
68 | + if tag["id"] == "": | |
69 | + tag = Tag.objects.create(name = tag["name"]) | |
70 | + else: | |
71 | + tag = get_object_or_404(Tag, id = tag["id"]) | |
72 | + | |
73 | + webpage.tags.add(tag) | |
74 | + | |
75 | + resource = get_object_or_404(Resource, id = webpage.id) | |
76 | + | |
77 | + for pend in pendencies: | |
78 | + Pendencies.objects.create(resource = resource, **pend) | |
79 | + | |
80 | + return webpage | |
81 | + | |
82 | + def update(self, instance, data): | |
83 | + return instance | |
84 | + | |
25 | 85 | class CompleteWebpageSerializer(serializers.ModelSerializer): |
26 | 86 | topic = TopicSerializer() |
27 | 87 | tags = TagSerializer(many = True) | ... | ... |
youtube_video/serializers.py
1 | 1 | from rest_framework import serializers |
2 | +from django.shortcuts import get_object_or_404 | |
2 | 3 | |
3 | 4 | from subjects.serializers import TagSerializer |
4 | 5 | from topics.serializers import TopicSerializer |
... | ... | @@ -6,6 +7,10 @@ from pendencies.serializers import PendenciesSerializer |
6 | 7 | from students_group.serializers import StudentsGroupSerializer |
7 | 8 | from users.serializers import UserBackupSerializer |
8 | 9 | |
10 | +from subjects.models import Tag | |
11 | +from topics.models import Topic, Resource | |
12 | +from pendencies.models import Pendencies | |
13 | + | |
9 | 14 | from .models import YTVideo |
10 | 15 | |
11 | 16 | class SimpleYTVideoSerializer(serializers.ModelSerializer): |
... | ... | @@ -22,6 +27,62 @@ class SimpleYTVideoSerializer(serializers.ModelSerializer): |
22 | 27 | model = YTVideo |
23 | 28 | exclude = ('students', 'groups',) |
24 | 29 | |
30 | + def create(self, data): | |
31 | + topic = data['topic'] | |
32 | + | |
33 | + ytvideo = None | |
34 | + | |
35 | + if not topic["id"] is None: | |
36 | + if topic['id'] == "": | |
37 | + topic_exist = Topic.objects.filter(subject = topic['subject'], name__unaccent__iexact = topic["name"]) | |
38 | + | |
39 | + if topic_exist.exists(): | |
40 | + topic = topic_exist[0] | |
41 | + else: | |
42 | + topic = Topic.objects.create(name = topic['name'], subject = topic['subject'], repository = topic['repository'], visible = topic['visible'], order = topic['order']) | |
43 | + | |
44 | + data["topic"] = topic | |
45 | + else: | |
46 | + data["topic"] = get_object_or_404(Topic, id = topic["id"]) | |
47 | + | |
48 | + | |
49 | + ytvideo_data = data | |
50 | + | |
51 | + pendencies = ytvideo_data["pendencies_resource"] | |
52 | + del ytvideo_data["pendencies_resource"] | |
53 | + | |
54 | + ytvideo = YTVideo() | |
55 | + ytvideo.name = ytvideo_data["name"] | |
56 | + ytvideo.brief_description = ytvideo_data["brief_description"] | |
57 | + ytvideo.show_window = ytvideo_data["show_window"] | |
58 | + ytvideo.all_students = ytvideo_data["all_students"] | |
59 | + ytvideo.visible = ytvideo_data["visible"] | |
60 | + ytvideo.order = ytvideo_data["order"] | |
61 | + ytvideo.topic = ytvideo_data["topic"] | |
62 | + ytvideo.url = ytvideo_data["url"] | |
63 | + | |
64 | + ytvideo.save() | |
65 | + | |
66 | + tags = data["tags"] | |
67 | + | |
68 | + for tag in tags: | |
69 | + if tag["id"] == "": | |
70 | + tag = Tag.objects.create(name = tag["name"]) | |
71 | + else: | |
72 | + tag = get_object_or_404(Tag, id = tag["id"]) | |
73 | + | |
74 | + ytvideo.tags.add(tag) | |
75 | + | |
76 | + resource = get_object_or_404(Resource, id = ytvideo.id) | |
77 | + | |
78 | + for pend in pendencies: | |
79 | + Pendencies.objects.create(resource = resource, **pend) | |
80 | + | |
81 | + return ytvideo | |
82 | + | |
83 | + def update(self, instance, data): | |
84 | + return instance | |
85 | + | |
25 | 86 | class CompleteYTVideoSerializer(serializers.ModelSerializer): |
26 | 87 | topic = TopicSerializer() |
27 | 88 | tags = TagSerializer(many = True) | ... | ... |