Update BasicKnowledge model with new type property
This commit is contained in:
parent
5fd5a5be4a
commit
14e9a4d6ec
|
|
@ -27,7 +27,7 @@ from users.mutations import ProfileMutations
|
|||
|
||||
|
||||
class CustomQuery(UsersQuery, AllUsersQuery, ModuleRoomsQuery, RoomsQuery, ObjectivesQuery, BookQuery, AssignmentsQuery,
|
||||
StudentSubmissionQuery, BasicKnowledgeQuery, PortfolioQuery, SurveysQuery, AllNewsTeasersQuery, graphene.ObjectType):
|
||||
StudentSubmissionQuery, BasicKnowledgeQuery, PortfolioQuery, SurveysQuery, AllNewsTeasersQuery, graphene.ObjectType):
|
||||
node = relay.Node.Field()
|
||||
|
||||
if settings.DEBUG:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 2.2.24 on 2021-10-20 12:02
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('basicknowledge', '0007_basicknowledge_intro'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='InstrumentType',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('category', models.CharField(choices=[('language_communication', 'Sprache & Kommunikation'), ('society', 'Gesellschaft'), ('interdisciplinary', 'Überfachliches Instrument')], max_length=100)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='basicknowledge',
|
||||
name='new_type',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='basicknowledge.InstrumentType'),
|
||||
),
|
||||
]
|
||||
|
|
@ -1,13 +1,31 @@
|
|||
from django.db import models
|
||||
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||
from wagtail.core.fields import StreamField, RichTextField
|
||||
from wagtail.core.fields import RichTextField, StreamField
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
from books.blocks import LinkBlock, VideoBlock, DocumentBlock, SectionTitleBlock, InfogramBlock, \
|
||||
GeniallyBlock, InstrumentTextBlock, SubtitleBlock, ThinglinkBlock
|
||||
from books.blocks import DocumentBlock, GeniallyBlock, InfogramBlock, InstrumentTextBlock, LinkBlock, SectionTitleBlock, \
|
||||
SubtitleBlock, ThinglinkBlock, VideoBlock
|
||||
from core.constants import DEFAULT_RICH_TEXT_FEATURES
|
||||
from core.wagtail_utils import StrictHierarchyPage
|
||||
|
||||
LANGUAGE_COMMUNICATION = 'language_communication'
|
||||
SOCIETY = 'society'
|
||||
INTERDISCIPLINARY = 'interdisciplinary'
|
||||
|
||||
CATEGORY_CHOICES = (
|
||||
(LANGUAGE_COMMUNICATION, 'Sprache & Kommunikation'),
|
||||
(SOCIETY, 'Gesellschaft'),
|
||||
(INTERDISCIPLINARY, 'Überfachliches Instrument'),
|
||||
)
|
||||
|
||||
|
||||
class InstrumentType(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
category = models.CharField(
|
||||
max_length=100,
|
||||
choices=CATEGORY_CHOICES
|
||||
)
|
||||
|
||||
|
||||
class BasicKnowledge(StrictHierarchyPage):
|
||||
parent_page_types = ['books.book']
|
||||
|
|
@ -27,19 +45,11 @@ class BasicKnowledge(StrictHierarchyPage):
|
|||
('subtitle', SubtitleBlock()),
|
||||
], null=True, blank=True)
|
||||
|
||||
LANGUAGE_COMMUNICATION = 'language_communication'
|
||||
SOCIETY = 'society'
|
||||
INTERDISCIPLINARY = 'interdisciplinary'
|
||||
|
||||
TYPE_CHOICES = (
|
||||
(LANGUAGE_COMMUNICATION, 'Sprache & Kommunikation'),
|
||||
(SOCIETY, 'Gesellschaft'),
|
||||
(INTERDISCIPLINARY, 'Überfachliches Instrument'),
|
||||
)
|
||||
new_type = models.ForeignKey(InstrumentType, null=True, on_delete=models.PROTECT)
|
||||
|
||||
type = models.CharField(
|
||||
max_length=100,
|
||||
choices=TYPE_CHOICES
|
||||
choices=CATEGORY_CHOICES
|
||||
)
|
||||
|
||||
content_panels = [
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class InstrumentNode(DjangoObjectType):
|
|||
|
||||
class BasicKnowledgeQuery(object):
|
||||
instrument = graphene.Field(InstrumentNode, slug=graphene.String(), id=graphene.ID())
|
||||
instruments = DjangoFilterConnectionField(InstrumentNode)
|
||||
instruments = graphene.List(InstrumentNode)
|
||||
|
||||
def resolve_instrument(self, info, **kwargs):
|
||||
slug = kwargs.get('slug')
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ type CustomQuery {
|
|||
project(id: ID, slug: String): ProjectNode
|
||||
projects: [ProjectNode]
|
||||
instrument(slug: String, id: ID): InstrumentNode
|
||||
instruments(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, type: String): InstrumentNodeConnection
|
||||
instruments: [InstrumentNode]
|
||||
studentSubmission(id: ID!): StudentSubmissionNode
|
||||
assignment(id: ID!): AssignmentNode
|
||||
assignments(offset: Int, before: String, after: String, first: Int, last: Int): AssignmentNodeConnection
|
||||
|
|
|
|||
Loading…
Reference in New Issue