Exemple #1
0
    def _edit_resource(self, request):

        form_class = self._get_edit_form_class()
        if request.method == 'POST':

            form = form_class(request,
                              request.POST,
                              request.FILES,
                              instance=request.resource)
            if form.is_valid():
                form.save()
                return self.response_success()
            else:
                try:
                    #TODO fero
                    form.write_down_messages()
                except AttributeError as e:
                    log.warning(
                        'Refactory needed: calling non-existent write_down_messages on form_class=%s'
                        % form_class)
                    pass  #don't worry for this exception...

        else:
            form = form_class(request, instance=request.resource)
            try:
                #TODO fero
                form.write_down_messages()
            except AttributeError as e:
                log.warning(
                    'Refactory needed: calling non-existent write_down_messages on form_class=%s'
                    % form_class)
                pass  #don't worry for this exception...

        fields = form.base_fields.keys()
        fieldsets = form_class.Meta.gf_fieldsets
        adminForm = helpers.AdminForm(form, fieldsets, {})

        context = {
            'form': form,
            'adminform': adminForm,
            'opts': form._meta.model._meta,
            'add': False,
            'change': True,
            'is_popup': False,
            'save_as': False,
            'save_on_top': False,
            'has_add_permission': False,
            'has_delete_permission': True,
            'has_change_permission': True,
            'show_delete': False,
            'errors': helpers.AdminErrorList(form, []),
        }

        template = "html/admin_form.html"
        return render_to_response(template,
                                  context,
                                  context_instance=RequestContext(request))
Exemple #2
0
    def _edit_resource(self, request):

        form_class = self._get_edit_form_class()
        if request.method == 'POST':

            form = form_class(request, request.POST, request.FILES, instance=request.resource)
            if form.is_valid():
                form.save()
                return self.response_success()
            else:
                try:
                    #TODO fero
                    form.write_down_messages()
                except AttributeError as e:
                    log.warning('Refactory needed: calling non-existent write_down_messages on form_class=%s' % form_class)
                    pass #don't worry for this exception...

        else:
            form = form_class(request, instance=request.resource)
            try:
                #TODO fero
                form.write_down_messages()
            except AttributeError as e:
                log.warning('Refactory needed: calling non-existent write_down_messages on form_class=%s' % form_class)
                pass #don't worry for this exception...

        fields = form.base_fields.keys()
        fieldsets = form_class.Meta.gf_fieldsets
        adminForm = helpers.AdminForm(form, fieldsets, {}) 

        context = {
            'form' : form,
            'adminform' : adminForm,
            'opts' : form._meta.model._meta,
            'add'  : False,
            'change' : True,
            'is_popup': False,
            'save_as' : False,
            'save_on_top': False,
            'has_add_permission': False,
            'has_delete_permission': True,
            'has_change_permission': True,
            'show_delete' : False,
            'errors': helpers.AdminErrorList(form, []),
        }

        template = "html/admin_form.html"
        return render_to_response(template, context, context_instance=RequestContext(request))
Exemple #3
0
def get_context_menu(request):

    resource = request.resource
    user = request.user

    entries = []
    entries += get_default_menu_entries(resource, user)
    entries += get_external_menu_entries(resource, user)

    context = {
        'media_url': settings.MEDIA_URL,
        'resource': request.resource,
        'menu_entries': entries
    }

    pt = ['blocks/menu.xml']

    return render_to_response(pt, context)
def get_context_menu(request):

    resource = request.resource
    user = request.user

    entries = []
    entries += get_default_menu_entries(resource, user)
    entries += get_external_menu_entries(resource, user)
    
    context = {
          'media_url': settings.MEDIA_URL
        , 'resource': request.resource
        , 'menu_entries': entries
    }

    pt = ['blocks/menu.xml']

    return render_to_response(pt, context)