Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# (c) 2018-2020 

2# MPIB <https://www.mpib-berlin.mpg.de/>, 

3# MPI-CBS <https://www.cbs.mpg.de/>, 

4# MPIP <http://www.psych.mpg.de/> 

5# 

6# This file is part of Castellum. 

7# 

8# Castellum is free software; you can redistribute it and/or modify it 

9# under the terms of the GNU Affero General Public License as published 

10# by the Free Software Foundation; either version 3 of the License, or 

11# (at your option) any later version. 

12# 

13# Castellum is distributed in the hope that it will be useful, but 

14# WITHOUT ANY WARRANTY; without even the implied warranty of 

15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

16# Affero General Public License for more details. 

17# 

18# You should have received a copy of the GNU Affero General Public 

19# License along with Castellum. If not, see 

20# <http://www.gnu.org/licenses/>. 

21 

22from django import forms 

23from django.contrib import admin 

24 

25from parler.admin import TranslatableAdmin 

26 

27from castellum.recruitment.filter_registry import custom_filters 

28 

29from . import models 

30 

31 

32def custom_filter_choices(): 

33 return [(None, '---')] + [(k, k) for k in sorted(custom_filters.keys())] 

34 

35 

36class StudyForm(forms.ModelForm): 

37 custom_filter = forms.ChoiceField(choices=custom_filter_choices, required=False) 

38 

39 class Meta: 

40 model = models.Study 

41 fields = '__all__' 

42 

43 

44class StudySessionInline(admin.TabularInline): 

45 model = models.StudySession 

46 

47 

48class StudyAdmin(admin.ModelAdmin): 

49 form = StudyForm 

50 inlines = [StudySessionInline] 

51 search_fields = ['name'] 

52 readonly_fields = ['domain'] 

53 

54 

55admin.site.register(models.Resource) 

56admin.site.register(models.Study, StudyAdmin) 

57admin.site.register(models.StudyMembership) 

58admin.site.register(models.StudyType, TranslatableAdmin)