Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

acmanage the reportupdate form internally within the report form

  • Loading branch information...
commit f3f13ebf9fe996237392f72055c412d64456bcd1 1 parent 2a2d581
Jennifer Bell authored
11 mainapp/forms.py
View
@@ -69,11 +69,12 @@ class Meta:
class ReportForm(forms.ModelForm):
"""
ReportForm --
- combine is_valid(), clean(), and save()
+
+ combines is_valid(), clean(), and save()
etc. for both an update form and a report form
- (these are submitted at the same time when a
- report is initially created)
+ (information for both models is submitted at
+ the same time when a report is initially created)
"""
class Meta:
@@ -84,8 +85,8 @@ class Meta:
lat = forms.fields.CharField(widget=forms.widgets.HiddenInput)
lon = forms.fields.CharField(widget=forms.widgets.HiddenInput)
- def __init__(self,update_form,data=None,files=None,initial=None):
- self.update_form = update_form
+ def __init__(self,data=None,files=None,initial=None):
+ self.update_form = ReportUpdateForm(data)
super(ReportForm,self).__init__(data,files, initial=initial)
def _get_pnt(self):
3  mainapp/views/mobile.py
View
@@ -63,8 +63,7 @@ def post(self,request):
raise InputValidationException('Invalid Nonce for API Key')
# we're good.
- update_form = ReportUpdateForm( request.POST )
- report_form = ReportForm( update_form, request.POST, request.FILES )
+ report_form = ReportForm( request.POST, request.FILES )
if not report_form.is_valid():
# some issue with our form input.
raise InputValidationException(report_form.all_errors())
8 mainapp/views/reports/main.py
View
@@ -13,8 +13,7 @@ def new( request ):
if request.method == "POST":
pnt = fromstr("POINT(" + request.POST["lon"] + " " + request.POST["lat"] + ")", srid=4326)
- update_form = ReportUpdateForm( request.POST )
- report_form = ReportForm( update_form, request.POST, request.FILES )
+ report_form = ReportForm( request.POST, request.FILES )
# this checks update is_valid too
if report_form.is_valid():
# this saves the update as part of the report.
@@ -23,15 +22,14 @@ def new( request ):
return( HttpResponseRedirect( report.get_absolute_url() ))
else:
pnt = fromstr("POINT(" + request.GET["lon"] + " " + request.GET["lat"] + ")", srid=4326)
- update_form = ReportUpdateForm()
- report_form = ReportForm(update_form, initial={ 'lat': request.GET['lat'],
+ report_form = ReportForm(initial={ 'lat': request.GET['lat'],
'lon': request.GET['lon'] } )
return render_to_response("reports/new.html",
{ "google": FixMyStreetMap(pnt, True),
"report_form": report_form,
- "update_form": update_form },
+ "update_form": report_form.update_form },
context_instance=RequestContext(request))
def show( request, report_id ):
Please sign in to comment.
Something went wrong with that request. Please try again.