@require_POST
@login_required
def create_for_locale(request):
 user = request.user
 locale = Locale.objects.get(locale=request.LANGUAGE_CODE)
 if (not user_can_announce(user, locale)):
  return HttpResponseForbidden()
 form = AnnouncementForm(request.POST)
 if form.is_valid():
  a = Announcement(creator=user, locale=locale, **form.cleaned_data)
  a.save()
  return HttpResponse(json.dumps({'id': a.id}), content_type='application/json')
 else:
  return HttpResponse(json.dumps(form.errors), status=400, content_type='application/json')

@ require_POST @ login_required def create_for_locale ( request ) : user = request . user locale = Locale . objects . get ( locale = request . LANGUAGE_CODE ) if ( not user_can_announce ( user , locale ) ) : return HttpResponseForbidden ( ) form = AnnouncementForm ( request . POST ) if form . is_valid ( ) : a = Announcement ( creator = user , locale = locale , ** form . cleaned_data ) a . save ( ) return HttpResponse ( json . dumps ( { 'id' : a . id } ) , content_type = 'application/json' ) else : return HttpResponse ( json . dumps ( form . errors ) , status = 400 , content_type = 'application/json' )
an ajax view to create a new announcement for the current locale .