Commit 27bf0780 authored by Bruno Martin's avatar Bruno Martin
Browse files

add is_public attribute to course models and show

only then to anonymous uses
parent 47ecd7ef
# Generated by Django 2.2.12 on 2020-04-21 03:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('courses', '0003_lesson_thumbnail'),
]
operations = [
migrations.AddField(
model_name='course',
name='is_public',
field=models.BooleanField(default=False, verbose_name='Public'),
),
]
......@@ -139,6 +139,11 @@ class Course(models.Model):
related_name="courses",
)
is_public = models.BooleanField(
_('Public'),
default=False,
)
class Meta:
verbose_name = _('Course')
verbose_name_plural = _('Courses')
......
......@@ -19,7 +19,7 @@ class CourseViewSet(viewsets.ModelViewSet):
queryset = super(CourseViewSet, self).get_queryset()
if not self.request.user.is_authenticated:
return queryset.filter(status='published').prefetch_related('professors')
return queryset.filter(is_public=True, status='published').prefetch_related('professors')
public_courses = self.request.query_params.get('public_courses', None)
if public_courses:
......
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