Commit 6921a0cc authored by Bruno Martin's avatar Bruno Martin
Browse files

add editor file model, viewset and endpoint

parent f40ed7da
from django.db import models
from django.utils.translation import ugettext_lazy as _
class EditorContentFile(models.Model):
name = models.CharField(_('Name'), max_length=255, null=True, blank=True)
file = models.FileField(upload_to='courses/files')
def __unicode__(self):
return self.name
from rest_framework import serializers
from .models import EditorContentFile
class EditorContentFileSerializer(serializers.ModelSerializer):
class Meta:
model = EditorContentFile
fields = '__all__'
from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticated
from .models import EditorContentFile
from .serializers import EditorContentFileSerializer
class EditorContentFileViewSet(viewsets.ModelViewSet):
queryset = EditorContentFile.objects.all()
serializer_class = EditorContentFileSerializer
permission_classes = [IsAuthenticated]
# Generated by Django 2.2.28 on 2022-05-20 18:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('courses', '0045_auto_20220426_0053'),
]
operations = [
migrations.CreateModel(
name='EditorContentFile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(blank=True, max_length=255, null=True, verbose_name='Name')),
('file', models.FileField(upload_to='courses/files')),
],
),
]
......@@ -54,6 +54,9 @@ from courses.events.views import (
EventViewSet,
EventFeed,
)
from courses.editor.views import (
EditorContentFileViewSet,
)
router = routers.SimpleRouter(trailing_slash=False)
......@@ -108,6 +111,8 @@ router.register(r'actions-user', UserActionsViewSet, base_name='actions-user')
router.register(r'note', NotesViewSet, base_name='note')
router.register(r'user_notes', UserNotesViewSet, base_name='user_notes')
router.register(r'editor-content-file', EditorContentFileViewSet)
app_name = 'courses'
urlpatterns = [
# Stats (Activity Stream related functionality)
......
Markdown is supported
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