Exemplo n.º 1
0
def _edit_data_source_shared(request, domain, config, read_only=False, create=False):
    if request.method == 'POST':
        form = ConfigurableDataSourceEditForm(domain, config, read_only, data=request.POST)
        if form.is_valid():
            config = form.save(commit=True)
            messages.success(request, _(u'Data source "{}" saved!').format(config.display_name))
            if create:
                # if we just created a data source, redirect to the edit view to avoid creating a new one
                return HttpResponseRedirect(reverse('edit_configurable_data_source', args=[domain, config._id]))
    else:
        form = ConfigurableDataSourceEditForm(domain, config, read_only)
    context = _shared_context(domain)
    context.update({
        'form': form,
        'data_source': config,
        'read_only': read_only
    })
    if config.is_deactivated:
        messages.info(
            request, _(
                'Data source "{}" has no associated table.\n'
                'Click "Rebuild Data Source" to recreate the table.'
            ).format(config.display_name)
        )
    return render(request, "userreports/edit_data_source.html", context)
Exemplo n.º 2
0
 def edit_form(self):
     if self.request.method == 'POST':
         return ConfigurableDataSourceEditForm(self.domain,
                                               self.config,
                                               self.read_only,
                                               data=self.request.POST)
     return ConfigurableDataSourceEditForm(self.domain, self.config,
                                           self.read_only)
Exemplo n.º 3
0
def _edit_data_source_shared(request, domain, config):
    if request.method == 'POST':
        form = ConfigurableDataSourceEditForm(domain, config, request.POST)
        if form.is_valid():
            config = form.save(commit=True)
            messages.success(request, _(u'Data source "{}" saved!').format(config.display_name))
    else:
        form = ConfigurableDataSourceEditForm(domain, config)
    context = _shared_context(domain)
    context.update({
        'form': form,
        'data_source': config,
    })
    return render(request, "userreports/edit_data_source.html", context)
Exemplo n.º 4
0
def _edit_data_source_shared(request, domain, config, read_only=False):
    if request.method == 'POST':
        form = ConfigurableDataSourceEditForm(domain, config, read_only, data=request.POST)
        if form.is_valid():
            config = form.save(commit=True)
            messages.success(request, _(u'Data source "{}" saved!').format(config.display_name))
    else:
        form = ConfigurableDataSourceEditForm(domain, config, read_only)
    context = _shared_context(domain)
    context.update({
        'form': form,
        'data_source': config,
        'read_only': read_only
    })
    if config.is_deactivated:
        messages.info(
            request, _(
                'Data source "{}" has no associated table.\n'
                'Click "Rebuild Data Source" to recreate the table.'
            ).format(config.display_name)
        )
    return render(request, "userreports/edit_data_source.html", context)
Exemplo n.º 5
0
def _edit_data_source_shared(request, domain, config, read_only=False):
    if request.method == 'POST':
        form = ConfigurableDataSourceEditForm(domain,
                                              config,
                                              read_only,
                                              data=request.POST)
        if form.is_valid():

            config = form.save(commit=True)
            messages.success(
                request,
                _(u'Data source "{}" saved!').format(config.display_name))

    else:
        form = ConfigurableDataSourceEditForm(domain, config, read_only)
    context = _shared_context(domain)
    context.update({
        'form': form,
        'data_source': config,
        'read_only': read_only
    })
    return render(request, "userreports/edit_data_source.html", context)