Coverage for pages.admin.utils: 91%

# Coverage for pages.admin.utils : 91%

## 34 statements 31 run 0 excluded 3 missing

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # -*- coding: utf-8 -*- from pages import settings from django.contrib import admin from django.forms import ModelForm from django.core.urlresolvers import get_mod_func def get_connected(): if not settings.PAGE_CONNECTED_MODELS: return [] models = [] for capp in settings.PAGE_CONNECTED_MODELS: model = {} mod_name, model_name = get_mod_func(capp['model']) model['model_name'] = model_name m = getattr(__import__(mod_name, {}, {}, ['']), model_name) model['model'] = m options = capp.get('options', {}) model['options'] = options if 'form' in capp: mod_name, form_name = get_mod_func(capp['form']) f = getattr(__import__(mod_name, {}, {}, ['']), form_name) model['options'].update({'form': f}) admin_class = admin.StackedInline if 'admin' in capp: mod_name, admin_class_name = get_mod_func(capp['admin']) admin_class = getattr(__import__(mod_name, {}, {}, ['']), admin_class_name) models.append((admin_class, m, options)) return models def make_inline_admin(admin_class, model_class, options): class ModelOptions(admin_class): model = model_class fk_name = 'page' form = options.get('form', ModelForm) extra = options.get('extra', 3) max_num = options.get('max_num', 0) return ModelOptions