Commit a6108363 authored by Bruno Martin's avatar Bruno Martin
Browse files

Merge branch 'develop'

parents 87c040ac aa68b8ad
......@@ -12,7 +12,7 @@ class Classroom(models.Model):
max_length=255,
)
description = models.TextField(
_('Pronatec'),
_('description'),
blank=True,
)
image = models.ImageField(
......
......@@ -4,6 +4,8 @@ from baquara.users.serializers import SimpleUserSerializer
from courses.serializers import BasicCourseSerializer
from discussion.serializers import ForumSumarySerializer
from .models import Classroom, Event
......@@ -37,6 +39,7 @@ class ClassroomSerializer(serializers.ModelSerializer):
coordinators = SimpleUserSerializer(read_only=True, many=True)
events = EventSerializer(read_only=True, many=True)
courses = BasicCourseSerializer(read_only=True, many=True)
forum = ForumSumarySerializer(read_only=True)
class Meta:
model = Classroom
......@@ -51,5 +54,6 @@ class ClassroomSerializer(serializers.ModelSerializer):
'group',
'events',
'chat_url',
'forum',
)
depth = 1
......@@ -13,12 +13,16 @@ from .serializers import (
from .permissions import IsClassroomAssistantOrCoordinatorOrReadOnly
class EventViewSet(viewsets.ReadOnlyModelViewSet):
class EventViewSet(viewsets.ModelViewSet):
queryset = Event.objects.all()
serializer_class = EventSerializer
permission_classes = [IsAuthenticated]
def get_queryset(self):
queryset = super().get_queryset()
return queryset
class BasicClassroomViewSet(viewsets.ReadOnlyModelViewSet):
......@@ -32,11 +36,15 @@ class BasicClassroomViewSet(viewsets.ReadOnlyModelViewSet):
if not self.request.user.is_superuser:
queryset = queryset.filter(
Q(groups__in=self.request.user.groups.all())
Q(group__in=self.request.user.groups.all())
| Q(assistants=self.request.user)
| Q(coordinators=self.request.user)
)
queryset = queryset.select_related(
'forum',
'group',
)
queryset = queryset.prefetch_related(
'assistants',
'coordinators',
......
......@@ -31,8 +31,7 @@ from courses.classroom.views import (
EventViewSet,
)
router = routers.DefaultRouter()
router = routers.SimpleRouter(trailing_slash=False)
router.register(r'course', CourseViewSet, base_name='course')
router.register(r'course_material', CourseMaterialViewSet, base_name='course_material')
router.register(r'course_material_file', CourseMaterialFileViewSet, base_name='course_material_file')
......
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