Merged in feature/update-wagtail-4.2-pr (pull request #125)
Feature/update wagtail 4.2 pr Approved-by: Daniel Egger
This commit is contained in:
commit
b63f850ec0
4
Pipfile
4
Pipfile
|
|
@ -27,7 +27,7 @@ graphene-django = "==2.15.0"
|
|||
django-filter = "~=21.1"
|
||||
djangorestframework = "~=3.8"
|
||||
pillow = "==9.1.0"
|
||||
wagtail = "~=2.15"
|
||||
wagtail = "~=4.2"
|
||||
django-cors-headers = "~=3.0"
|
||||
django-storages = "*"
|
||||
boto3 = "*"
|
||||
|
|
@ -44,3 +44,5 @@ django-silk = "*"
|
|||
wagtail-autocomplete = "*"
|
||||
jedi = "==0.17.2"
|
||||
Authlib = "*"
|
||||
django-stubs = {extras = ["compatible-mypy"], version = "*"}
|
||||
black = "*"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -113,6 +113,26 @@ const mockGraphqlOps = (options) => {
|
|||
cy.get('@mockGraphqlOps').invoke('setOperations' as any, options);
|
||||
};
|
||||
|
||||
const login = (username: string, password: string, visitLogin = false) => {
|
||||
if (visitLogin) {
|
||||
cy.visit('/beta-login');
|
||||
}
|
||||
|
||||
if (username !== '') {
|
||||
cy.get('[data-cy=email-input]').type(username);
|
||||
}
|
||||
|
||||
if (password !== '') {
|
||||
cy.get('[data-cy=password-input]').type(password);
|
||||
}
|
||||
cy.get('[data-cy=login-button]').click();
|
||||
};
|
||||
|
||||
const fakeLogin = () => {
|
||||
cy.log('Logging in (fake)');
|
||||
cy.setCookie('loginStatus', 'true');
|
||||
};
|
||||
|
||||
declare global {
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
|
|
@ -136,9 +156,9 @@ declare global {
|
|||
|
||||
selectClass(schoolClass: string): void;
|
||||
|
||||
login(username: string, password: string, visitLogin?: boolean): void;
|
||||
login: typeof login;
|
||||
|
||||
fakeLogin(username: string, password: string): void;
|
||||
fakeLogin: typeof fakeLogin;
|
||||
|
||||
isSubmissionReadOnly(myText: string): void;
|
||||
|
||||
|
|
@ -180,20 +200,7 @@ Cypress.Commands.add('apolloLogin', (username, password) => {
|
|||
});
|
||||
|
||||
// todo: replace with apollo call
|
||||
Cypress.Commands.add('login', (username, password, visitLogin = false) => {
|
||||
if (visitLogin) {
|
||||
cy.visit('/beta-login');
|
||||
}
|
||||
|
||||
if (username !== '') {
|
||||
cy.get('[data-cy=email-input]').type(username);
|
||||
}
|
||||
|
||||
if (password !== '') {
|
||||
cy.get('[data-cy=password-input]').type(password);
|
||||
}
|
||||
cy.get('[data-cy=login-button]').click();
|
||||
});
|
||||
Cypress.Commands.add('login', login);
|
||||
|
||||
Cypress.Commands.add('getByDataCy', getByDataCy);
|
||||
|
||||
|
|
@ -203,10 +210,7 @@ Cypress.Commands.add('selectClass', (schoolClass) => {
|
|||
cy.getByDataCy('class-selection-entry').contains(schoolClass).click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('fakeLogin', () => {
|
||||
cy.log('Logging in (fake)');
|
||||
cy.setCookie('loginStatus', 'true');
|
||||
});
|
||||
Cypress.Commands.add('fakeLogin', fakeLogin);
|
||||
|
||||
Cypress.Commands.add('isSubmissionReadOnly', (myText) => {
|
||||
cy.get('.submission-form__textarea--readonly').as('textarea');
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import logging
|
|||
from graphene.types import Scalar
|
||||
from graphene_django.converter import convert_django_field
|
||||
from graphql_relay import to_global_id
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.fields import StreamField
|
||||
from wagtail.documents.models import Document
|
||||
from wagtail.images.models import Image
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Generated by Django 2.2.19 on 2021-03-15 21:43
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.fields
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -14,6 +14,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='assignment',
|
||||
name='solution',
|
||||
field=wagtail.core.fields.RichTextField(blank=True, null=True),
|
||||
field=wagtail.fields.RichTextField(blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Generated by Django 3.2.13 on 2022-06-15 15:40
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.fields
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -14,6 +14,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='assignment',
|
||||
name='assignment',
|
||||
field=wagtail.core.fields.RichTextField(),
|
||||
field=wagtail.fields.RichTextField(),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from django_extensions.db.models import TimeStampedModel
|
||||
from wagtail.admin.edit_handlers import FieldPanel
|
||||
from wagtail.core.fields import RichTextField
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.snippets.models import register_snippet
|
||||
from wagtailautocomplete.edit_handlers import AutocompletePanel
|
||||
from wagtail.search import index
|
||||
|
|
|
|||
|
|
@ -10,51 +10,54 @@
|
|||
|
||||
from graphql_relay import to_global_id
|
||||
|
||||
from api.test_utils import create_client, DefaultUserTestCase
|
||||
from assignments.models import Assignment, StudentSubmission
|
||||
from api.test_utils import create_client
|
||||
from core.tests.base_test import SkillboxTestCase
|
||||
from users.factories import SchoolClassFactory
|
||||
from users.models import SchoolClassMember
|
||||
from .queries.mutations import UPDATE_SUBMISSION_FEEDBACK_MUTATION
|
||||
from ..factories import AssignmentFactory, StudentSubmissionFactory, SubmissionFeedbackFactory
|
||||
from ..factories import (
|
||||
AssignmentFactory,
|
||||
StudentSubmissionFactory,
|
||||
SubmissionFeedbackFactory,
|
||||
)
|
||||
|
||||
|
||||
class SubmissionFeedbackTestCase(SkillboxTestCase):
|
||||
def setUp(self):
|
||||
self.createDefault()
|
||||
|
||||
self.assignment = AssignmentFactory(
|
||||
owner=self.teacher
|
||||
)
|
||||
self.assignment_id = to_global_id('AssignmentNode', self.assignment.pk)
|
||||
self.assignment = AssignmentFactory(owner=self.teacher)
|
||||
self.assignment_id = to_global_id("AssignmentNode", self.assignment.pk)
|
||||
|
||||
self.student_submission = StudentSubmissionFactory(assignment=self.assignment, student=self.student1,
|
||||
final=False)
|
||||
self.student_submission_id = to_global_id('StudentSubmissionNode', self.student_submission.pk)
|
||||
self.student_submission = StudentSubmissionFactory(
|
||||
assignment=self.assignment, student=self.student1, final=False
|
||||
)
|
||||
self.student_submission_id = to_global_id(
|
||||
"StudentSubmissionNode", self.student_submission.pk
|
||||
)
|
||||
|
||||
school_class = SchoolClassFactory()
|
||||
for user in [self.student1, self.teacher]:
|
||||
SchoolClassMember.objects.create(
|
||||
user=user,
|
||||
school_class=school_class
|
||||
)
|
||||
SchoolClassMember.objects.create(user=user, school_class=school_class)
|
||||
user.set_selected_class(school_class)
|
||||
|
||||
|
||||
def _create_submission_feedback(self, user, final, text, student_submission_id):
|
||||
return self.get_client(user).execute(UPDATE_SUBMISSION_FEEDBACK_MUTATION, variables={
|
||||
'input': {
|
||||
"submissionFeedback": {
|
||||
"studentSubmission": student_submission_id,
|
||||
"text": text,
|
||||
"final": final
|
||||
return self.get_client(user).execute(
|
||||
UPDATE_SUBMISSION_FEEDBACK_MUTATION,
|
||||
variables={
|
||||
"input": {
|
||||
"submissionFeedback": {
|
||||
"studentSubmission": student_submission_id,
|
||||
"text": text,
|
||||
"final": final,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
def _fetch_assignment_student(self, user):
|
||||
client = self.get_client(user)
|
||||
query = '''
|
||||
query = """
|
||||
query AssignmentWithSubmissions($id: ID!) {
|
||||
assignment(id: $id) {
|
||||
title
|
||||
|
|
@ -68,14 +71,12 @@ class SubmissionFeedbackTestCase(SkillboxTestCase):
|
|||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
return client.execute(query, variables={
|
||||
'id': self.assignment_id
|
||||
})
|
||||
"""
|
||||
return client.execute(query, variables={"id": self.assignment_id})
|
||||
|
||||
def _fetch_assignment_teacher(self, user):
|
||||
client = self.get_client(user)
|
||||
query = '''
|
||||
query = """
|
||||
query AssignmentWithSubmissions($id: ID!) {
|
||||
assignment(id: $id) {
|
||||
title
|
||||
|
|
@ -89,14 +90,12 @@ class SubmissionFeedbackTestCase(SkillboxTestCase):
|
|||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
return client.execute(query, variables={
|
||||
'id': self.assignment_id
|
||||
})
|
||||
"""
|
||||
return client.execute(query, variables={"id": self.assignment_id})
|
||||
|
||||
def _fetch_submission_teacher(self, user):
|
||||
client = self.get_client(user)
|
||||
query = '''
|
||||
query = """
|
||||
query StudentSubmission($id: ID!) {
|
||||
studentSubmission(id: $id) {
|
||||
id
|
||||
|
|
@ -107,14 +106,12 @@ class SubmissionFeedbackTestCase(SkillboxTestCase):
|
|||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
return client.execute(query, variables={
|
||||
'id': self.student_submission_id
|
||||
})
|
||||
"""
|
||||
return client.execute(query, variables={"id": self.student_submission_id})
|
||||
|
||||
def _fetch_submission_feedback(self, user):
|
||||
client = create_client(user)
|
||||
query = '''
|
||||
query = """
|
||||
query AssignmentWithSubmissions($id: ID!) {
|
||||
assignment(id: $id) {
|
||||
title
|
||||
|
|
@ -128,96 +125,136 @@ class SubmissionFeedbackTestCase(SkillboxTestCase):
|
|||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
return client.execute(query, variables={
|
||||
'id': self.assignment_id
|
||||
})
|
||||
"""
|
||||
return client.execute(query, variables={"id": self.assignment_id})
|
||||
|
||||
def test_teacher_can_create_feedback(self):
|
||||
result = self._create_submission_feedback(self.teacher, False, 'Balalal', self.student_submission_id)
|
||||
result = self._create_submission_feedback(
|
||||
self.teacher, False, "Balalal", self.student_submission_id
|
||||
)
|
||||
|
||||
self.assertIsNone(result.errors)
|
||||
self.assertIsNotNone(
|
||||
result.data.get('updateSubmissionFeedback').get('updatedSubmissionFeedback').get('id'))
|
||||
|
||||
def test_student_cannot_create_feedback(self):
|
||||
result = self._create_submission_feedback(self.student1, False, 'Balalal', self.student_submission_id)
|
||||
self.assertIsNotNone(result.errors)
|
||||
self.assertEqual(len(result.errors), 1)
|
||||
self.assertEqual(result.errors[0].get('message'), 'Missing permissions')
|
||||
|
||||
def test_teacher_can_update_feedback(self):
|
||||
assignment = AssignmentFactory(
|
||||
owner=self.teacher
|
||||
result.data.get("updateSubmissionFeedback")
|
||||
.get("updatedSubmissionFeedback")
|
||||
.get("id")
|
||||
)
|
||||
|
||||
student_submission = StudentSubmissionFactory(assignment=assignment, student=self.student1, final=False)
|
||||
submission_feedback = SubmissionFeedbackFactory(teacher=self.teacher, final=False,
|
||||
student_submission=student_submission)
|
||||
submission_feedback_id = to_global_id('SubmissionFeedback', submission_feedback.pk)
|
||||
def test_student_cannot_create_feedback(self):
|
||||
result = self._create_submission_feedback(
|
||||
self.student1, False, "Balalal", self.student_submission_id
|
||||
)
|
||||
self.assertIsNotNone(result.errors)
|
||||
self.assertEqual(len(result.errors), 1)
|
||||
self.assertEqual(result.errors[0].get("message"), "Missing permissions")
|
||||
|
||||
result = self._create_submission_feedback(self.teacher, True, 'Some', submission_feedback_id)
|
||||
def test_teacher_can_update_feedback(self):
|
||||
assignment = AssignmentFactory(owner=self.teacher)
|
||||
|
||||
student_submission = StudentSubmissionFactory(
|
||||
assignment=assignment, student=self.student1, final=False
|
||||
)
|
||||
submission_feedback = SubmissionFeedbackFactory(
|
||||
teacher=self.teacher, final=False, student_submission=student_submission
|
||||
)
|
||||
submission_feedback_id = to_global_id(
|
||||
"SubmissionFeedback", submission_feedback.pk
|
||||
)
|
||||
|
||||
result = self._create_submission_feedback(
|
||||
self.teacher, True, "Some", submission_feedback_id
|
||||
)
|
||||
|
||||
self.assertIsNone(result.errors)
|
||||
|
||||
submission_feedback_response = result.data.get('updateSubmissionFeedback').get(
|
||||
'updatedSubmissionFeedback')
|
||||
|
||||
self.assertTrue(submission_feedback_response.get('final'))
|
||||
self.assertEqual(submission_feedback_response.get('text'), 'Some')
|
||||
|
||||
def test_external_teacher_cannot_update_feedback(self):
|
||||
assignment = AssignmentFactory(
|
||||
owner=self.teacher
|
||||
submission_feedback_response = result.data.get("updateSubmissionFeedback").get(
|
||||
"updatedSubmissionFeedback"
|
||||
)
|
||||
|
||||
student_submission = StudentSubmissionFactory(assignment=assignment, student=self.student1, final=False)
|
||||
submission_feedback = SubmissionFeedbackFactory(teacher=self.teacher, final=False,
|
||||
student_submission=student_submission)
|
||||
submission_feedback_id = to_global_id('SubmissionFeedback', submission_feedback.pk)
|
||||
self.assertTrue(submission_feedback_response.get("final"))
|
||||
self.assertEqual(submission_feedback_response.get("text"), "Some")
|
||||
|
||||
result = self._create_submission_feedback(self.teacher2, True, 'Some', submission_feedback_id)
|
||||
def test_external_teacher_cannot_update_feedback(self):
|
||||
assignment = AssignmentFactory(owner=self.teacher)
|
||||
|
||||
student_submission = StudentSubmissionFactory(
|
||||
assignment=assignment, student=self.student1, final=False
|
||||
)
|
||||
submission_feedback = SubmissionFeedbackFactory(
|
||||
teacher=self.teacher, final=False, student_submission=student_submission
|
||||
)
|
||||
submission_feedback_id = to_global_id(
|
||||
"SubmissionFeedback", submission_feedback.pk
|
||||
)
|
||||
|
||||
result = self._create_submission_feedback(
|
||||
self.teacher2, True, "Some", submission_feedback_id
|
||||
)
|
||||
|
||||
self.assertIsNotNone(result.errors)
|
||||
|
||||
def test_student_does_not_see_non_final_feedback(self):
|
||||
SubmissionFeedbackFactory(teacher=self.teacher, final=False, student_submission=self.student_submission)
|
||||
SubmissionFeedbackFactory(
|
||||
teacher=self.teacher,
|
||||
final=False,
|
||||
student_submission=self.student_submission,
|
||||
)
|
||||
result = self._fetch_assignment_student(self.student1)
|
||||
|
||||
self.assertIsNone(result.data.get('submissionFeedback'))
|
||||
self.assertIsNone(result.data.get("submissionFeedback"))
|
||||
|
||||
def test_student_does_see_final_feedback(self):
|
||||
submission_feedback = SubmissionFeedbackFactory(teacher=self.teacher, final=True,
|
||||
student_submission=self.student_submission)
|
||||
submission_feedback = SubmissionFeedbackFactory(
|
||||
teacher=self.teacher, final=True, student_submission=self.student_submission
|
||||
)
|
||||
result = self._fetch_assignment_student(self.student1)
|
||||
self.assertEqual(result.data.get('assignment').get('submission').get('submissionFeedback')
|
||||
.get('text'), submission_feedback.text)
|
||||
self.assertEqual(
|
||||
result.data.get("assignment")
|
||||
.get("submission")
|
||||
.get("submissionFeedback")
|
||||
.get("text"),
|
||||
submission_feedback.text,
|
||||
)
|
||||
|
||||
def test_teacher_can_see_feedback_for_submission(self):
|
||||
submission_feedback = SubmissionFeedbackFactory(teacher=self.teacher, final=False,
|
||||
student_submission=self.student_submission)
|
||||
submission_feedback = SubmissionFeedbackFactory(
|
||||
teacher=self.teacher,
|
||||
final=False,
|
||||
student_submission=self.student_submission,
|
||||
)
|
||||
self.student_submission.final = True
|
||||
self.student_submission.save()
|
||||
|
||||
result = self._fetch_assignment_teacher(self.teacher)
|
||||
self.assertEqual(result.data.get('assignment').get('submissions')[0].get('submissionFeedback')
|
||||
.get('text'), submission_feedback.text)
|
||||
self.assertEqual(
|
||||
result.data.get("assignment")
|
||||
.get("submissions")[0]
|
||||
.get("submissionFeedback")
|
||||
.get("text"),
|
||||
submission_feedback.text,
|
||||
)
|
||||
|
||||
def test_external_teacher_cannot_see_assignment_with_feedback(self):
|
||||
SubmissionFeedbackFactory(teacher=self.teacher, final=False,
|
||||
student_submission=self.student_submission)
|
||||
SubmissionFeedbackFactory(
|
||||
teacher=self.teacher,
|
||||
final=False,
|
||||
student_submission=self.student_submission,
|
||||
)
|
||||
self.student_submission.final = True
|
||||
self.student_submission.save()
|
||||
|
||||
result = self._fetch_assignment_teacher(self.teacher2)
|
||||
self.assertEqual(result.data.get('assignment').get('submissions'), [])
|
||||
self.assertEqual(result.data.get("assignment").get("submissions"), [])
|
||||
|
||||
def test_external_teacher_cannot_see_feedback(self):
|
||||
SubmissionFeedbackFactory(teacher=self.teacher, final=False,
|
||||
student_submission=self.student_submission)
|
||||
SubmissionFeedbackFactory(
|
||||
teacher=self.teacher,
|
||||
final=False,
|
||||
student_submission=self.student_submission,
|
||||
)
|
||||
self.student_submission.final = True
|
||||
self.student_submission.save()
|
||||
|
||||
result = self._fetch_submission_teacher(self.teacher2)
|
||||
self.assertIsNone(result.errors)
|
||||
self.assertIsNone(result.data.get('studentSubmission'))
|
||||
self.assertIsNone(result.data.get("studentSubmission"))
|
||||
|
|
|
|||
|
|
@ -1,35 +1,23 @@
|
|||
from django.conf import settings
|
||||
import json
|
||||
|
||||
from django.test import TestCase, RequestFactory
|
||||
from graphene.test import Client
|
||||
|
||||
from api import schema
|
||||
from api.schema import schema
|
||||
from api.test_utils import DefaultUserTestCase, create_client
|
||||
from assignments.factories import AssignmentFactory, StudentSubmissionFactory
|
||||
from assignments.models import Assignment
|
||||
from books.factories import ModuleFactory
|
||||
from books.models import ContentBlock, Chapter
|
||||
from core.factories import UserFactory
|
||||
from users.models import User
|
||||
from users.services import create_users
|
||||
|
||||
|
||||
class MyAssignmentsTest(DefaultUserTestCase):
|
||||
def setUp(self):
|
||||
super(MyAssignmentsTest, self).setUp()
|
||||
self.assignment = AssignmentFactory(
|
||||
owner=self.teacher
|
||||
)
|
||||
self.assignment = AssignmentFactory(owner=self.teacher)
|
||||
|
||||
self.submission1 = StudentSubmissionFactory(student=self.student1, assignment=self.assignment)
|
||||
self.submission2 = StudentSubmissionFactory(student=self.student2, assignment=self.assignment)
|
||||
self.submission1 = StudentSubmissionFactory(
|
||||
student=self.student1, assignment=self.assignment
|
||||
)
|
||||
self.submission2 = StudentSubmissionFactory(
|
||||
student=self.student2, assignment=self.assignment
|
||||
)
|
||||
|
||||
self.client = create_client(self.student1)
|
||||
|
||||
def query_my_assignments(self):
|
||||
query = '''
|
||||
query = """
|
||||
query MyActivityQuery {
|
||||
myActivity {
|
||||
edges {
|
||||
|
|
@ -138,20 +126,27 @@ class MyAssignmentsTest(DefaultUserTestCase):
|
|||
}
|
||||
}
|
||||
|
||||
'''
|
||||
"""
|
||||
|
||||
result = self.client.execute(query)
|
||||
|
||||
self.assertIsNone(result.get('errors'))
|
||||
self.assertIsNone(result.get("errors"))
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def get_content(result):
|
||||
return result.get('data').get('myActivity').get('edges')
|
||||
return result.get("data").get("myActivity").get("edges")
|
||||
|
||||
def test_my_assignment_query(self):
|
||||
result = self.query_my_assignments()
|
||||
contents = self.get_content(result)
|
||||
self.assertEqual(len(contents), 1)
|
||||
self.assertEquals(contents[0].get('node').get('mySubmissions').get('edges')[0].get('node').get('text'), self.submission1.text)
|
||||
|
||||
self.assertEquals(
|
||||
contents[0]
|
||||
.get("node")
|
||||
.get("mySubmissions")
|
||||
.get("edges")[0]
|
||||
.get("node")
|
||||
.get("text"),
|
||||
self.submission1.text,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@ from datetime import timedelta, date
|
|||
from graphql_relay import to_global_id
|
||||
|
||||
from assignments.factories import AssignmentFactory, StudentSubmissionFactory
|
||||
from assignments.tests.queries.mutations import UPDATE_ASSIGNMENT_MUTATION, UPDATE_SUBMISSION_FEEDBACK_MUTATION
|
||||
from assignments.tests.queries.mutations import (
|
||||
UPDATE_ASSIGNMENT_MUTATION,
|
||||
UPDATE_SUBMISSION_FEEDBACK_MUTATION,
|
||||
)
|
||||
from core.tests.base_test import SkillboxTestCase
|
||||
from users.models import User
|
||||
|
||||
|
||||
class AssignmentReadOnlyTestCase(SkillboxTestCase):
|
||||
|
|
@ -18,7 +20,7 @@ class AssignmentReadOnlyTestCase(SkillboxTestCase):
|
|||
self.teacher.license_expiry_date = yesterday
|
||||
self.teacher.save()
|
||||
self.assignment = AssignmentFactory()
|
||||
self.assignment_id = to_global_id('AssignmentNode', self.assignment.id)
|
||||
self.assignment_id = to_global_id("AssignmentNode", self.assignment.id)
|
||||
|
||||
def test_edit_assignment_fails(self):
|
||||
variables = {
|
||||
|
|
@ -27,11 +29,13 @@ class AssignmentReadOnlyTestCase(SkillboxTestCase):
|
|||
"answer": "bla",
|
||||
"document": "",
|
||||
"final": False,
|
||||
"id": self.assignment_id
|
||||
"id": self.assignment_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
result = self.get_client(self.student1).execute(UPDATE_ASSIGNMENT_MUTATION, variables=variables)
|
||||
result = self.get_client(self.student1).execute(
|
||||
UPDATE_ASSIGNMENT_MUTATION, variables=variables
|
||||
)
|
||||
self.assertIsNotNone(result.errors)
|
||||
|
||||
def test_share_assignment_fails(self):
|
||||
|
|
@ -41,42 +45,55 @@ class AssignmentReadOnlyTestCase(SkillboxTestCase):
|
|||
"answer": "bla",
|
||||
"document": "",
|
||||
"final": True,
|
||||
"id": self.assignment_id
|
||||
"id": self.assignment_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
result = self.get_client(self.student1).execute(UPDATE_ASSIGNMENT_MUTATION, variables=variables)
|
||||
result = self.get_client(self.student1).execute(
|
||||
UPDATE_ASSIGNMENT_MUTATION, variables=variables
|
||||
)
|
||||
self.assertIsNotNone(result.errors)
|
||||
|
||||
def test_edit_feedback_fails(self):
|
||||
student_submission = StudentSubmissionFactory(assignment=self.assignment, student=self.student1,
|
||||
final=True)
|
||||
student_submission_id = to_global_id('StudentSubmissionNode', student_submission.id)
|
||||
result = self.get_client(self.teacher).execute(UPDATE_SUBMISSION_FEEDBACK_MUTATION, variables={
|
||||
'input': {
|
||||
"submissionFeedback": {
|
||||
"studentSubmission": student_submission_id,
|
||||
"text": "Feedback",
|
||||
"final": False
|
||||
student_submission = StudentSubmissionFactory(
|
||||
assignment=self.assignment, student=self.student1, final=True
|
||||
)
|
||||
student_submission_id = to_global_id(
|
||||
"StudentSubmissionNode", student_submission.id
|
||||
)
|
||||
result = self.get_client(self.teacher).execute(
|
||||
UPDATE_SUBMISSION_FEEDBACK_MUTATION,
|
||||
variables={
|
||||
"input": {
|
||||
"submissionFeedback": {
|
||||
"studentSubmission": student_submission_id,
|
||||
"text": "Feedback",
|
||||
"final": False,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
self.assertIsNotNone(result.errors)
|
||||
|
||||
|
||||
def test_share_feedback_fails(self):
|
||||
student_submission = StudentSubmissionFactory(assignment=self.assignment, student=self.student1,
|
||||
final=True)
|
||||
student_submission_id = to_global_id('StudentSubmissionNode', student_submission.id)
|
||||
result = self.get_client(self.teacher).execute(UPDATE_SUBMISSION_FEEDBACK_MUTATION, variables={
|
||||
'input': {
|
||||
"submissionFeedback": {
|
||||
"studentSubmission": student_submission_id,
|
||||
"text": "Feedback",
|
||||
"final": True
|
||||
student_submission = StudentSubmissionFactory(
|
||||
assignment=self.assignment, student=self.student1, final=True
|
||||
)
|
||||
student_submission_id = to_global_id(
|
||||
"StudentSubmissionNode", student_submission.id
|
||||
)
|
||||
result = self.get_client(self.teacher).execute(
|
||||
UPDATE_SUBMISSION_FEEDBACK_MUTATION,
|
||||
variables={
|
||||
"input": {
|
||||
"submissionFeedback": {
|
||||
"studentSubmission": student_submission_id,
|
||||
"text": "Feedback",
|
||||
"final": True,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
self.assertIsNotNone(result.errors)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ class Migration(migrations.Migration):
|
|||
name='BasicKnowledge',
|
||||
fields=[
|
||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||
('contents', wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True)),
|
||||
('contents', wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True)),
|
||||
('type', models.CharField(choices=[('language_communication', 'Sprache & Kommunikation'), ('society', 'Gesellschaft')], max_length=100)),
|
||||
],
|
||||
options={
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 2.0.6 on 2019-07-22 09:32
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
||||
|
|
@ -16,6 +16,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='basicknowledge',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['bold', 'ul']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('section_title', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['bold', 'ul']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('section_title', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 2.0.6 on 2019-11-28 16:01
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
||||
|
|
@ -16,6 +16,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='basicknowledge',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['bold', 'ul']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('section_title', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['bold', 'ul']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('section_title', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 2.1.15 on 2020-05-20 09:54
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
||||
|
|
@ -16,6 +16,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='basicknowledge',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['bold', 'ul', 'brand', 'secondary']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('section_title', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['bold', 'ul', 'brand', 'secondary']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('section_title', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Generated by Django 2.2.12 on 2020-09-29 07:54
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.fields
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -14,6 +14,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AddField(
|
||||
model_name='basicknowledge',
|
||||
name='intro',
|
||||
field=wagtail.core.fields.RichTextField(blank=True, default=''),
|
||||
field=wagtail.fields.RichTextField(blank=True, default=''),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 3.2.13 on 2022-07-28 08:48
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.documents.blocks
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
|
@ -17,6 +17,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='basicknowledge',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['bold', 'ul', 'brand', 'secondary']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('section_title', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('cms_document_block', wagtail.documents.blocks.DocumentChooserBlock())], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['bold', 'ul', 'brand', 'secondary']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('section_title', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('cms_document_block', wagtail.documents.blocks.DocumentChooserBlock())], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
import books.blocks
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
||||
|
|
@ -29,6 +29,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='basicknowledge',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['bold', 'ul', 'brand', 'secondary']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('section_title', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock())], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['bold', 'ul', 'brand', 'secondary']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('section_title', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock())], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 3.2.16 on 2023-02-21 16:04
|
||||
|
||||
import books.blocks
|
||||
from django.db import migrations
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('basicknowledge', '0025_auto_20220914_1338'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='basicknowledge',
|
||||
name='contents',
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['bold', 'ul', 'brand', 'secondary']))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('section_title', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock())], blank=True, null=True, use_json_field=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -1,35 +1,44 @@
|
|||
from django.db import models
|
||||
from django.utils.text import slugify
|
||||
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||
from wagtail.core.fields import RichTextField, StreamField
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.fields import RichTextField, StreamField
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
from books.blocks import CMSDocumentBlock, DocumentBlock, GeniallyBlock, InfogramBlock, InstrumentTextBlock, LinkBlock, \
|
||||
SectionTitleBlock, \
|
||||
SubtitleBlock, ThinglinkBlock, VideoBlock
|
||||
from books.blocks import (
|
||||
CMSDocumentBlock,
|
||||
DocumentBlock,
|
||||
GeniallyBlock,
|
||||
InfogramBlock,
|
||||
InstrumentTextBlock,
|
||||
LinkBlock,
|
||||
SectionTitleBlock,
|
||||
SubtitleBlock,
|
||||
ThinglinkBlock,
|
||||
VideoBlock,
|
||||
)
|
||||
from core.constants import DEFAULT_RICH_TEXT_FEATURES
|
||||
from core.wagtail_utils import StrictHierarchyPage
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
LANGUAGE_COMMUNICATION = 'language_communication'
|
||||
SOCIETY = 'society'
|
||||
INTERDISCIPLINARY = 'interdisciplinary'
|
||||
LANGUAGE_COMMUNICATION_LABEL = 'Sprache & Kommunikation'
|
||||
SOCIETY_LABEL = 'Gesellschaft'
|
||||
INTERDISCIPLINARY_LABEL = 'Überfachliche Instrumente'
|
||||
LANGUAGE_COMMUNICATION = "language_communication"
|
||||
SOCIETY = "society"
|
||||
INTERDISCIPLINARY = "interdisciplinary"
|
||||
LANGUAGE_COMMUNICATION_LABEL = "Sprache & Kommunikation"
|
||||
SOCIETY_LABEL = "Gesellschaft"
|
||||
INTERDISCIPLINARY_LABEL = "Überfachliche Instrumente"
|
||||
|
||||
|
||||
class InstrumentCategory(models.Model):
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
background = models.CharField('background color', max_length=7)
|
||||
foreground = models.CharField('foreground color', max_length=7)
|
||||
background = models.CharField("background color", max_length=7)
|
||||
foreground = models.CharField("foreground color", max_length=7)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = _('instrument categories')
|
||||
verbose_name = _('instrument category')
|
||||
verbose_name_plural = _("instrument categories")
|
||||
verbose_name = _("instrument category")
|
||||
|
||||
|
||||
def default_category():
|
||||
|
|
@ -38,8 +47,8 @@ def default_category():
|
|||
|
||||
class InstrumentType(models.Model):
|
||||
class Meta:
|
||||
verbose_name = _('instrument type')
|
||||
verbose_name_plural = _('instrument types')
|
||||
verbose_name = _("instrument type")
|
||||
verbose_name_plural = _("instrument types")
|
||||
|
||||
CATEGORY_CHOICES = (
|
||||
(LANGUAGE_COMMUNICATION, LANGUAGE_COMMUNICATION_LABEL),
|
||||
|
|
@ -53,7 +62,7 @@ class InstrumentType(models.Model):
|
|||
on_delete=models.PROTECT,
|
||||
null=False,
|
||||
default=default_category,
|
||||
related_name='instrument_types'
|
||||
related_name="instrument_types",
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
@ -64,42 +73,46 @@ class InstrumentType(models.Model):
|
|||
return self.type
|
||||
|
||||
|
||||
|
||||
class BasicKnowledge(StrictHierarchyPage):
|
||||
class Meta:
|
||||
verbose_name = _('instrument')
|
||||
verbose_name_plural = _('instruments')
|
||||
verbose_name = _("instrument")
|
||||
verbose_name_plural = _("instruments")
|
||||
|
||||
parent_page_types = ['books.book']
|
||||
parent_page_types = ["books.book"]
|
||||
|
||||
intro = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES, default='', blank=True)
|
||||
intro = RichTextField(
|
||||
features=DEFAULT_RICH_TEXT_FEATURES, default="", blank=True)
|
||||
|
||||
contents = StreamField([
|
||||
('text_block', InstrumentTextBlock()),
|
||||
('image_block', ImageChooserBlock()),
|
||||
('link_block', LinkBlock()),
|
||||
('video_block', VideoBlock()),
|
||||
('document_block', DocumentBlock()),
|
||||
('section_title', SectionTitleBlock()),
|
||||
('infogram_block', InfogramBlock()),
|
||||
('genially_block', GeniallyBlock()),
|
||||
('thinglink_block', ThinglinkBlock()),
|
||||
('subtitle', SubtitleBlock()),
|
||||
('cms_document_block', CMSDocumentBlock()),
|
||||
], null=True, blank=True)
|
||||
contents = StreamField(
|
||||
[
|
||||
("text_block", InstrumentTextBlock()),
|
||||
("image_block", ImageChooserBlock()),
|
||||
("link_block", LinkBlock()),
|
||||
("video_block", VideoBlock()),
|
||||
("document_block", DocumentBlock()),
|
||||
("section_title", SectionTitleBlock()),
|
||||
("infogram_block", InfogramBlock()),
|
||||
("genially_block", GeniallyBlock()),
|
||||
("thinglink_block", ThinglinkBlock()),
|
||||
("subtitle", SubtitleBlock()),
|
||||
("cms_document_block", CMSDocumentBlock()),
|
||||
],
|
||||
null=True,
|
||||
blank=True,
|
||||
use_json_field=True,
|
||||
)
|
||||
|
||||
new_type = models.ForeignKey(InstrumentType, null=True, on_delete=models.PROTECT, related_name='instruments')
|
||||
new_type = models.ForeignKey(
|
||||
InstrumentType, null=True, on_delete=models.PROTECT, related_name="instruments"
|
||||
)
|
||||
|
||||
old_type = models.CharField(
|
||||
max_length=100,
|
||||
choices=InstrumentType.CATEGORY_CHOICES,
|
||||
blank=True
|
||||
max_length=100, choices=InstrumentType.CATEGORY_CHOICES, blank=True
|
||||
)
|
||||
|
||||
content_panels = [
|
||||
FieldPanel('title', classname="full title"),
|
||||
FieldPanel('new_type'),
|
||||
FieldPanel('intro'),
|
||||
StreamFieldPanel('contents')
|
||||
FieldPanel("title", classname="full title"),
|
||||
FieldPanel("new_type"),
|
||||
FieldPanel("intro"),
|
||||
FieldPanel("contents"),
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup, modeladmin_register
|
||||
from wagtail.core import hooks
|
||||
from wagtail.contrib.modeladmin.options import (
|
||||
ModelAdmin,
|
||||
ModelAdminGroup,
|
||||
modeladmin_register,
|
||||
)
|
||||
from wagtail import hooks
|
||||
|
||||
from .models import BasicKnowledge, InstrumentCategory, InstrumentType
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
|
@ -7,33 +11,45 @@ from core.logger import get_logger
|
|||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class InstrumentAdmin(ModelAdmin):
|
||||
model = BasicKnowledge
|
||||
list_display = ('title', 'new_type', 'status_string')
|
||||
search_fields = ('title', 'new_type__name')
|
||||
list_display = ("title", "new_type", "status_string")
|
||||
search_fields = ("title", "new_type__name")
|
||||
|
||||
|
||||
class InstrumentCategoryAdmin(ModelAdmin):
|
||||
model = InstrumentCategory
|
||||
list_display = ('name', 'background', 'foreground')
|
||||
list_display = ("name", "background", "foreground")
|
||||
|
||||
|
||||
class InstrumentTypeAdmin(ModelAdmin):
|
||||
model = InstrumentType
|
||||
list_display = ('name', 'category',)
|
||||
list_display = (
|
||||
"name",
|
||||
"category",
|
||||
)
|
||||
inspect_view_enabled = True
|
||||
inspect_view_fields = ('name', 'category', 'instruments',)
|
||||
inspect_view_fields = (
|
||||
"name",
|
||||
"category",
|
||||
"instruments",
|
||||
)
|
||||
|
||||
|
||||
class InstrumentGroup(ModelAdminGroup):
|
||||
menu_label = _('Instruments')
|
||||
items = (InstrumentAdmin, InstrumentTypeAdmin, InstrumentCategoryAdmin,)
|
||||
menu_label = _("Instruments")
|
||||
items = (
|
||||
InstrumentAdmin,
|
||||
InstrumentTypeAdmin,
|
||||
InstrumentCategoryAdmin,
|
||||
)
|
||||
|
||||
|
||||
modeladmin_register(InstrumentGroup)
|
||||
|
||||
|
||||
@hooks.register('construct_page_chooser_queryset')
|
||||
@hooks.register("construct_page_chooser_queryset")
|
||||
def order_by_created(pages, request):
|
||||
logger.debug('constructing page chooser queryset')
|
||||
return pages.live().order_by('-latest_revision_created_at')
|
||||
logger.debug("constructing page chooser queryset")
|
||||
return pages.all().order_by("-latest_revision_created_at")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from wagtail.core import blocks
|
||||
from wagtail import blocks
|
||||
from wagtail.documents.blocks import DocumentChooserBlock
|
||||
from wagtail.snippets.blocks import SnippetChooserBlock
|
||||
|
||||
|
|
@ -6,16 +6,29 @@ from assignments.models import Assignment
|
|||
from core.constants import DEFAULT_RICH_TEXT_FEATURES, INSTRUMENTS_RICH_TEXT_FEATURES
|
||||
from surveys.models import Survey
|
||||
|
||||
"""
|
||||
Using a StructBlock inside a StreamField (e.g. inside a ContentBlock):
|
||||
as an illustration
|
||||
data = {'text': 'This is me'}
|
||||
self.contents.append(('solution', data))
|
||||
|
||||
by itself:
|
||||
block = SolutionBlock()
|
||||
data = {'text': 'This is me'}
|
||||
value = block.to_python(data)
|
||||
cleaned_value = block.clean(value)
|
||||
"""
|
||||
|
||||
|
||||
class CMSDocumentBlock(DocumentChooserBlock):
|
||||
class Meta:
|
||||
label = 'CMS Document'
|
||||
label = "CMS Document"
|
||||
|
||||
|
||||
# link_block
|
||||
class LinkBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'link'
|
||||
icon = "link"
|
||||
|
||||
text = blocks.TextBlock()
|
||||
url = blocks.URLBlock()
|
||||
|
|
@ -24,14 +37,14 @@ class LinkBlock(blocks.StructBlock):
|
|||
# 'text_block' 'solution'
|
||||
class TextBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'doc-full'
|
||||
icon = "doc-full"
|
||||
|
||||
text = blocks.RichTextBlock(features=DEFAULT_RICH_TEXT_FEATURES)
|
||||
|
||||
|
||||
class SolutionBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'tick'
|
||||
icon = "tick"
|
||||
|
||||
text = blocks.RichTextBlock(features=DEFAULT_RICH_TEXT_FEATURES)
|
||||
document = CMSDocumentBlock(required=False)
|
||||
|
|
@ -40,17 +53,19 @@ class SolutionBlock(blocks.StructBlock):
|
|||
# 'basic_knowledge'
|
||||
class BasicKnowledgeBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'placeholder'
|
||||
label = 'Instrument'
|
||||
icon = "placeholder"
|
||||
label = "Instrument"
|
||||
|
||||
description = blocks.RichTextBlock(required=False)
|
||||
basic_knowledge = blocks.PageChooserBlock(required=True, page_type='basicknowledge.BasicKnowledge')
|
||||
basic_knowledge = blocks.PageChooserBlock(
|
||||
required=True, page_type="basicknowledge.BasicKnowledge"
|
||||
)
|
||||
|
||||
|
||||
# 'image_url'
|
||||
class ImageUrlBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'image'
|
||||
icon = "image"
|
||||
|
||||
title = blocks.TextBlock()
|
||||
url = blocks.URLBlock()
|
||||
|
|
@ -59,7 +74,7 @@ class ImageUrlBlock(blocks.StructBlock):
|
|||
# 'assignment'
|
||||
class AssignmentBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'download'
|
||||
icon = "download"
|
||||
|
||||
assignment_id = SnippetChooserBlock(Assignment)
|
||||
|
||||
|
|
@ -67,7 +82,7 @@ class AssignmentBlock(blocks.StructBlock):
|
|||
# 'survey'
|
||||
class SurveyBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'form'
|
||||
icon = "form"
|
||||
|
||||
survey_id = SnippetChooserBlock(Survey)
|
||||
|
||||
|
|
@ -75,7 +90,7 @@ class SurveyBlock(blocks.StructBlock):
|
|||
# 'video_block'
|
||||
class VideoBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'media'
|
||||
icon = "media"
|
||||
|
||||
url = blocks.URLBlock()
|
||||
|
||||
|
|
@ -83,7 +98,7 @@ class VideoBlock(blocks.StructBlock):
|
|||
# 'document_block'
|
||||
class DocumentBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'doc-full'
|
||||
icon = "doc-full"
|
||||
|
||||
url = blocks.URLBlock()
|
||||
|
||||
|
|
@ -111,21 +126,21 @@ class SubtitleBlock(blocks.StructBlock):
|
|||
|
||||
class InstrumentTextBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'doc-full'
|
||||
icon = "doc-full"
|
||||
|
||||
text = blocks.RichTextBlock(features=INSTRUMENTS_RICH_TEXT_FEATURES)
|
||||
|
||||
|
||||
class ModuleRoomSlugBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'link'
|
||||
icon = "link"
|
||||
|
||||
title = blocks.TextBlock()
|
||||
|
||||
|
||||
class InstructionBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'help'
|
||||
icon = "help"
|
||||
|
||||
url = blocks.URLBlock(required=False)
|
||||
text = blocks.TextBlock(required=False)
|
||||
|
|
|
|||
|
|
@ -4,17 +4,43 @@ import factory
|
|||
import wagtail_factories
|
||||
from django.contrib.auth import get_user_model
|
||||
from factory import CREATE_STRATEGY
|
||||
from wagtail.core import blocks
|
||||
from wagtail.core.models import Page, Site
|
||||
from wagtail.core.rich_text import RichText
|
||||
from wagtail import blocks
|
||||
from wagtail.models import Page, Site
|
||||
from wagtail.rich_text import RichText
|
||||
|
||||
from assignments.models import Assignment
|
||||
from basicknowledge.models import BasicKnowledge, INTERDISCIPLINARY, INTERDISCIPLINARY_LABEL, InstrumentCategory, \
|
||||
InstrumentType, \
|
||||
LANGUAGE_COMMUNICATION, LANGUAGE_COMMUNICATION_LABEL, SOCIETY, SOCIETY_LABEL
|
||||
from books.blocks import AssignmentBlock, BasicKnowledgeBlock, ImageUrlBlock, LinkBlock, VideoBlock
|
||||
from basicknowledge.models import (
|
||||
BasicKnowledge,
|
||||
INTERDISCIPLINARY,
|
||||
INTERDISCIPLINARY_LABEL,
|
||||
InstrumentCategory,
|
||||
InstrumentType,
|
||||
LANGUAGE_COMMUNICATION,
|
||||
LANGUAGE_COMMUNICATION_LABEL,
|
||||
SOCIETY,
|
||||
SOCIETY_LABEL,
|
||||
)
|
||||
from books.blocks import (
|
||||
AssignmentBlock,
|
||||
BasicKnowledgeBlock,
|
||||
ImageUrlBlock,
|
||||
LinkBlock,
|
||||
SurveyBlock,
|
||||
VideoBlock,
|
||||
)
|
||||
from books.models import Book, Chapter, ContentBlock, Module, TextBlock, Topic
|
||||
from core.factories import BasePageFactory, DummyImageFactory, fake, fake_paragraph, fake_title
|
||||
from core.factories import (
|
||||
BasePageFactory,
|
||||
DummyImageFactory,
|
||||
fake,
|
||||
fake_paragraph,
|
||||
fake_title,
|
||||
)
|
||||
from core.logger import get_logger
|
||||
from surveys.factories import SurveyFactory
|
||||
from surveys.models import Survey
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class BookFactory(BasePageFactory):
|
||||
|
|
@ -24,18 +50,25 @@ class BookFactory(BasePageFactory):
|
|||
@staticmethod
|
||||
def create_default_structure():
|
||||
site = wagtail_factories.SiteFactory.create(is_default_site=True)
|
||||
Page.objects.get(title='Root').delete()
|
||||
Page.objects.get(title="Root").delete()
|
||||
|
||||
book = BookFactory.create(parent=site.root_page, title='A book')
|
||||
topic = TopicFactory.create(parent=book, order=1, title='A topic')
|
||||
module = ModuleFactory.create(parent=topic,
|
||||
title="A module",
|
||||
meta_title="Modul 1",
|
||||
teaser="Whatever",
|
||||
intro="<p>Hello</p>")
|
||||
book = BookFactory.create(parent=site.root_page, title="A book")
|
||||
topic = TopicFactory.create(parent=book, order=1, title="A topic")
|
||||
module = ModuleFactory.create(
|
||||
parent=topic,
|
||||
title="A module",
|
||||
meta_title="Modul 1",
|
||||
teaser="Whatever",
|
||||
intro="<p>Hello</p>",
|
||||
)
|
||||
chapter = ChapterFactory.create(parent=module, title="A chapter")
|
||||
content_block = ContentBlockFactory.create(parent=chapter, module=module, title="A content block", type="task",
|
||||
contents=[])
|
||||
content_block = ContentBlockFactory.create(
|
||||
parent=chapter,
|
||||
module=module,
|
||||
title="A content block",
|
||||
type="task",
|
||||
contents=[],
|
||||
)
|
||||
|
||||
return book, topic, module, chapter, content_block
|
||||
|
||||
|
|
@ -45,7 +78,9 @@ class TopicFactory(BasePageFactory):
|
|||
model = Topic
|
||||
|
||||
order = 0
|
||||
teaser = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(8, 12)))
|
||||
teaser = factory.LazyAttribute(
|
||||
lambda x: fake.sentence(nb_words=random.randint(8, 12))
|
||||
)
|
||||
description = factory.LazyAttribute(lambda x: fake.text(max_nb_chars=200))
|
||||
|
||||
|
||||
|
|
@ -54,7 +89,9 @@ class ModuleFactory(BasePageFactory):
|
|||
model = Module
|
||||
|
||||
meta_title = factory.LazyAttribute(lambda x: fake.text(max_nb_chars=20))
|
||||
teaser = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(8, 12)))
|
||||
teaser = factory.LazyAttribute(
|
||||
lambda x: fake.sentence(nb_words=random.randint(8, 12))
|
||||
)
|
||||
intro = factory.LazyAttribute(lambda x: fake.text(max_nb_chars=200))
|
||||
|
||||
hero_image = factory.SubFactory(DummyImageFactory)
|
||||
|
|
@ -75,11 +112,14 @@ class TextBlockFactory(wagtail_factories.StructBlockFactory):
|
|||
class InstrumentCategoryFactory(factory.DjangoModelFactory):
|
||||
class Meta:
|
||||
model = InstrumentCategory
|
||||
django_get_or_create = ('name',)
|
||||
django_get_or_create = ("name",)
|
||||
|
||||
name = factory.Iterator(
|
||||
[LANGUAGE_COMMUNICATION_LABEL, SOCIETY_LABEL, INTERDISCIPLINARY_LABEL]
|
||||
)
|
||||
foreground = factory.Iterator(["FF0000", "FFFFFF", "000000"])
|
||||
background = factory.Iterator(["FF0000", "FFFFFF", "000000"])
|
||||
|
||||
name = factory.Iterator([LANGUAGE_COMMUNICATION_LABEL, SOCIETY_LABEL, INTERDISCIPLINARY_LABEL])
|
||||
foreground = factory.Iterator(['FF0000', 'FFFFFF', '000000'])
|
||||
background = factory.Iterator(['FF0000', 'FFFFFF', '000000'])
|
||||
|
||||
class InstrumentTypeFactory(factory.DjangoModelFactory):
|
||||
class Meta:
|
||||
|
|
@ -99,7 +139,7 @@ class InstrumentFactory(BasePageFactory):
|
|||
|
||||
@classmethod
|
||||
def _create(cls, model_class, *args, **kwargs):
|
||||
kwargs['parent'] = Site.objects.get(is_default_site=True).root_page
|
||||
kwargs["parent"] = Site.objects.get(is_default_site=True).root_page
|
||||
return super()._create(model_class, *args, **kwargs)
|
||||
|
||||
|
||||
|
|
@ -113,7 +153,7 @@ class BasicKnowledgeBlockFactory(wagtail_factories.StructBlockFactory):
|
|||
|
||||
class ImageUrlBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
title = fake_title()
|
||||
url = factory.LazyAttribute(lambda x: 'https://picsum.photos/600/400/?random')
|
||||
url = factory.LazyAttribute(lambda x: "https://picsum.photos/600/400/?random")
|
||||
|
||||
class Meta:
|
||||
model = ImageUrlBlock
|
||||
|
|
@ -121,127 +161,202 @@ class ImageUrlBlockFactory(wagtail_factories.StructBlockFactory):
|
|||
|
||||
class LinkBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
text = fake_title()
|
||||
url = factory.LazyAttribute(lambda x: 'https://picsum.photos/600/400/?random')
|
||||
url = factory.LazyAttribute(lambda x: "https://picsum.photos/600/400/?random")
|
||||
|
||||
class Meta:
|
||||
model = LinkBlock
|
||||
|
||||
|
||||
class AssignmentBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
class Meta:
|
||||
model = AssignmentBlock
|
||||
|
||||
class EntityBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
@classmethod
|
||||
def _build(cls, model_class, *args, **kwargs):
|
||||
block = model_class()
|
||||
return blocks.StructValue(
|
||||
block,
|
||||
# todo: build in a more generic fashion
|
||||
[
|
||||
(name, kwargs['assignment']) for name, child_block in block.child_blocks.items()
|
||||
],
|
||||
)
|
||||
logger.debug(cls.id_key)
|
||||
logger.debug(cls.entity_key)
|
||||
logger.debug(kwargs)
|
||||
value = block.to_python({cls.id_key: kwargs.get(cls.entity_key).id})
|
||||
clean_value = block.clean(value)
|
||||
return clean_value
|
||||
|
||||
|
||||
class AssignmentBlockFactory(EntityBlockFactory):
|
||||
class Meta:
|
||||
model = AssignmentBlock
|
||||
|
||||
id_key = "assignment_id"
|
||||
entity_key = "assignment"
|
||||
|
||||
|
||||
class SurveyBlockFactory(EntityBlockFactory):
|
||||
class Meta:
|
||||
model = SurveyBlock
|
||||
|
||||
id_key = "survey_id"
|
||||
entity_key = "survey"
|
||||
|
||||
|
||||
class VideoBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
url = factory.LazyAttribute(lambda x: 'https://www.youtube.com/watch?v=lO9d-AJai8Q')
|
||||
url = factory.LazyAttribute(lambda x: "https://www.youtube.com/watch?v=lO9d-AJai8Q")
|
||||
|
||||
class Meta:
|
||||
model = VideoBlock
|
||||
|
||||
|
||||
block_types = ['text_block', 'basic_knowledge', 'student_entry', 'image_url_block', 'solution']
|
||||
block_types = [
|
||||
"text_block",
|
||||
"basic_knowledge",
|
||||
"student_entry",
|
||||
"image_url_block",
|
||||
"solution",
|
||||
]
|
||||
|
||||
|
||||
class ContentBlockFactory(BasePageFactory):
|
||||
class Meta:
|
||||
model = ContentBlock
|
||||
|
||||
type = factory.LazyAttribute(lambda x: random.choice(['normal', 'instrument', 'task',]))
|
||||
type = factory.LazyAttribute(
|
||||
lambda x: random.choice(
|
||||
[
|
||||
"normal",
|
||||
"instrument",
|
||||
"task",
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
contents = wagtail_factories.StreamFieldFactory({
|
||||
'text_block': TextBlockFactory,
|
||||
'basic_knowledge': BasicKnowledgeBlockFactory,
|
||||
'assignment': AssignmentBlockFactory,
|
||||
'image_block': wagtail_factories.ImageChooserBlockFactory,
|
||||
'image_url_block': ImageUrlBlockFactory,
|
||||
'link_block': LinkBlockFactory,
|
||||
'video_block': VideoBlockFactory,
|
||||
'solution': TextBlockFactory
|
||||
})
|
||||
contents = wagtail_factories.StreamFieldFactory(
|
||||
{
|
||||
"text_block": TextBlockFactory,
|
||||
"basic_knowledge": BasicKnowledgeBlockFactory,
|
||||
"assignment": AssignmentBlockFactory,
|
||||
"image_block": wagtail_factories.ImageChooserBlockFactory,
|
||||
"image_url_block": ImageUrlBlockFactory,
|
||||
"link_block": LinkBlockFactory,
|
||||
"video_block": VideoBlockFactory,
|
||||
"solution": TextBlockFactory,
|
||||
"survey": SurveyBlockFactory,
|
||||
}
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def stream_field_magic(cls, module, kwargs, stream_field_name):
|
||||
if stream_field_name in kwargs:
|
||||
"""
|
||||
"""
|
||||
stream_field_name is most likely 'contents'
|
||||
this means: if there is a property named contents, use the defined ones in this block.
|
||||
otherwise, go into the other block and randomize the contents
|
||||
"""
|
||||
for idx, resource in enumerate(kwargs[stream_field_name]):
|
||||
value = resource['value']
|
||||
block_type = resource['type']
|
||||
value = resource["value"]
|
||||
block_type = resource["type"]
|
||||
|
||||
if block_type == 'assignment':
|
||||
if block_type == "assignment":
|
||||
user = get_user_model().objects.first()
|
||||
assignment = Assignment.objects.create(
|
||||
title=value['title'],
|
||||
assignment=value['assignment'],
|
||||
title=value["title"],
|
||||
assignment=value["assignment"],
|
||||
owner=user,
|
||||
module=module
|
||||
module=module,
|
||||
)
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, 'assignment')] = assignment
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, "assignment"
|
||||
)
|
||||
] = assignment
|
||||
elif block_type == "survey":
|
||||
survey = Survey.objects.create(
|
||||
title=value["title"], data=value["data"], module=module
|
||||
)
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, "survey"
|
||||
)
|
||||
] = survey
|
||||
else:
|
||||
for jdx, field in enumerate(value):
|
||||
|
||||
if block_type == 'text_block':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = RichText(
|
||||
value[field])
|
||||
elif block_type == 'solution':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = RichText(
|
||||
value[field])
|
||||
elif block_type == 'basic_knowledge':
|
||||
if field == 'description':
|
||||
if block_type == "text_block":
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, field
|
||||
)
|
||||
] = RichText(value[field])
|
||||
elif block_type == "solution":
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, field
|
||||
)
|
||||
] = RichText(value[field])
|
||||
elif block_type == "basic_knowledge":
|
||||
if field == "description":
|
||||
kwargs[
|
||||
'{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = RichText(
|
||||
value[field])
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, field
|
||||
)
|
||||
] = RichText(value[field])
|
||||
else:
|
||||
kwargs[
|
||||
'{}__{}__{}__{}'.format(stream_field_name, idx, block_type,
|
||||
field)] = 'https://google.ch'
|
||||
elif block_type == 'image_url_block':
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, field
|
||||
)
|
||||
] = "https://google.ch"
|
||||
elif block_type == "image_url_block":
|
||||
kwargs[
|
||||
'{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = value[field]
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, field
|
||||
)
|
||||
] = value[field]
|
||||
|
||||
else:
|
||||
kwargs[
|
||||
'{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = value[field]
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, field
|
||||
)
|
||||
] = value[field]
|
||||
|
||||
del kwargs[stream_field_name]
|
||||
else: # random contents from generator
|
||||
for i in range(0, random.randint(3, 7)):
|
||||
block_type = random.choice(block_types)
|
||||
if block_type == 'text_block':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'text_block', 'text')] = RichText(
|
||||
fake_paragraph())
|
||||
elif block_type == 'basic_knowledge':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'basic_knowledge', 'description')] = RichText(
|
||||
fake_paragraph())
|
||||
elif block_type == 'assignment':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'assignment', 'task_text')] = RichText(
|
||||
fake_paragraph())
|
||||
elif block_type == 'image_url_block':
|
||||
if block_type == "text_block":
|
||||
kwargs[
|
||||
'{}__{}__{}__{}'.format(stream_field_name, i, 'image_url_block', 'title')] = fake_paragraph()
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, i, "text_block", "text"
|
||||
)
|
||||
] = RichText(fake_paragraph())
|
||||
elif block_type == "basic_knowledge":
|
||||
kwargs[
|
||||
'{}__{}__{}__{}'.format(stream_field_name, i, 'image_url_block',
|
||||
'url')] = 'https://picsum.photos/400/?random={}'.format(
|
||||
''.join(random.choice('abcdefghiklmn') for _ in range(6)))
|
||||
elif block_type == 'solution':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'solution', 'text')] = RichText(
|
||||
fake_paragraph())
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, i, "basic_knowledge", "description"
|
||||
)
|
||||
] = RichText(fake_paragraph())
|
||||
elif block_type == "assignment":
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, i, "assignment", "task_text"
|
||||
)
|
||||
] = RichText(fake_paragraph())
|
||||
elif block_type == "image_url_block":
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, i, "image_url_block", "title"
|
||||
)
|
||||
] = fake_paragraph()
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, i, "image_url_block", "url"
|
||||
)
|
||||
] = "https://picsum.photos/400/?random={}".format(
|
||||
"".join(random.choice("abcdefghiklmn") for _ in range(6))
|
||||
)
|
||||
elif block_type == "solution":
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, i, "solution", "text"
|
||||
)
|
||||
] = RichText(fake_paragraph())
|
||||
|
||||
@classmethod
|
||||
def create(cls, module, **kwargs):
|
||||
cls.stream_field_magic(module, kwargs, 'contents')
|
||||
cls.stream_field_magic(module, kwargs, "contents")
|
||||
return cls._generate(CREATE_STRATEGY, kwargs)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from wagtail.core.models import PageManager
|
||||
from wagtail.models import PageManager
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from core.logger import get_logger
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ class Migration(migrations.Migration):
|
|||
fields=[
|
||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||
('user_created', models.BooleanField(default=False)),
|
||||
('contents', wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.core.blocks.IntegerBlock())])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('task', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True)),
|
||||
('contents', wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock()), ('url', wagtail.blocks.URLBlock())])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.blocks.IntegerBlock())])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('task', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True)),
|
||||
('type', models.CharField(choices=[('plain', 'Normal'), ('yellow', 'Gelb'), ('green', 'Grün'), ('blue', 'Blau')], default='plain', max_length=100)),
|
||||
],
|
||||
options={
|
||||
|
|
@ -61,7 +61,7 @@ class Migration(migrations.Migration):
|
|||
('order', models.PositiveIntegerField(help_text='Order of the module')),
|
||||
('meta_title', models.CharField(help_text="e.g. 'Intro' or 'Modul 1'", max_length=255)),
|
||||
('teaser', models.TextField()),
|
||||
('intro', wagtail.core.fields.RichTextField()),
|
||||
('intro', wagtail.fields.RichTextField()),
|
||||
('hero_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
|
||||
],
|
||||
options={
|
||||
|
|
@ -76,7 +76,7 @@ class Migration(migrations.Migration):
|
|||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||
('order', models.PositiveIntegerField(help_text='Order of the topic')),
|
||||
('teaser', models.TextField()),
|
||||
('description', wagtail.core.fields.RichTextField()),
|
||||
('description', wagtail.fields.RichTextField()),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Thema',
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-25 11:55
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
|
||||
|
||||
|
|
@ -16,6 +16,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock()), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.core.blocks.IntegerBlock())])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('task', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock()), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.blocks.IntegerBlock())])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('task', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
import assignments.models
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -18,6 +18,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock()), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('task', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock()), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('task', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import assignments.models
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -25,6 +25,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock()), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock()), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
import assignments.models
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -18,6 +18,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock()), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock()), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
import assignments.models
|
||||
from django.db import migrations, models
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())]))], blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
import assignments.models
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -18,6 +18,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('content_list_item', wagtail.core.blocks.StreamBlock([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('content_list_item', wagtail.blocks.StreamBlock([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import assignments.models
|
||||
from django.db import migrations
|
||||
import surveys.models
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -19,6 +19,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())])), ('content_list_item', wagtail.core.blocks.StreamBlock([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('content_list_item', wagtail.blocks.StreamBlock([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import assignments.models
|
||||
from django.db import migrations
|
||||
import surveys.models
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -19,6 +19,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())])), ('content_list_item', wagtail.core.blocks.StreamBlock([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('content_list_item', wagtail.blocks.StreamBlock([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import assignments.models
|
||||
from django.db import migrations
|
||||
import surveys.models
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -19,6 +19,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('instruction', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())])), ('content_list_item', wagtail.core.blocks.StreamBlock([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('instruction', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock()), ('text', wagtail.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('content_list_item', wagtail.blocks.StreamBlock([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(required=True, target_model=['basicknowledge.BasicKnowledge']))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock()), ('text', wagtail.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import assignments.models
|
||||
from django.db import migrations
|
||||
import surveys.models
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
|
@ -19,6 +19,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('instruction', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())])), ('content_list_item', wagtail.core.blocks.StreamBlock([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('instruction', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock()), ('text', wagtail.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('content_list_item', wagtail.blocks.StreamBlock([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock()), ('text', wagtail.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())]))]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ from django.db import migrations, models
|
|||
import django.db.models.deletion
|
||||
import surveys.models
|
||||
import taggit.managers
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.core.models.collections
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.models.collections
|
||||
import wagtail.documents.blocks
|
||||
import wagtail.images.blocks
|
||||
import wagtail.search.index
|
||||
|
|
@ -28,7 +28,7 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('instruction', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())])), ('cms_document_block', wagtail.documents.blocks.DocumentChooserBlock()), ('content_list_item', wagtail.core.blocks.StreamBlock([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('instruction', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())])), ('cms_document_block', wagtail.documents.blocks.DocumentChooserBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock()), ('text', wagtail.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('cms_document_block', wagtail.documents.blocks.DocumentChooserBlock()), ('content_list_item', wagtail.blocks.StreamBlock([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))], icon='tick')), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock()), ('text', wagtail.blocks.TextBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('cms_document_block', wagtail.documents.blocks.DocumentChooserBlock())]))], blank=True, null=True),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CustomDocument',
|
||||
|
|
@ -40,7 +40,7 @@ class Migration(migrations.Migration):
|
|||
('file_size', models.PositiveIntegerField(editable=False, null=True)),
|
||||
('file_hash', models.CharField(blank=True, editable=False, max_length=40)),
|
||||
('display_text', models.CharField(default='', max_length=1024)),
|
||||
('collection', models.ForeignKey(default=wagtail.core.models.collections.get_root_collection_id, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailcore.collection', verbose_name='collection')),
|
||||
('collection', models.ForeignKey(default=wagtail.models.collections.get_root_collection_id, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailcore.collection', verbose_name='collection')),
|
||||
('tags', taggit.managers.TaggableManager(blank=True, help_text=None, through='taggit.TaggedItem', to='taggit.Tag', verbose_name='tags')),
|
||||
('uploaded_by_user', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='uploaded by user')),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import assignments.models
|
|||
import books.blocks
|
||||
from django.db import migrations
|
||||
import surveys.models
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.documents.blocks
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
|
@ -21,6 +21,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold'])), ('document', books.blocks.CMSDocumentBlock(required=False))])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('instruction', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock(required=False)), ('text', wagtail.core.blocks.TextBlock(required=False)), ('document', wagtail.documents.blocks.DocumentChooserBlock(required=False))])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock()), ('content_list_item', wagtail.core.blocks.StreamBlock([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.core.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.core.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('solution', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold'])), ('document', books.blocks.CMSDocumentBlock(required=False))])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('infogram_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock()), ('title', wagtail.core.blocks.TextBlock())])), ('genially_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('thinglink_block', wagtail.core.blocks.StructBlock([('id', wagtail.core.blocks.TextBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('instruction', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock(required=False)), ('text', wagtail.core.blocks.TextBlock(required=False)), ('document', wagtail.documents.blocks.DocumentChooserBlock(required=False))])), ('module_room_slug', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold'])), ('document', books.blocks.CMSDocumentBlock(required=False))])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock(required=False)), ('text', wagtail.blocks.TextBlock(required=False)), ('document', wagtail.documents.blocks.DocumentChooserBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock()), ('content_list_item', wagtail.blocks.StreamBlock([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold'])), ('document', books.blocks.CMSDocumentBlock(required=False))])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock(required=False)), ('text', wagtail.blocks.TextBlock(required=False)), ('document', wagtail.documents.blocks.DocumentChooserBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 3.2.16 on 2023-02-21 16:04
|
||||
|
||||
import assignments.models
|
||||
import books.blocks
|
||||
from django.db import migrations
|
||||
import surveys.models
|
||||
import wagtail.blocks
|
||||
import wagtail.documents.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
import wagtail.snippets.blocks
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('books', '0040_module_hero_source'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='contents',
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold'])), ('document', books.blocks.CMSDocumentBlock(required=False))])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock(required=False)), ('text', wagtail.blocks.TextBlock(required=False)), ('document', wagtail.documents.blocks.DocumentChooserBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock()), ('content_list_item', wagtail.blocks.StreamBlock([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('basic_knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(required=False)), ('basic_knowledge', wagtail.blocks.PageChooserBlock(page_type=['basicknowledge.BasicKnowledge'], required=True))])), ('assignment', wagtail.blocks.StructBlock([('assignment_id', wagtail.snippets.blocks.SnippetChooserBlock(assignments.models.Assignment))])), ('survey', wagtail.blocks.StructBlock([('survey_id', wagtail.snippets.blocks.SnippetChooserBlock(surveys.models.Survey))])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('solution', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold'])), ('document', books.blocks.CMSDocumentBlock(required=False))])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('infogram_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock()), ('title', wagtail.blocks.TextBlock())])), ('genially_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('thinglink_block', wagtail.blocks.StructBlock([('id', wagtail.blocks.TextBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('instruction', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock(required=False)), ('text', wagtail.blocks.TextBlock(required=False)), ('document', wagtail.documents.blocks.DocumentChooserBlock(required=False))])), ('module_room_slug', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock())])), ('cms_document_block', books.blocks.CMSDocumentBlock())]))], blank=True, null=True, use_json_field=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
|
||||
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList
|
||||
from wagtail.admin.panels import FieldPanel, TabbedInterface, ObjectList
|
||||
|
||||
from core.wagtail_utils import StrictHierarchyPage, get_default_settings
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
|
||||
from django.db import models
|
||||
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList
|
||||
from wagtail.admin.panels import FieldPanel, TabbedInterface, ObjectList
|
||||
|
||||
from core.wagtail_utils import StrictHierarchyPage, get_default_settings
|
||||
from users.models import SchoolClass
|
||||
|
|
@ -53,8 +53,7 @@ class Chapter(StrictHierarchyPage, GraphqlNodeMixin):
|
|||
|
||||
def sync_description_visibility(self, school_class_template, school_class_to_sync):
|
||||
if (
|
||||
self.description_hidden_for.filter(
|
||||
id=school_class_template.id).exists()
|
||||
self.description_hidden_for.filter(id=school_class_template.id).exists()
|
||||
and not self.description_hidden_for.filter(
|
||||
id=school_class_to_sync.id
|
||||
).exists()
|
||||
|
|
@ -62,8 +61,7 @@ class Chapter(StrictHierarchyPage, GraphqlNodeMixin):
|
|||
self.description_hidden_for.add(school_class_to_sync)
|
||||
|
||||
if (
|
||||
self.description_hidden_for.filter(
|
||||
id=school_class_to_sync.id).exists()
|
||||
self.description_hidden_for.filter(id=school_class_to_sync.id).exists()
|
||||
and not self.description_hidden_for.filter(
|
||||
id=school_class_template.id
|
||||
).exists()
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
import logging
|
||||
|
||||
from django.db import models
|
||||
from wagtail.admin.edit_handlers import (
|
||||
from wagtail.admin.panels import (
|
||||
FieldPanel,
|
||||
TabbedInterface,
|
||||
ObjectList,
|
||||
StreamFieldPanel,
|
||||
)
|
||||
from wagtail.core.blocks import StreamBlock
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.blocks import StreamBlock
|
||||
from wagtail.fields import StreamField
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
from books.managers import ContentBlockManager
|
||||
from core.logger import get_logger
|
||||
from core.wagtail_utils import get_default_settings
|
||||
from books.blocks import (
|
||||
CMSDocumentBlock,
|
||||
|
|
@ -31,14 +29,50 @@ from books.blocks import (
|
|||
ThinglinkBlock,
|
||||
InstructionBlock,
|
||||
)
|
||||
from books.utils import get_type_and_value
|
||||
from core.wagtail_utils import StrictHierarchyPage
|
||||
from notes.models import ContentBlockBookmark
|
||||
from surveys.models import Survey
|
||||
from users.models import SchoolClass, User
|
||||
from core.mixins import GraphqlNodeMixin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def duplicate_entities_generator(new_module):
|
||||
def duplicate_entities(block):
|
||||
content_type = block.block_type
|
||||
value = block.value
|
||||
# logger.debug(block)
|
||||
if content_type == "assignment":
|
||||
assignment = value.get("assignment_id")
|
||||
if assignment is None:
|
||||
return None
|
||||
# copy the assignment
|
||||
assignment.pk = None
|
||||
assignment.title = f"{assignment.title} (Kopie)"
|
||||
assignment.module = new_module
|
||||
# logger.debug(f"setting new module {new_module}, {assignment.module}")
|
||||
assignment.save()
|
||||
data = {"assignment_id": assignment}
|
||||
new_block = ("assignment", data)
|
||||
return new_block
|
||||
if content_type == "survey":
|
||||
# logger.debug(value)
|
||||
survey = value.get("survey_id")
|
||||
if survey is None:
|
||||
return None
|
||||
# copy the survey
|
||||
survey.pk = None
|
||||
survey.title = f"{survey.title} (Kopie)"
|
||||
survey.module = new_module
|
||||
# logger.debug(f"setting new module {new_module}, {survey.module}")
|
||||
survey.save()
|
||||
data = {"survey_id": survey}
|
||||
new_block = ("survey", data)
|
||||
# logger.debug(new_block)
|
||||
return new_block
|
||||
return block
|
||||
|
||||
return duplicate_entities
|
||||
|
||||
|
||||
class ContentBlock(StrictHierarchyPage, GraphqlNodeMixin):
|
||||
|
|
@ -100,15 +134,15 @@ class ContentBlock(StrictHierarchyPage, GraphqlNodeMixin):
|
|||
content_blocks + [("content_list_item", content_list_item)],
|
||||
null=True,
|
||||
blank=True,
|
||||
use_json_field=True,
|
||||
)
|
||||
|
||||
type = models.CharField(
|
||||
max_length=100, choices=TYPE_CHOICES, default=NORMAL)
|
||||
type = models.CharField(max_length=100, choices=TYPE_CHOICES, default=NORMAL)
|
||||
|
||||
content_panels = [
|
||||
FieldPanel("title", classname="full title"),
|
||||
FieldPanel("type"),
|
||||
StreamFieldPanel("contents"),
|
||||
FieldPanel("contents"),
|
||||
]
|
||||
|
||||
#
|
||||
|
|
@ -127,6 +161,23 @@ class ContentBlock(StrictHierarchyPage, GraphqlNodeMixin):
|
|||
def module(self):
|
||||
return self.get_parent().get_parent().specific
|
||||
|
||||
# duplicate all attached Surveys and Assignments
|
||||
def duplicate_attached_entities(self):
|
||||
duplicate_entities_func = duplicate_entities_generator(self.module)
|
||||
new_contents = [duplicate_entities_func(content) for content in self.contents]
|
||||
cleaned_contents = [item for item in new_contents if item is not None]
|
||||
# we can't just insert a list here, we need a StreamValue data type
|
||||
# so we need to clear the list, then add each element in turn
|
||||
self.contents.clear()
|
||||
# like this, the internal methods of the SteamValue data type can work on the single elements
|
||||
for content in cleaned_contents:
|
||||
self.contents.append(content)
|
||||
|
||||
# as an illustration
|
||||
# data = {'text': 'This is me'}
|
||||
# self.contents.append(('solution', data))
|
||||
self.save()
|
||||
|
||||
def is_hidden_for_class(self, school_class):
|
||||
return (
|
||||
not self.user_created
|
||||
|
|
@ -136,19 +187,38 @@ class ContentBlock(StrictHierarchyPage, GraphqlNodeMixin):
|
|||
and not self.visible_for.filter(id=school_class.id).exists()
|
||||
)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
for data in self.contents.raw_data:
|
||||
block_type, value = get_type_and_value(data)
|
||||
|
||||
if block_type == "survey":
|
||||
module = self.module
|
||||
survey = value["survey_id"]
|
||||
if isinstance(survey, int):
|
||||
survey = Survey.objects.get(pk=survey)
|
||||
def reassign_entities(self):
|
||||
module = self.module
|
||||
logger.debug("reassigning entities")
|
||||
for content in self.contents:
|
||||
if content.block_type == "assignment":
|
||||
assignment = content.value.get("assignment_id")
|
||||
logger.debug(assignment.module)
|
||||
if assignment.module != module:
|
||||
assignment.module = module
|
||||
assignment.save()
|
||||
if content.block_type == "survey":
|
||||
survey = content.value.get("survey_id")
|
||||
logger.debug(survey.module)
|
||||
if survey.module != module:
|
||||
survey.module = module
|
||||
survey.save()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
# def save(self, *args, **kwargs):
|
||||
# todo: move this to the after_create_page and after_edit_page hooks, and remove from here.
|
||||
# for data in self.contents.raw_data:
|
||||
# block_type, value = get_type_and_value(data)
|
||||
|
||||
# todo: also do the same for assignments
|
||||
# if block_type == "survey":
|
||||
# module = self.module
|
||||
# survey = value["survey_id"]
|
||||
# if isinstance(survey, int):
|
||||
# survey = Survey.objects.get(pk=survey)
|
||||
# if survey.module != module:
|
||||
# survey.module = module
|
||||
# survey.save()
|
||||
# super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class ContentBlockSnapshot(ContentBlock):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList
|
||||
from wagtail.core.fields import RichTextField
|
||||
from wagtail.images.edit_handlers import ImageChooserPanel
|
||||
from wagtail.admin.panels import FieldPanel, TabbedInterface, ObjectList
|
||||
from wagtail.fields import RichTextField
|
||||
|
||||
from core.constants import DEFAULT_RICH_TEXT_FEATURES
|
||||
from core.wagtail_utils import StrictHierarchyPage, get_default_settings
|
||||
|
|
@ -35,7 +34,7 @@ class Module(StrictHierarchyPage):
|
|||
content_panels = [
|
||||
FieldPanel("title", classname="full title"),
|
||||
FieldPanel("meta_title", classname="full title"),
|
||||
ImageChooserPanel("hero_image"),
|
||||
FieldPanel("hero_image"),
|
||||
FieldPanel("hero_source"),
|
||||
FieldPanel("teaser"),
|
||||
FieldPanel("intro"),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import logging
|
||||
|
||||
from django.db import models
|
||||
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList
|
||||
from wagtail.core.fields import RichTextField
|
||||
from wagtail.admin.panels import FieldPanel, TabbedInterface, ObjectList
|
||||
from wagtail.fields import RichTextField
|
||||
|
||||
from core.constants import DEFAULT_RICH_TEXT_FEATURES
|
||||
from core.wagtail_utils import StrictHierarchyPage, get_default_settings
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import re
|
|||
|
||||
from typing import List, Union
|
||||
|
||||
from wagtail.core.blocks import StreamValue
|
||||
from wagtail.blocks import StreamValue
|
||||
|
||||
from api.utils import get_object
|
||||
from assignments.models import Assignment
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from graphql_relay import to_global_id
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.tests.utils.form_data import streamfield, nested_form_data, rich_text
|
||||
from wagtail.fields import StreamField
|
||||
from wagtail.test.utils.form_data import streamfield, nested_form_data, rich_text
|
||||
|
||||
from books.factories import ContentBlockFactory, ModuleFactory, ChapterFactory
|
||||
from books.models import ContentBlock
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
from django.test import TestCase
|
||||
from assignments.models import Assignment
|
||||
|
||||
from books.factories import BookFactory, ContentBlockFactory
|
||||
from books.models.contentblock import ContentBlock
|
||||
from core.logger import get_logger
|
||||
from surveys.models import Survey
|
||||
from users.services import create_users
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class DuplicateContentsTestCase(TestCase):
|
||||
def setUp(self) -> None:
|
||||
create_users()
|
||||
_, _, self.module, chapter, _ = BookFactory.create_default_structure()
|
||||
text = {"type": "text_block", "value": {"text": "Hallo"}}
|
||||
assignment = {
|
||||
"type": "assignment",
|
||||
"value": {"title": "Hello", "assignment": "Assignment"},
|
||||
}
|
||||
survey = {"type": "survey", "value": {"title": "Survey Title", "data": "null"}}
|
||||
self.content_block = ContentBlockFactory.create(
|
||||
parent=chapter,
|
||||
module=self.module,
|
||||
title="Another content block",
|
||||
type="task",
|
||||
contents=[text, assignment, survey],
|
||||
)
|
||||
self.assignment = Assignment.objects.first()
|
||||
|
||||
def test_duplicate_entities(self):
|
||||
self.assertEqual(
|
||||
self.content_block.contents[1].value["assignment_id"], self.assignment
|
||||
)
|
||||
self.assertEqual(
|
||||
self.content_block.contents[1].value["assignment_id"].title, "Hello"
|
||||
)
|
||||
self.assertEqual(Assignment.objects.count(), 1)
|
||||
self.assertEqual(Survey.objects.count(), 1)
|
||||
self.content_block.duplicate_attached_entities()
|
||||
self.assertEqual(Assignment.objects.count(), 2)
|
||||
self.assertEqual(Survey.objects.count(), 2)
|
||||
new_assignment = Assignment.objects.latest("id")
|
||||
new_survey = Survey.objects.latest("id")
|
||||
content_block = ContentBlock.objects.get(id=self.content_block.id)
|
||||
self.assertEqual(len(content_block.contents), 3)
|
||||
self.assertEqual(
|
||||
content_block.contents[1].value["assignment_id"], new_assignment
|
||||
)
|
||||
self.assertEqual(content_block.contents[2].value["survey_id"], new_survey)
|
||||
|
|
@ -8,7 +8,7 @@ from django.conf import settings
|
|||
from django.core import management
|
||||
from django.core.management import BaseCommand
|
||||
from django.db import connection
|
||||
from wagtail.core.models import Page
|
||||
from wagtail.models import Page
|
||||
|
||||
from books.factories import BookFactory, TopicFactory, ModuleFactory, ChapterFactory, ContentBlockFactory
|
||||
from core.factories import UserFactory
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
# Generated by Django 3.2.16 on 2023-03-09 17:14
|
||||
|
||||
from django.contrib.auth.models import Group, Permission
|
||||
from django.db import migrations
|
||||
|
||||
"""
|
||||
CMS-Editors:
|
||||
Wagtail: Alle Rechte
|
||||
Django: Bereich «Lernziele»
|
||||
|
||||
Support:
|
||||
Django: Bereich «User»
|
||||
|
||||
News:
|
||||
Django: Bereich «News»
|
||||
|
||||
"""
|
||||
|
||||
news = ["news"]
|
||||
support = ["users", "auth"]
|
||||
cms_editors = [
|
||||
"objectives",
|
||||
"books",
|
||||
"assignments",
|
||||
"basicknowledge",
|
||||
"surveys",
|
||||
"wagtailadmin",
|
||||
"wagtailcore",
|
||||
"wagtailimages",
|
||||
"wagtailembeds",
|
||||
"wagtailredirects",
|
||||
"wagtailsearch",
|
||||
"wagtailusers",
|
||||
"wagtaildocs",
|
||||
]
|
||||
|
||||
groups = [("News", news), ("CMS-Editors", cms_editors), ("Support", support)]
|
||||
|
||||
|
||||
def add_permissions(apps, schema_editor):
|
||||
for name, app_labels in groups:
|
||||
group, _ = Group.objects.get_or_create(name=name)
|
||||
for app_label in app_labels:
|
||||
for permission in Permission.objects.filter(
|
||||
content_type__app_label=app_label
|
||||
):
|
||||
group.permissions.add(permission)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("core", "0002_delete_admindata"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(add_permissions, migrations.RunPython.noop),
|
||||
]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 3.2.16 on 2023-03-13 15:19
|
||||
|
||||
from django.db import migrations
|
||||
from django.contrib.auth.models import Group
|
||||
|
||||
|
||||
def delete_old_group(apps, schema_editor):
|
||||
try:
|
||||
group = Group.objects.get(name="Altes CMS")
|
||||
group.delete()
|
||||
except Group.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("core", "0003_auto_20230309_1714"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(delete_old_group, migrations.RunPython.noop),
|
||||
]
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
# Generated by Django 3.2.16 on 2023-03-16 10:28
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
from core.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def add_group_page_permissions(apps, schema_editor):
|
||||
try:
|
||||
types = ["lock", "bulk_delete", "edit", "publish", "unlock", "add"]
|
||||
Group = apps.get_model("auth", "Group")
|
||||
Site = apps.get_model("wagtailcore", "Site")
|
||||
GroupPagePermission = apps.get_model("wagtailcore", "GroupPagePermission")
|
||||
group = Group.objects.get(name="CMS-Editors")
|
||||
site = Site.objects.get(is_default_site=True)
|
||||
page = site.root_page
|
||||
for tp in types:
|
||||
GroupPagePermission.objects.get_or_create(
|
||||
group=group, page=page, permission_type=tp
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("core", "0004_auto_20230313_1519"),
|
||||
("wagtailcore", "0083_workflowcontenttype"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(add_group_page_permissions, migrations.RunPython.noop)
|
||||
]
|
||||
|
|
@ -61,7 +61,7 @@ INSTALLED_APPS = [
|
|||
'wagtail.images',
|
||||
'wagtail.search',
|
||||
'wagtail.admin',
|
||||
'wagtail.core',
|
||||
'wagtail',
|
||||
'wagtail.api.v2',
|
||||
'wagtailautocomplete',
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,264 @@
|
|||
import json
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from wagtail.models import Page
|
||||
from wagtail.test.utils import WagtailTestUtils
|
||||
from assignments.factories import AssignmentFactory
|
||||
from assignments.models import Assignment
|
||||
from books.blocks import AssignmentBlock, SurveyBlock
|
||||
from books.factories import BookFactory, ChapterFactory, ModuleFactory, TopicFactory
|
||||
from books.models.contentblock import ContentBlock
|
||||
from books.models.module import Module
|
||||
from books.models.topic import Topic
|
||||
|
||||
from core.logger import get_logger
|
||||
from surveys.factories import SurveyFactory
|
||||
from surveys.models import Survey
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def get_copy_payload(title, slug, parent):
|
||||
return {
|
||||
"new_title": title,
|
||||
"new_slug": slug,
|
||||
"new_parent_page": parent.id,
|
||||
"copy_subpages": True,
|
||||
"publish_copies": False,
|
||||
"alias": False,
|
||||
}
|
||||
|
||||
|
||||
def get_copy_url(page):
|
||||
return reverse("wagtailadmin_pages:copy", args=(page.id,))
|
||||
|
||||
|
||||
class CoreHooksTestCase(WagtailTestUtils, TestCase):
|
||||
def setUp(self) -> None:
|
||||
(
|
||||
self.book,
|
||||
self.topic,
|
||||
self.module,
|
||||
self.chapter,
|
||||
self.content_block,
|
||||
) = BookFactory.create_default_structure()
|
||||
self.user = self.login()
|
||||
|
||||
# create content blocks
|
||||
assignment = AssignmentFactory()
|
||||
self.assignment_id = assignment.id
|
||||
assignment_block = AssignmentBlock()
|
||||
assignment_value = assignment_block.to_python({"assignment_id": assignment.id})
|
||||
cleaned_assignment_value = assignment_block.clean(assignment_value)
|
||||
assignment_content = ("assignment", cleaned_assignment_value)
|
||||
|
||||
survey = SurveyFactory()
|
||||
survey_block = SurveyBlock()
|
||||
survey_value = survey_block.to_python({"survey_id": survey.id})
|
||||
cleaned_survey_value = survey_block.clean(survey_value)
|
||||
survey_content = ("survey", cleaned_survey_value)
|
||||
|
||||
self.content_block.contents.append(assignment_content)
|
||||
self.content_block.contents.append(survey_content)
|
||||
self.content_block.save()
|
||||
|
||||
self.assertEqual(
|
||||
self.content_block.contents[0].value["assignment_id"], assignment
|
||||
)
|
||||
self.assertEqual(self.content_block.contents[1].value["survey_id"], survey)
|
||||
self.assertEqual(Assignment.objects.count(), 1)
|
||||
self.assertEqual(Survey.objects.count(), 1)
|
||||
# logger.debug(f"assignment: {assignment.id}")
|
||||
|
||||
self.new_topic = TopicFactory.create(
|
||||
parent=self.book, title="A second Topic", order=2
|
||||
)
|
||||
|
||||
self.new_module = ModuleFactory.create(
|
||||
parent=self.new_topic,
|
||||
title="A second module",
|
||||
meta_title="Modul 1",
|
||||
teaser="Whatever",
|
||||
intro="<p>Hello</p>",
|
||||
)
|
||||
self.new_chapter = ChapterFactory.create(
|
||||
parent=self.new_module, title="A second chapter"
|
||||
)
|
||||
|
||||
def test_after_create_hook(self):
|
||||
# description = rich_text('<p>hello</p>')
|
||||
self.assertEqual(Topic.objects.count(), 2)
|
||||
description = {
|
||||
"blocks": [
|
||||
{
|
||||
"key": "thfb4",
|
||||
"text": "asd",
|
||||
"type": "unstyled",
|
||||
"depth": 0,
|
||||
"inlineStyleRanges": [],
|
||||
"entityRanges": [],
|
||||
"data": {},
|
||||
}
|
||||
],
|
||||
"entityMap": {},
|
||||
}
|
||||
post_data = {
|
||||
"title": "New Page",
|
||||
"order": 1,
|
||||
"teaser": "Tease",
|
||||
"description": json.dumps(description),
|
||||
"slug": "hello-world",
|
||||
}
|
||||
url = reverse(
|
||||
"wagtailadmin_pages:add",
|
||||
args=("books", "topic", self.book.id),
|
||||
)
|
||||
# logger.debug(url)
|
||||
self.client.post(
|
||||
url,
|
||||
post_data,
|
||||
)
|
||||
self.assertEqual(Topic.objects.count(), 3)
|
||||
|
||||
def _check_copied_content_block(self, module=None):
|
||||
if module is None:
|
||||
module = self.new_module
|
||||
|
||||
self.assertEqual(ContentBlock.objects.count(), 2)
|
||||
self.assertEqual(Assignment.objects.count(), 2)
|
||||
self.assertEqual(Survey.objects.count(), 2)
|
||||
new_content_block = ContentBlock.objects.latest("-latest_revision_created_at")
|
||||
new_assignment = Assignment.objects.latest("pk")
|
||||
new_survey = Survey.objects.latest("pk")
|
||||
self.assertEqual(
|
||||
new_content_block.contents[0].value["assignment_id"], new_assignment
|
||||
)
|
||||
self.assertEqual(new_assignment.module, module)
|
||||
self.assertEqual(new_content_block.contents[1].value["survey_id"], new_survey)
|
||||
self.assertEqual(new_survey.module, module)
|
||||
|
||||
def test_content_block_after_copy_hook(self):
|
||||
"""
|
||||
should copy the content block, and set all entities' module to the new parent's parent module
|
||||
"""
|
||||
# inspired by wagtail.admin.tests.pages.test_copy_page
|
||||
|
||||
url = get_copy_url(self.content_block)
|
||||
post_data = get_copy_payload(
|
||||
"Neuer Titel (Kopie)", "new-slug", self.new_chapter
|
||||
)
|
||||
self.client.post(url, post_data)
|
||||
self._check_copied_content_block()
|
||||
|
||||
def test_chapter_after_copy_hook(self):
|
||||
"""
|
||||
should copy the chapter, and set all entities' module to the new parent module
|
||||
"""
|
||||
url = get_copy_url(self.chapter)
|
||||
post_data = get_copy_payload("Neuer Titel (Kopie)", "new-slug", self.new_module)
|
||||
self.client.post(url, post_data)
|
||||
self._check_copied_content_block()
|
||||
|
||||
def test_module_after_copy_hook(self):
|
||||
"""
|
||||
should copy the module, and set all entities' module to the newly created module
|
||||
"""
|
||||
url = get_copy_url(self.module)
|
||||
post_data = get_copy_payload("Neuer Titel (Kopie)", "new-slug", self.new_topic)
|
||||
self.client.post(url, post_data)
|
||||
module = Module.objects.latest("-latest_revision_created_at")
|
||||
self._check_copied_content_block(module)
|
||||
|
||||
def test_topic_after_copy_hook(self):
|
||||
"""
|
||||
should copy the whole topic, and set all entities to the newly created child module
|
||||
"""
|
||||
url = get_copy_url(self.topic)
|
||||
post_data = get_copy_payload("Neuer Titel (Kopie)", "new-slug", self.book)
|
||||
self.client.post(url, post_data)
|
||||
topic = Topic.objects.latest("-latest_revision_created_at")
|
||||
module = topic.get_children().first().specific
|
||||
self._check_copied_content_block(module)
|
||||
|
||||
# def test_chapter_after_move_hook(self):
|
||||
# """
|
||||
# should move the chapter, and set all entities' module to the new parent's parent module
|
||||
# """
|
||||
#
|
||||
# assignment = self.content_block.contents[0].value["assignment_id"]
|
||||
# survey = self.content_block.contents[1].value["survey_id"]
|
||||
# self.assertEqual(self.chapter.pk, self.content_block.get_parent().pk)
|
||||
#
|
||||
# logger.debug("content blocks")
|
||||
# logger.debug(self.chapter.get_content_blocks())
|
||||
#
|
||||
# url = reverse(
|
||||
# "wagtailadmin_pages:move_confirm",
|
||||
# args=(self.chapter.id, self.new_module.id),
|
||||
# )
|
||||
# logger.debug(url)
|
||||
# response = self.client.post(url)
|
||||
# logger.debug(response)
|
||||
# chapter = Page.objects.get(id=self.chapter.id)
|
||||
# logger.debug("new content blocks")
|
||||
# logger.debug(chapter.specific.get_content_blocks())
|
||||
# self.assertEqual(chapter.get_parent().id, self.new_module.id)
|
||||
# # reload the assignment from the DB
|
||||
# assignment = Assignment.objects.get(id=assignment.id)
|
||||
# self.assertEqual(assignment.module, self.new_module)
|
||||
# survey = Survey.objects.get(id=survey.id)
|
||||
# self.assertEqual(survey.module, self.new_module)
|
||||
|
||||
# def test_content_block_after_move_hook(self):
|
||||
# """
|
||||
# should move the content block, and set all entities' module to the new parent's parent module
|
||||
# """
|
||||
#
|
||||
# url = reverse(
|
||||
# "wagtailadmin_pages:move_confirm",
|
||||
# args=(self.content_block.id, self.new_chapter.id),
|
||||
# )
|
||||
# self.client.post(url)
|
||||
# assignment = self.content_block.contents[0].value["assignment_id"]
|
||||
# self.assertEqual(assignment.module, self.new_module)
|
||||
|
||||
def test_content_block_after_create_hook(self):
|
||||
"""
|
||||
should save the content block and set all new entites' module to the correct module
|
||||
"""
|
||||
assignment = AssignmentFactory(module=self.module)
|
||||
survey = SurveyFactory(module=None)
|
||||
self.assertEqual(assignment.module, assignment.module)
|
||||
self.assertIsNone(survey.module)
|
||||
self.assertEqual(ContentBlock.objects.count(), 1)
|
||||
url = reverse(
|
||||
"wagtailadmin_pages:add",
|
||||
args=("books", "contentblock", self.new_chapter.id),
|
||||
)
|
||||
post_data = {
|
||||
"title": "New Content Block",
|
||||
"order": 1,
|
||||
"slug": "hello-world",
|
||||
"contents-count": 2,
|
||||
"contents-0-deleted": "",
|
||||
"contents-0-order": "0",
|
||||
"contents-0-type": "assignment",
|
||||
"contents-0-id": "",
|
||||
"contents-0-value-assignment_id": f"{assignment.id}",
|
||||
"contents-1-deleted": "",
|
||||
"contents-1-order": "1",
|
||||
"contents-1-type": "survey",
|
||||
"contents-1-id": "",
|
||||
"contents-1-value-survey_id": f"{survey.id}",
|
||||
"type": "normal",
|
||||
}
|
||||
response = self.client.post(
|
||||
url,
|
||||
post_data,
|
||||
)
|
||||
self.assertEqual(ContentBlock.objects.count(), 2)
|
||||
# reload assignment
|
||||
assignment = Assignment.objects.get(id=assignment.id)
|
||||
self.assertEqual(assignment.module, self.new_module)
|
||||
survey = Survey.objects.get(id=survey.id)
|
||||
self.assertEqual(survey.module, self.new_module)
|
||||
|
|
@ -5,7 +5,7 @@ from django.contrib import admin
|
|||
from django.urls import re_path
|
||||
from django.views.generic import RedirectView
|
||||
from wagtail.admin import urls as wagtailadmin_urls
|
||||
from wagtail.core import urls as wagtail_urls
|
||||
from wagtail import urls as wagtail_urls
|
||||
from wagtail.documents import urls as wagtaildocs_urls
|
||||
|
||||
from wagtailautocomplete.urls.admin import urlpatterns as autocomplete_admin_urls
|
||||
|
|
|
|||
|
|
@ -1,90 +1,144 @@
|
|||
import wagtail.admin.rich_text.editors.draftail.features as draftail_features
|
||||
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler
|
||||
from wagtail.core import hooks
|
||||
from wagtail.admin.rich_text.converters.html_to_contentstate import (
|
||||
InlineStyleElementHandler,
|
||||
)
|
||||
from wagtail import hooks
|
||||
|
||||
from basicknowledge.models import BasicKnowledge
|
||||
from books.models import ContentBlockSnapshot
|
||||
from books.models.chapter import Chapter
|
||||
from books.models.contentblock import ContentBlock
|
||||
from core.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
# 1. Use the register_rich_text_features hook.
|
||||
@hooks.register('register_rich_text_features')
|
||||
@hooks.register("register_rich_text_features")
|
||||
def register_brand_feature(features):
|
||||
"""
|
||||
Registering the feature, which uses the `BRAND` Draft.js inline style type,
|
||||
and is stored as HTML with a `<span class="brand">` tag.
|
||||
"""
|
||||
feature_name = 'brand'
|
||||
type_ = 'BRAND'
|
||||
feature_name = "brand"
|
||||
type_ = "BRAND"
|
||||
|
||||
# 2. Configure how Draftail handles the feature in its toolbar.
|
||||
control = {
|
||||
'type': type_,
|
||||
'label': 'Grün',
|
||||
'description': 'Grün',
|
||||
'style': {
|
||||
'color': '#17A887',
|
||||
'font-weight': '600'
|
||||
},
|
||||
"type": type_,
|
||||
"label": "Grün",
|
||||
"description": "Grün",
|
||||
"style": {"color": "#17A887", "font-weight": "600"},
|
||||
}
|
||||
|
||||
# 3. Call register_editor_plugin to register the configuration for Draftail.
|
||||
features.register_editor_plugin(
|
||||
'draftail', feature_name, draftail_features.InlineStyleFeature(control)
|
||||
"draftail", feature_name, draftail_features.InlineStyleFeature(control)
|
||||
)
|
||||
|
||||
# 4.configure the content transform from the DB to the editor and back.
|
||||
db_conversion = {
|
||||
'from_database_format': {'span[class="brand"]': InlineStyleElementHandler(type_)},
|
||||
'to_database_format': {'style_map': {type_: 'span class="brand""'}},
|
||||
"from_database_format": {
|
||||
'span[class="brand"]': InlineStyleElementHandler(type_)
|
||||
},
|
||||
"to_database_format": {"style_map": {type_: 'span class="brand""'}},
|
||||
}
|
||||
|
||||
# 5. Call register_converter_rule to register the content transformation conversion.
|
||||
features.register_converter_rule('contentstate', feature_name, db_conversion)
|
||||
features.register_converter_rule("contentstate", feature_name, db_conversion)
|
||||
|
||||
# 6. (optional) Add the feature to the default features list to make it available
|
||||
# on rich text fields that do not specify an explicit 'features' list
|
||||
features.default_features.append(feature_name)
|
||||
|
||||
|
||||
@hooks.register('register_rich_text_features')
|
||||
@hooks.register("register_rich_text_features")
|
||||
def register_secondary_feature(features):
|
||||
"""
|
||||
Registering the feature, which uses the `SECONDARY` Draft.js inline style type,
|
||||
and is stored as HTML with a `<span class="secondary">` tag.
|
||||
"""
|
||||
feature_name = 'secondary'
|
||||
type_ = 'SECONDARY'
|
||||
feature_name = "secondary"
|
||||
type_ = "SECONDARY"
|
||||
|
||||
# 2. Configure how Draftail handles the feature in its toolbar.
|
||||
control = {
|
||||
'type': type_,
|
||||
'label': 'Blau',
|
||||
'description': 'Blau',
|
||||
'style': {
|
||||
'color': '#078CC6',
|
||||
'font-weight': '600'
|
||||
},
|
||||
"type": type_,
|
||||
"label": "Blau",
|
||||
"description": "Blau",
|
||||
"style": {"color": "#078CC6", "font-weight": "600"},
|
||||
}
|
||||
|
||||
# 3. Call register_editor_plugin to register the configuration for Draftail.
|
||||
features.register_editor_plugin(
|
||||
'draftail', feature_name, draftail_features.InlineStyleFeature(control)
|
||||
"draftail", feature_name, draftail_features.InlineStyleFeature(control)
|
||||
)
|
||||
|
||||
# 4.configure the content transform from the DB to the editor and back.
|
||||
db_conversion = {
|
||||
'from_database_format': {'span[class="secondary"]': InlineStyleElementHandler(type_)},
|
||||
'to_database_format': {'style_map': {type_: 'span class="secondary"'}},
|
||||
"from_database_format": {
|
||||
'span[class="secondary"]': InlineStyleElementHandler(type_)
|
||||
},
|
||||
"to_database_format": {"style_map": {type_: 'span class="secondary"'}},
|
||||
}
|
||||
|
||||
# 5. Call register_converter_rule to register the content transformation conversion.
|
||||
features.register_converter_rule('contentstate', feature_name, db_conversion)
|
||||
features.register_converter_rule("contentstate", feature_name, db_conversion)
|
||||
|
||||
# 6. (optional) Add the feature to the default features list to make it available
|
||||
# on rich text fields that do not specify an explicit 'features' list
|
||||
features.default_features.append(feature_name)
|
||||
|
||||
|
||||
@hooks.register('construct_explorer_page_queryset')
|
||||
@hooks.register("construct_explorer_page_queryset")
|
||||
def remove_page_types_from_menu(parent_page, pages, request):
|
||||
return pages.not_type(ContentBlockSnapshot).not_type(BasicKnowledge).exclude(contentblock__user_created=True)
|
||||
return (
|
||||
pages.not_type(ContentBlockSnapshot)
|
||||
.not_type(BasicKnowledge)
|
||||
.exclude(contentblock__user_created=True)
|
||||
)
|
||||
|
||||
|
||||
@hooks.register("after_copy_page")
|
||||
def after_copy_hook(request, page, new_page):
|
||||
# todo: find every ContentBlock further down in the tree, see if there are any Surveys or Assignments and copy them and reassign them
|
||||
if type(page.specific) == ContentBlock:
|
||||
# logger.debug("It's a content block")
|
||||
content_block: ContentBlock = new_page.specific
|
||||
# logger.debug(f"duplicatin {content_block.title, content_block.pk}")
|
||||
content_block.duplicate_attached_entities()
|
||||
|
||||
else:
|
||||
# logger.debug(f"It's something else {type(page.specific)}, {ContentBlock}")
|
||||
content_blocks = new_page.specific.get_content_blocks()
|
||||
for content_block in content_blocks:
|
||||
content_block.duplicate_attached_entities()
|
||||
|
||||
|
||||
@hooks.register("after_move_page")
|
||||
def after_move_hook(request, page):
|
||||
logger.debug(f"after moving the page {page.title}")
|
||||
if type(page.specific) == ContentBlock:
|
||||
logger.debug("it's a content block")
|
||||
page.specific.reassign_entities()
|
||||
if type(page.specific) == Chapter:
|
||||
logger.debug("it's a chapter")
|
||||
content_blocks = page.specific.get_content_blocks()
|
||||
logger.debug(page.id)
|
||||
logger.debug(page.specific.get_content_blocks())
|
||||
logger.debug(page.get_children())
|
||||
for content_block in content_blocks:
|
||||
content_block.reassign_entities()
|
||||
|
||||
|
||||
@hooks.register("after_edit_page")
|
||||
def after_edit_hook(request, page):
|
||||
logger.debug(f"After edit page {page.title}, {type(page).__name__}")
|
||||
|
||||
|
||||
@hooks.register("after_create_page")
|
||||
def after_create_hook(request, page):
|
||||
# reassign assignment and survey module
|
||||
if type(page.specific) == ContentBlock:
|
||||
content_block = page.specific
|
||||
content_block.reassign_entities()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from wagtail.admin.edit_handlers import CommentPanel
|
||||
from wagtail.admin.edit_handlers import FieldPanel, ObjectList
|
||||
from wagtail.core.models import Page
|
||||
from wagtail.admin.panels import CommentPanel
|
||||
from wagtail.admin.panels import FieldPanel, ObjectList
|
||||
from wagtail.models import Page
|
||||
|
||||
|
||||
class StrictHierarchyPage(Page):
|
||||
|
|
@ -9,20 +9,27 @@ class StrictHierarchyPage(Page):
|
|||
abstract = True
|
||||
|
||||
def get_child_ids(self):
|
||||
return self.get_children().values_list('id', flat=True)
|
||||
return self.get_children().values_list("id", flat=True)
|
||||
|
||||
@classmethod
|
||||
def get_by_parent(cls, parent):
|
||||
return cls.objects.filter(id__in=parent.get_child_ids()).live()
|
||||
|
||||
def get_content_blocks(self):
|
||||
from books.models.contentblock import ContentBlock
|
||||
|
||||
return ContentBlock.objects.all().descendant_of(self)
|
||||
|
||||
|
||||
def wagtail_parent_filter(parent_cls, child_cls):
|
||||
class ParentValueFilter(admin.SimpleListFilter):
|
||||
title = 'parent'
|
||||
parameter_name = 'parent'
|
||||
title = "parent"
|
||||
parameter_name = "parent"
|
||||
|
||||
def lookups(self, request, model_admin):
|
||||
return list((parent.slug, parent.title) for parent in parent_cls.objects.all())
|
||||
return list(
|
||||
(parent.slug, parent.title) for parent in parent_cls.objects.all()
|
||||
)
|
||||
|
||||
def queryset(self, request, queryset):
|
||||
filter_value = self.value()
|
||||
|
|
@ -34,7 +41,4 @@ def wagtail_parent_filter(parent_cls, child_cls):
|
|||
|
||||
|
||||
def get_default_settings():
|
||||
return ObjectList([
|
||||
FieldPanel('slug'),
|
||||
CommentPanel()
|
||||
], heading='Settings')
|
||||
return ObjectList([FieldPanel("slug"), CommentPanel()], heading="Settings")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from django.contrib import admin
|
||||
from wagtail.core.models import Page
|
||||
from wagtail.models import Page
|
||||
|
||||
from objectives.models import ObjectiveGroup, Objective
|
||||
from books.models import Topic
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import factory
|
|||
import wagtail_factories
|
||||
from django.contrib.auth import get_user_model
|
||||
from factory import CREATE_STRATEGY
|
||||
from wagtail.core.rich_text import RichText
|
||||
from wagtail.rich_text import RichText
|
||||
|
||||
from books.factories import TextBlockFactory, ImageUrlBlockFactory, LinkBlockFactory
|
||||
from core.factories import fake, fake_paragraph
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
from django.db import migrations, models
|
||||
import django_extensions.db.fields
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -36,7 +36,7 @@ class Migration(migrations.Migration):
|
|||
('description', models.TextField(blank=True, null=True, verbose_name='description')),
|
||||
('slug', django_extensions.db.fields.AutoSlugField(blank=True, editable=False, populate_from='title', verbose_name='slug')),
|
||||
('subtitle', models.CharField(blank=True, max_length=255)),
|
||||
('contents', wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True)),
|
||||
('contents', wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Raumeintrag',
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 2.0.6 on 2019-06-17 11:15
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -15,6 +15,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='roomentry',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock())])), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 2.0.6 on 2019-07-22 09:32
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -15,6 +15,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='roomentry',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul']))])), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul']))])), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 3.2.13 on 2022-06-15 15:40
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -15,6 +15,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='roomentry',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))])), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import wagtail.core.blocks
|
||||
import wagtail.core.fields
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -21,6 +21,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='roomentry',
|
||||
name='contents',
|
||||
field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock(features=['ul', 'bold']))])), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('subtitle', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock())])), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True),
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 3.2.16 on 2023-02-21 16:04
|
||||
|
||||
from django.db import migrations
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rooms', '0012_auto_20220712_1109'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='roomentry',
|
||||
name='contents',
|
||||
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold']))])), ('image_url_block', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('document_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())])), ('subtitle', wagtail.blocks.StructBlock([('text', wagtail.blocks.TextBlock())])), ('video_block', wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock())]))], blank=True, null=True, use_json_field=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -1,9 +1,15 @@
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from django_extensions.db.models import TitleSlugDescriptionModel
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.fields import StreamField
|
||||
|
||||
from books.blocks import DocumentBlock, ImageUrlBlock, LinkBlock, SubtitleBlock, VideoBlock
|
||||
from books.blocks import (
|
||||
DocumentBlock,
|
||||
ImageUrlBlock,
|
||||
LinkBlock,
|
||||
SubtitleBlock,
|
||||
VideoBlock,
|
||||
)
|
||||
from books.models import TextBlock
|
||||
from core.mixins import GraphqlNodeMixin
|
||||
from users.models import SchoolClass
|
||||
|
|
@ -11,38 +17,55 @@ from users.models import SchoolClass
|
|||
|
||||
class Room(TitleSlugDescriptionModel, GraphqlNodeMixin):
|
||||
class Meta:
|
||||
verbose_name = 'Raum'
|
||||
verbose_name_plural = 'Räume'
|
||||
verbose_name = "Raum"
|
||||
verbose_name_plural = "Räume"
|
||||
|
||||
school_class = models.ForeignKey(SchoolClass, blank=False, null=False, on_delete=models.CASCADE,
|
||||
related_name='rooms')
|
||||
school_class = models.ForeignKey(
|
||||
SchoolClass,
|
||||
blank=False,
|
||||
null=False,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="rooms",
|
||||
)
|
||||
appearance = models.CharField(blank=True, null=False, max_length=255)
|
||||
user_created = models.BooleanField(blank=False, null=False, default=True)
|
||||
restricted = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.title} - {self.school_class}'
|
||||
return f"{self.title} - {self.school_class}"
|
||||
|
||||
|
||||
class RoomEntry(TitleSlugDescriptionModel):
|
||||
class Meta:
|
||||
verbose_name = 'Raumeintrag'
|
||||
verbose_name_plural = 'Raumeinträge'
|
||||
verbose_name = "Raumeintrag"
|
||||
verbose_name_plural = "Raumeinträge"
|
||||
|
||||
room = models.ForeignKey(Room, blank=False, null=False, on_delete=models.CASCADE, related_name='room_entries')
|
||||
author = models.ForeignKey(get_user_model(), null=True, on_delete=models.CASCADE)
|
||||
room = models.ForeignKey(
|
||||
Room,
|
||||
blank=False,
|
||||
null=False,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="room_entries",
|
||||
)
|
||||
author = models.ForeignKey(
|
||||
get_user_model(), null=True, on_delete=models.CASCADE)
|
||||
|
||||
contents = StreamField([
|
||||
('text_block', TextBlock()),
|
||||
('image_url_block', ImageUrlBlock()),
|
||||
('link_block', LinkBlock()),
|
||||
('document_block', DocumentBlock()),
|
||||
('subtitle', SubtitleBlock()),
|
||||
('video_block', VideoBlock())
|
||||
], null=True, blank=True)
|
||||
contents = StreamField(
|
||||
[
|
||||
("text_block", TextBlock()),
|
||||
("image_url_block", ImageUrlBlock()),
|
||||
("link_block", LinkBlock()),
|
||||
("document_block", DocumentBlock()),
|
||||
("subtitle", SubtitleBlock()),
|
||||
("video_block", VideoBlock()),
|
||||
],
|
||||
null=True,
|
||||
blank=True,
|
||||
use_json_field=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f'RoomEntry {self.id}-{self.title}-{self.author}'
|
||||
return f"RoomEntry {self.id}-{self.title}-{self.author}"
|
||||
|
||||
def can_user_see_entry(self, user):
|
||||
return user.is_superuser or self.room.school_class.is_user_in_schoolclass(user)
|
||||
|
|
@ -50,17 +73,21 @@ class RoomEntry(TitleSlugDescriptionModel):
|
|||
|
||||
class ModuleRoomSlug(TitleSlugDescriptionModel):
|
||||
class Meta:
|
||||
verbose_name = 'Slug für Modul-Raum'
|
||||
verbose_name_plural = 'Slugs für Modul-Raum'
|
||||
verbose_name = "Slug für Modul-Raum"
|
||||
verbose_name_plural = "Slugs für Modul-Raum"
|
||||
|
||||
def __str__(self):
|
||||
return f'ModuleRoomSlug {self.id}-{self.title}'
|
||||
return f"ModuleRoomSlug {self.id}-{self.title}"
|
||||
|
||||
|
||||
class Comment(models.Model):
|
||||
text = models.TextField()
|
||||
room_entry = models.ForeignKey(RoomEntry, related_name='comments', on_delete=models.CASCADE)
|
||||
owner = models.ForeignKey(get_user_model(), related_name='comments', on_delete=models.PROTECT)
|
||||
room_entry = models.ForeignKey(
|
||||
RoomEntry, related_name="comments", on_delete=models.CASCADE
|
||||
)
|
||||
owner = models.ForeignKey(
|
||||
get_user_model(), related_name="comments", on_delete=models.PROTECT
|
||||
)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#
|
||||
# Created on 2019-08-05
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
from wagtail.core import hooks
|
||||
from wagtail import hooks
|
||||
|
||||
from rooms.models import ModuleRoomSlug
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue