Browse files

Added save and continue to easy admin

Works with both vanilla admin and grappelli but method is crude -
it just runs javascript that deals with both cases
This will likely be a release to push to pypi as 1.5
  • Loading branch information...
1 parent 05bd064 commit 7edcda9a71e29cb7c888a1b635c87966b7b08a24 David Burke committed Dec 27, 2012
Showing with 24 additions and 4 deletions.
  1. +1 −1 README.md
  2. +11 −0 report_builder/admin.py
  3. +0 −2 report_builder/models.py
  4. +11 −0 report_builder/templates/admin/report_builder/change_form.html
  5. +1 −1 setup.py
View
2 README.md
@@ -13,12 +13,12 @@ What's finished?
- Preview and create xlsx reports
- Very simple security, user must have change or "view" permission to view
reports. Unprivileged users can still build reports and see database schema.
+- Model properties (thanks yekibud)
What isn't
- "or" filters together
- More exports, views
- Decent form validation
-- Functions in display fields
- Support for django-custom-fields
# Installation
View
11 report_builder/admin.py
@@ -1,6 +1,7 @@
from django.contrib import admin
from django import forms
from django.core.urlresolvers import reverse
+from django.http import HttpResponseRedirect
from report_builder.models import DisplayField, Report, FilterField
@@ -31,6 +32,16 @@ class ReportAdmin(admin.ModelAdmin):
inlines = [DisplayFieldInline, FilterFieldInline]
list_display_links = ['admin_edit']
+ def response_add(self, request, obj, post_url_continue=None):
+ if '_easy' in request.POST:
+ return HttpResponseRedirect(obj.get_absolute_url())
+ return super(ReportAdmin, self).response_add(request, obj, post_url_continue)
+
+ def response_change(self, request, obj, post_url_continue=None):
+ if '_easy' in request.POST:
+ return HttpResponseRedirect(obj.get_absolute_url())
+ return super(ReportAdmin, self).response_change(request, obj, post_url_continue)
+
def easy_edit(self, obj):
return '<a href="%s">Edit</a>' % obj.get_absolute_url()
easy_edit.allow_tags = True
View
2 report_builder/models.py
@@ -20,8 +20,6 @@ def _get_allowed_models():
modified = models.DateField(auto_now=True)
distinct = models.BooleanField()
-
-
@models.permalink
def get_absolute_url(self):
return ("report_update_view", [str(self.id)])
View
11 report_builder/templates/admin/report_builder/change_form.html
@@ -0,0 +1,11 @@
+{% extends "admin/change_form.html" %}
+
+{% block submit_buttons_bottom %}
+ {{ block.super }}
+ <script>
+ (function($) {$('<input type="submit" name="_easy" value="Save and continue to easy edit"/>').appendTo('.submit-row');})(django.jQuery);
+
+ $('<li><input type="submit" class="grp-button grp-default" name="_easy" value="Save and continue to easy edit"/></li>').appendTo('footer ul');
+
+</script>
+{% endblock %}
View
2 setup.py
@@ -2,7 +2,7 @@
setup(
name = "django-report-builder",
- version = "1.4",
+ version = "1.5",
author = "David Burke",
author_email = "david@burkesoftware.com",
description = ("Query and Report builder for Django ORM"),

0 comments on commit 7edcda9

Please sign in to comment.