@treeio_login_required
@handle_response_format
def currency_add(request, response_format='html'):
 if (not request.user.profile.is_admin('treeio.finance')):
  return user_denied(request, message="You don't have administrator access to the Finance module")
 if request.POST:
  if ('cancel' not in request.POST):
   currency = Currency()
   form = CurrencyForm(request.user.profile, request.POST, instance=currency)
   if form.is_valid():
    currency = form.save(commit=False)
    cname = dict_currencies[currency.code]
    currency.name = cname[(cname.index(' ') + 2):]
    currency.save()
    currency.set_user_from_request(request)
    return HttpResponseRedirect(reverse('finance_currency_view', args=[currency.id]))
  else:
   return HttpResponseRedirect(reverse('finance_settings_view'))
 else:
  form = CurrencyForm(request.user.profile)
 return render_to_response('finance/currency_add', {'form': form}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def currency_add ( request , response_format = 'html' ) : if ( not request . user . profile . is_admin ( 'treeio.finance' ) ) : return user_denied ( request , message = "You don't have administrator access to the Finance module" ) if request . POST : if ( 'cancel' not in request . POST ) : currency = Currency ( ) form = CurrencyForm ( request . user . profile , request . POST , instance = currency ) if form . is_valid ( ) : currency = form . save ( commit = False ) cname = dict_currencies [ currency . code ] currency . name = cname [ ( cname . index ( ' ' ) + 2 ) : ] currency . save ( ) currency . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'finance_currency_view' , args = [ currency . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'finance_settings_view' ) ) else : form = CurrencyForm ( request . user . profile ) return render_to_response ( 'finance/currency_add' , { 'form' : form } , context_instance = RequestContext ( request ) , response_format = response_format )
currency add .