@handle_response_format
@treeio_login_required
def contact_add_typed(request, type_id, response_format='html'):
 contact_type = get_object_or_404(ContactType, pk=type_id)
 if (not request.user.profile.has_permission(contact_type, mode='x')):
  return user_denied(request, message=("You don't have access to create " + unicode(contact_type)))
 if request.POST:
  if ('cancel' not in request.POST):
   form = ContactForm(request.user.profile, contact_type, request.POST, files=request.FILES)
   if form.is_valid():
    contact = form.save(request, contact_type)
    contact.set_user_from_request(request)
    return HttpResponseRedirect(reverse('identities_contact_view', args=[contact.id]))
  else:
   return HttpResponseRedirect(reverse('identities_index'))
 else:
  form = ContactForm(request.user.profile, contact_type)
 types = Object.filter_by_request(request, ContactType.objects.order_by('name'))
 return render_to_response('identities/contact_add_typed', {'type': contact_type, 'types': types, 'form': form}, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def contact_add_typed ( request , type_id , response_format = 'html' ) : contact_type = get_object_or_404 ( ContactType , pk = type_id ) if ( not request . user . profile . has_permission ( contact_type , mode = 'x' ) ) : return user_denied ( request , message = ( "You don't have access to create " + unicode ( contact_type ) ) ) if request . POST : if ( 'cancel' not in request . POST ) : form = ContactForm ( request . user . profile , contact_type , request . POST , files = request . FILES ) if form . is_valid ( ) : contact = form . save ( request , contact_type ) contact . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'identities_contact_view' , args = [ contact . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'identities_index' ) ) else : form = ContactForm ( request . user . profile , contact_type ) types = Object . filter_by_request ( request , ContactType . objects . order_by ( 'name' ) ) return render_to_response ( 'identities/contact_add_typed' , { 'type' : contact_type , 'types' : types , 'form' : form } , context_instance = RequestContext ( request ) , response_format = response_format )
contact add with preselected type .