/usr/share/pyshared/extra_views/generic.py is in python-django-extra-views 0.2.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | from django.contrib.contenttypes.generic import generic_inlineformset_factory, BaseGenericInlineFormSet
from extra_views.formsets import BaseInlineFormSetMixin, InlineFormSetMixin, BaseInlineFormSetView, InlineFormSetView
class BaseGenericInlineFormSetMixin(BaseInlineFormSetMixin):
ct_field = "content_type"
ct_fk_field = "object_id"
formset_class = BaseGenericInlineFormSet
def get_factory_kwargs(self):
kwargs = super(BaseGenericInlineFormSetMixin, self).get_factory_kwargs()
del kwargs['fk_name']
kwargs.update({
"ct_field": self.ct_field,
"fk_field": self.ct_fk_field,
})
return kwargs
def get_formset(self):
result = generic_inlineformset_factory(self.inline_model, **self.get_factory_kwargs())
return result
class GenericInlineFormSet(BaseGenericInlineFormSetMixin):
def __init__(self, parent_model, request, instance):
self.inline_model = self.model
self.model = parent_model
self.request = request
self.object = instance
class GenericInlineFormSetMixin(BaseGenericInlineFormSetMixin, InlineFormSetMixin):
pass
class BaseGenericInlineFormSetView(GenericInlineFormSetMixin, BaseInlineFormSetView):
pass
class GenericInlineFormSetView(BaseGenericInlineFormSetView, InlineFormSetView):
pass
|