コード例 #1
0
ファイル: admin.py プロジェクト: fabiold/keops
 def _prepare_change_view(self, request, context):
     context['items'] = json.dumps(extjs.get_form_items(self))
     context['fields'] = json.dumps(['pk'] + list(self.fields))
     pk = request.GET.get('pk')
     if pk:
         context['pk'] = pk
     self._prepare_context(request, context)
コード例 #2
0
ファイル: actions.py プロジェクト: dissipator/keops
def show_model_admin(request, admin, view_type):
    if view_type == 'list':
        return admin.list_view(request)
    
    import json
    from django import forms
    from keops.forms import extjs
    
    f = form
    
    if view_type == 'list':
        template = 'keops/base/list_form.js'
        fields = [name for name, field in form.get_form().base_fields.items() if not isinstance(field, forms.ModelMultipleChoiceField)]
        items = None
    else:
        #return form.add_view(request)
        template = 'keops/base/model_form.js'
        fields = [name for name, field in f.base_fields.items()]
        items = json.dumps(extjs.get_form_items(f))
    fields = json.dumps(fields + ['pk'])
    
    
    
    return render(request, template, {'form': f, 'model': model,
        'json': json, 'fields': fields, 'extjs': extjs, 'items': items,
        'model_name': '%s.%s' % (model._meta.app_label, model._meta.model_name),
        'form_title': model._meta.verbose_name_plural})
コード例 #3
0
ファイル: admin.py プロジェクト: dissipator/keops
 def _prepare_change_view(self, request, context):
     context['items'] = json.dumps(extjs.get_form_items(self))
     context['fields'] = json.dumps(['pk'] + list(self.fields))
     pk = request.GET.get('pk')
     if pk:
         context['pk'] = pk
     self._prepare_context(request, context)