Skip to content

Commit

Permalink
Merge pull request #134 from meomancer/develop
Browse files Browse the repository at this point in the history
fixing add/update : cannot see error when overal assessment is empty
  • Loading branch information
meomancer authored Jun 16, 2016
2 parents 3529ad7 + 9ead992 commit c2460bd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion django_project/healthsites/views/assessment_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from healthsites.models.assessment import HealthsiteAssessment
from healthsites.models.healthsite import Healthsite
from healthsites.utils import create_event, update_event, clean_parameter, get_overall_assessments
from exceptions import ValueError


def update_assessment(request):
Expand All @@ -33,15 +34,26 @@ def update_assessment(request):

if len(error_param_message) > 0:
messages = {'fail_params': error_param_message}
messages['fail'] = ["some field in general need to be filled"]
result = json.dumps(messages)
return HttpResponse(result, content_type='application/json')

#
messages['success'] = []
messages['fail'] = []
name = request.POST.get('name')
latitude = request.POST.get('latitude')
longitude = request.POST.get('longitude')
assessment = request.POST.get('overall_assessment')
try:
if (int(assessment) < 1 or int(assessment) > 5):
messages = {'fail': ["overal assessment just from 1 to 5"]}
result = json.dumps(messages)
return HttpResponse(result, content_type='application/json')
except ValueError:
messages = {'fail': ["overal assessment should be integer"]}
result = json.dumps(messages)
return HttpResponse(result, content_type='application/json')

geom = Point(
float(latitude), float(longitude)
)
Expand Down

0 comments on commit c2460bd

Please sign in to comment.