def replace_icon_with_default(request):
 "\n    Expected output will look something like this:\n    {\n            'success': true,\n            'portfolio_entry__pk': 0\n    }"
 portfolio_entry = PortfolioEntry.objects.get(pk=int(request.POST['portfolio_entry__pk']), person__user=request.user)
 project = portfolio_entry.project
 project_before_changes = mysite.search.models.Project.objects.get(pk=project.pk)
 mysite.search.models.WrongIcon.spawn_from_project(project)
 try:
  wrong_icon_url = project_before_changes.icon_for_profile.url
 except ValueError:
  wrong_icon_url = 'icon_url'
 project.invalidate_all_icons()
 project.save()
 data = {}
 data['success'] = True
 data['portfolio_entry__pk'] = portfolio_entry.pk
 return mysite.base.view_helpers.json_response(data)

def replace_icon_with_default ( request ) : portfolio_entry = PortfolioEntry . objects . get ( pk = int ( request . POST [ 'portfolio_entry__pk' ] ) , person__user = request . user ) project = portfolio_entry . project project_before_changes = mysite . search . models . Project . objects . get ( pk = project . pk ) mysite . search . models . WrongIcon . spawn_from_project ( project ) try : wrong_icon_url = project_before_changes . icon_for_profile . url except ValueError : wrong_icon_url = 'icon_url' project . invalidate_all_icons ( ) project . save ( ) data = { } data [ 'success' ] = True data [ 'portfolio_entry__pk' ] = portfolio_entry . pk return mysite . base . view_helpers . json_response ( data )
expected postcondition: projects icon_dict says it is generic .