#NEWLINE# @ csrf_exempt #NEWLINE# def submit( request ) : #NEWLINE# #INDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# json_dict = safe_key_getter ( json_load ( request . raw_post_data ) ) #NEWLINE# coord_list = json_dict ( 'coord_system' ) #NEWLINE# type_list = json_dict ( 'types' ) #NEWLINE# format_list = json_dict ( 'formats' ) #NEWLINE# update_frequency_list = json_dict ( 'update_frequency' ) #NEWLINE# ( coords , types , formats , updates ) = ( '' , '' , '' , '' ) #NEWLINE# if ( coord_list == None ) : #NEWLINE# #INDENT# return http_badreq ( 'coord_system should be a list' ) #NEWLINE# #UNINDENT# if ( type_list == None ) : #NEWLINE# #INDENT# return http_badreq ( 'types should be a list' ) #NEWLINE# #UNINDENT# if ( format_list == None ) : #NEWLINE# #INDENT# return http_badreq ( 'formats should be a list' ) #NEWLINE# #UNINDENT# if ( update_frequency_list == None ) : #NEWLINE# #INDENT# return http_badreq ( 'update_frequency should be a list' ) #NEWLINE# #UNINDENT# for c in coord_list : #NEWLINE# #INDENT# coords = ( ( coords + ' EPSG:' ) + CoordSystem . objects . get ( pk = c ) . EPSG_code . __str__ ( ) ) #NEWLINE# #UNINDENT# for t in type_list : #NEWLINE# #INDENT# types = ( ( types + ' ' ) + UrlType . objects . get ( pk = t ) . url_type ) #NEWLINE# #UNINDENT# for f in coord_list : #NEWLINE# #INDENT# formats = ( ( formats + ' ' ) + DataType . objects . get ( pk = f ) . data_type ) #NEWLINE# #UNINDENT# for u in update_frequency_list : #NEWLINE# #INDENT# if u : #NEWLINE# #INDENT# updates = ( ( updates + ' ' ) + UpdateFrequency . objects . get ( pk = u ) . update_frequency ) #NEWLINE# #UNINDENT# #UNINDENT# data = { #NEWLINE# #INDENT# 'submitter' : request . user . username , #NEWLINE# 'submit_date' : datetime . now ( ) , #NEWLINE# 'dataset_name' : json_dict ( 'dataset_name' ) , #NEWLINE# 'organization' : json_dict ( 'organization' ) , #NEWLINE# 'copyright_holder' : json_dict ( 'copyright_holder' ) , #NEWLINE# 'contact_email' : json_dict ( 'contact_email' ) , #NEWLINE# 'contact_phone' : json_dict ( 'contact_phone' ) , #NEWLINE# 'url' : json_dict ( 'url' ) , #NEWLINE# 'time_period' : json_dict ( 'time_period' ) , #NEWLINE# 'release_date' : json_dict ( 'release_date' ) , #NEWLINE# 'area_of_interest' : json_dict ( 'area_of_interest' ) , #NEWLINE# 'update_frequency' : updates , #NEWLINE# 'coord_system' : coords , #NEWLINE# 'types' : types , #NEWLINE# 'formats' : formats , #NEWLINE# 'usage_limitations' : json_dict ( 'usage_limitations' ) , #NEWLINE# 'collection_process' : json_dict ( 'collection_process' ) , #NEWLINE# 'data_purpose' : json_dict ( 'data_purpose' ) , #NEWLINE# 'intended_audience' : json_dict ( 'intended_audience' ) , #NEWLINE# 'why' : json_dict ( 'why' ) , #NEWLINE# #UNINDENT# } #NEWLINE# for key in data : #NEWLINE# #INDENT# if ( ( data [ key ] == None ) or ( hasattr ( data [ key ] , 'len' ) and ( len ( data [ key ] ) == 0 ) ) ) : #NEWLINE# #INDENT# return http_badreq ( ( key + ' is empty or not defined' ) ) #NEWLINE# #UNINDENT# #UNINDENT# send_email ( request . user , data ) #NEWLINE# return HttpResponse ( 'Created' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Http404