def generate_update_view(self): """Generate class based view for UpdateView""" name = model_class_form(self.model + 'UpdateView') update_args = dict( form_class=self.get_actual_form('update'), model=self.get_model_class, template_name=self.get_template('update'), permissions=self.view_permission('update'), permission_required=self.check_permission_required, login_required=self.check_login_required, inlineformset=self.inlineformset, custom_form=self.createupdate_forms or self.custom_modelform, success_url=reverse_lazy('{}-{}-list'.format(self.app, self.custom_postfix_url)), custom_postfix_url=self.custom_postfix_url ) parent_classes = [self.get_createupdate_mixin(), UpdateView] if self.custom_update_view_mixin: parent_classes.insert(0, self.custom_update_view_mixin) update_class = type( name, tuple(parent_classes), update_args ) self.classes[name] = update_class return update_class
def generate_list_view(self): """Generate class based view for ListView""" name = model_class_form(self.model + 'ListView') list_args = dict( model=self.get_model_class, context_object_name=plural(self.model), template_name=self.get_template('list'), table_class=self.get_actual_table(), context_table_name='table_objects', crud=self.crud, permissions=self.view_permission('list'), permission_required=self.check_permission_required, login_required=self.check_login_required, table_pagination={'per_page': self.tables2_pagination or 10}, custom_queryset=self.custom_queryset, custom_context=self.custom_context, custom_postfix_url=self.custom_postfix_url ) list_class = type( name, (BaseListViewMixin, SingleTableView), list_args ) self.classes[name] = list_class return list_class
def generate_list_view(self): """Generate class based view for ListView""" name = model_class_form(self.model + 'ListView') list_args = dict( model=self.get_model_class, context_object_name=plural(self.model), template_name=self.get_template('list'), table_class=self.get_actual_table(), context_table_name='table_objects', crud=self.crud, permissions=self.view_permission('list'), permission_required=self.check_permission_required, login_required=self.check_login_required, table_pagination={'per_page': self.tables2_pagination or 10}, custom_queryset=self.custom_queryset, custom_context=self.custom_context, custom_postfix_url=self.custom_postfix_url) parent_classes = [BaseListViewMixin, SingleTableView] if self.custom_list_view_mixin: parent_classes.insert(0, self.custom_list_view_mixin) list_class = type(name, tuple(parent_classes), list_args) self.classes[name] = list_class return list_class
def generate_create_view(self): """Generate class based view for CreateView""" name = model_class_form(self.model + 'CreateView') create_args = dict(form_class=self.get_actual_form('create'), model=self.get_model_class, template_name=self.get_template('create'), permissions=self.view_permission('create'), permission_required=self.check_permission_required, login_required=self.check_login_required, inlineformset=self.inlineformset, success_url=reverse_lazy('{}-{}-list'.format( self.app, self.custom_postfix_url)), custom_form=self.createupdate_forms or self.custom_modelform, custom_postfix_url=self.custom_postfix_url) parent_classes = [self.get_createupdate_mixin(), CreateView] if self.custom_create_view_mixin: parent_classes.insert(0, self.custom_create_view_mixin) create_class = type(name, tuple(parent_classes), create_args) self.classes[name] = create_class return create_class
def generate_create_view(self): """Generate class based view for CreateView""" name = model_class_form(self.model + 'CreateView') create_args = dict( form_class=self.get_actual_form('create'), model=self.get_model_class, template_name=self.get_template('create'), permissions=self.view_permission('create'), permission_required=self.check_permission_required, login_required=self.check_login_required, inlineformset=self.inlineformset, success_url=reverse_lazy('{}-{}-list'.format(self.app, self.custom_postfix_url)), custom_form=self.createupdate_forms or self.custom_modelform, custom_postfix_url=self.custom_postfix_url ) create_class = type( name, (self.get_createupdate_mixin(), CreateView), create_args ) self.classes[name] = create_class return create_class
def generate_table(self): model_class = self.get_model_class() detail_url_name = '{}-{}-detail'.format( self.app, custom_postfix_url(self.crud(), self.model) ) main_attrs = dict( id=tables.LinkColumn(detail_url_name, args=[A('pk')]) ) meta_attrs = dict( model=model_class, fields=('id',) + self.tables2_fields if self.tables2_fields else ('id',), attrs={ "class": self.tables2_css_class, "empty_text": "No {} exist".format(plural(self.model)) }) main_attrs['Meta'] = type('Meta', (), meta_attrs) klass = type( model_class_form(self.model + 'Table'), (tables.Table,), main_attrs ) return klass
def generate_table(self): model_class = self.get_model_class() detail_url_name = '{}-{}-detail'.format( self.app, custom_postfix_url(self.crud(), self.model)) main_attrs = dict( id=tables.LinkColumn(detail_url_name, args=[A('pk')]) # uuid=tables.LinkColumn(detail_url_name, args=[A('uuid')]) #'uuid' replaced 'id' ) meta_attrs = dict( model=model_class, fields=('id', ) + self.tables2_fields if self.tables2_fields else ('id', ), # fields=self.tables2_fields, #Exclude 'id' in table field attrs={ "class": self.tables2_css_class, "empty_text": "No {} exist".format(plural(self.model)) }) main_attrs['Meta'] = type('Meta', (), meta_attrs) klass = type(model_class_form(self.model + 'Table'), (tables.Table, ), main_attrs) return klass
def generate_table(self): model_class = self.get_model_class() detail_url_name = "{}-{}-detail".format(self.app, self.model) main_attrs = dict(id=tables.LinkColumn(detail_url_name, args=[A("pk")])) meta_attrs = dict( model=model_class, fields=("id",) + self.tables2_fields if self.tables2_fields else ("id",), attrs={"class": self.tables2_css_class, "empty_text": "No {} exist".format(plural(self.model))}, ) main_attrs["Meta"] = type("Meta", (), meta_attrs) klass = type(model_class_form(self.model + "Table"), (tables.Table,), main_attrs) return klass
def generate_detail_view(self): """Generate class based view for DetailView""" name = model_class_form(self.model + 'DetailView') detail_args = dict( model=self.get_model_class, template_name=self.get_template('detail'), login_required=self.check_login_required, permissions=self.view_permission('detail'), permission_required=self.check_permission_required, ) detail_class = type(name, (CrudBuilderMixin, DetailView), detail_args) self.classes[name] = detail_class return detail_class
def generate_delete_view(self): """Generate class based view for DeleteView""" name = model_class_form(self.model + 'DeleteView') delete_args = dict(model=self.get_model_class, template_name=self.get_template('delete'), permissions=self.view_permission('delete'), permission_required=self.check_permission_required, login_required=self.check_login_required, success_url=reverse_lazy('{}-{}-list'.format( self.app, self.model))) delete_class = type(name, (CrudBuilderMixin, DeleteView), delete_args) self.classes[name] = delete_class return delete_class
def generate_delete_view(self): """Generate class based view for DeleteView""" name = model_class_form(self.model + 'DeleteView') delete_args = dict( model=self.get_model_class, template_name=self.get_template('delete'), permissions=self.view_permission('delete'), permission_required=self.check_permission_required, login_required=self.check_login_required, success_url=reverse_lazy('{}-{}-list'.format(self.app, self.model)) ) delete_class = type(name, (CrudBuilderMixin, DeleteView), delete_args) self.classes[name] = delete_class return delete_class
def generate_detail_view(self): """Generate class based view for DetailView""" name = model_class_form(self.model + 'DetailView') detail_args = dict(detailview_excludes=self.detailview_excludes, model=self.get_model_class, template_name=self.get_template('detail'), login_required=self.check_login_required, permissions=self.view_permission('detail'), inlineformset=self.inlineformset, permission_required=self.check_permission_required, custom_postfix_url=self.custom_postfix_url) detail_class = type(name, (BaseDetailViewMixin, DetailView), detail_args) self.classes[name] = detail_class return detail_class
def generate_detail_view(self): """Generate class based view for DetailView""" name = model_class_form(self.model + 'DetailView') detail_args = dict( detailview_excludes = self.detailview_excludes, model=self.get_model_class, template_name=self.get_template('detail'), login_required=self.check_login_required, permissions=self.view_permission('detail'), inlineformset=self.inlineformset, permission_required=self.check_permission_required, ) detail_class = type(name, (BaseDetailViewMixin, DetailView), detail_args) self.classes[name] = detail_class return detail_class
def generate_update_view(self): """Generate class based view for UpdateView""" name = model_class_form(self.model + 'UpdateView') update_args = dict(form_class=self.get_actual_form('update'), model=self.get_model_class, template_name=self.get_template('update'), permissions=self.view_permission('update'), permission_required=self.check_permission_required, login_required=self.check_login_required, inlineformset=self.inlineformset, success_url=reverse_lazy('{}-{}-list'.format( self.app, self.model))) update_class = type(name, (self.get_createupdate_mixin(), UpdateView), update_args) self.classes[name] = update_class return update_class
def generate_delete_view(self): """Generate class based view for DeleteView""" name = model_class_form(self.model + 'DeleteView') delete_args = dict(model=self.get_model_class, template_name=self.get_template('delete'), permissions=self.view_permission('delete'), permission_required=self.check_permission_required, login_required=self.check_login_required, success_url=reverse_lazy('{}-{}-list'.format( self.app, self.custom_postfix_url)), custom_postfix_url=self.custom_postfix_url) parent_classes = [CrudBuilderMixin, DeleteView] if self.custom_delete_view_mixin: parent_classes.insert(0, self.custom_delete_view_mixin) delete_class = type(name, tuple(parent_classes), delete_args) self.classes[name] = delete_class return delete_class