Merge branch 'feature/MS-539-Add-search' into release/Wagtail-anpassungen
This commit is contained in:
commit
d7b2c36994
|
|
@ -24,7 +24,8 @@ class Assignment(index.Indexed, TimeStampedModel):
|
||||||
taskbase_id = models.CharField(max_length=255, null=True, blank=True)
|
taskbase_id = models.CharField(max_length=255, null=True, blank=True)
|
||||||
|
|
||||||
search_fields = [
|
search_fields = [
|
||||||
index.SearchField('title', partial_match=True)
|
index.SearchField('title', partial_match=True),
|
||||||
|
index.SearchField('assignment', partial_match=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
panels = [
|
panels = [
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@ from .models import Assignment
|
||||||
class AssignmentAdmin(ModelAdmin):
|
class AssignmentAdmin(ModelAdmin):
|
||||||
model = Assignment
|
model = Assignment
|
||||||
menu_label = 'Assignments'
|
menu_label = 'Assignments'
|
||||||
list_display = ('title', 'module', 'pk',)
|
list_display = ('title', 'module', 'assignment')
|
||||||
|
search_fields = ('title', 'assignment')
|
||||||
|
list_filter = ('module', )
|
||||||
|
menu_icon = 'form'
|
||||||
|
|
||||||
|
|
||||||
modeladmin_register(AssignmentAdmin)
|
modeladmin_register(AssignmentAdmin)
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,21 @@ from django.contrib.auth import get_user_model
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import JSONField
|
from django.db.models import JSONField
|
||||||
from wagtail.snippets.models import register_snippet
|
from wagtail.snippets.models import register_snippet
|
||||||
|
from wagtail.search import index
|
||||||
|
|
||||||
|
|
||||||
@register_snippet
|
@register_snippet
|
||||||
class Survey(models.Model):
|
class Survey(models.Model, index.Indexed):
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
module = models.ForeignKey('books.Module', related_name='surveys', on_delete=models.CASCADE, null=True,
|
module = models.ForeignKey('books.Module', related_name='surveys', on_delete=models.CASCADE, null=True,
|
||||||
blank=True)
|
blank=True)
|
||||||
data = JSONField()
|
data = JSONField()
|
||||||
|
|
||||||
|
search_fields = [
|
||||||
|
index.SearchField('title', partial_match=True),
|
||||||
|
index.SearchField('module__meta_title', partial_match=True),
|
||||||
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
|
||||||
|
from .models import Survey
|
||||||
|
|
||||||
|
|
||||||
|
class SurveyAdmin(ModelAdmin):
|
||||||
|
model = Survey
|
||||||
|
menu_label = 'Surveys'
|
||||||
|
list_display = ('title', 'module')
|
||||||
|
search_fields = ('title', 'module__meta_title')
|
||||||
|
list_filter = ('module', )
|
||||||
|
menu_icon = 'help'
|
||||||
|
|
||||||
|
|
||||||
|
modeladmin_register(SurveyAdmin)
|
||||||
|
|
||||||
Loading…
Reference in New Issue