diff --git a/registrasion/reporting/forms.py b/registrasion/reporting/forms.py index c275fc01..e9f8cf0a 100644 --- a/registrasion/reporting/forms.py +++ b/registrasion/reporting/forms.py @@ -81,16 +81,3 @@ def model_fields_form_factory(model): ) return ModelFieldsForm - - -class SectionContentTypeForm(forms.Form): - section = forms.IntegerField( - required=False, - min_value=0, - widget=forms.HiddenInput(), - ) - - content_type = forms.CharField( - required=False, - widget=forms.HiddenInput(), - ) diff --git a/registrasion/reporting/reports.py b/registrasion/reporting/reports.py index dce5358f..eb2c33a6 100644 --- a/registrasion/reporting/reports.py +++ b/registrasion/reporting/reports.py @@ -216,10 +216,6 @@ class ReportView(object): def __init__(self, inner_view, title, form_type): # Consolidate form_type so it has content type and section - bases = [forms.SectionContentTypeForm, form_type] - bases = [base for base in bases if base is not None] - form_type = forms.mix_form(*bases) - self.inner_view = inner_view self.title = title self.form_type = form_type @@ -254,7 +250,7 @@ class ReportView(object): renderers = { "text/csv": self._render_as_csv, "text/html": self._render_as_html, - "": self._render_as_html, + None: self._render_as_html, } render = renderers[data.content_type] return render(data) @@ -292,9 +288,10 @@ class ReportViewRequestData(object): # Calculate other data self.form = report_view.get_form(request) - # Content type and section come from the form - self.content_type = self.form.cleaned_data["content_type"] - self.section = self.form.cleaned_data["section"] + # Content type and section come from request.GET + self.content_type = request.GET.get("content_type") + self.section = request.GET.get("section") + self.section = int(self.section) if self.section else None # Reports come from calling the inner view reports = report_view.inner_view(request, self.form, *a, **k) diff --git a/registrasion/templatetags/registrasion_tags.py b/registrasion/templatetags/registrasion_tags.py index 7d2bb56e..1f408ed1 100644 --- a/registrasion/templatetags/registrasion_tags.py +++ b/registrasion/templatetags/registrasion_tags.py @@ -80,9 +80,11 @@ def items_purchased(context, category=None): @register.assignment_tag(takes_context=True) def report_as_csv(context, section): - query = dict(context.request.GET) - query["section"] = section - query["content_type"] = "text/csv" + old_query = context.request.META["QUERY_STRING"] + query = dict([("section", section), ("content_type", "text/csv")]) querystring = urlencode(query) + if old_query: + querystring = old_query + "&" + querystring + return context.request.path + "?" + querystring