Esempio n. 1
0
def gethsnopdata( request ):
	print( "qx/views/gethsnopdata() %s %s" % ( request.scheme, request.method ) )
	
	if request.method == "GET":
		REQUEST = request.GET
	else:
		REQUEST = request.POST
		
#	op_number = request.POST.get( "op_num" )
	op_number = REQUEST.get( "op_num" )
	
	op_err_str = ""
	op_info_list = get_op_info( op_number )
	if len( op_info_list ) == 0:
		op_err_str = "Geen OP gevonden voor OP-nummer %s" % op_number
		op_isvalid = False
	else:
		op_isvalid = True
	print( "op_isvalid: ", op_isvalid )
	
	for op_info_dict in op_info_list:
		print( "op_info_dict:", op_info_dict )
	
	marriages = {}
	missing_data = {}
	hsnmanage = { "statustekst" : "" }
	partners = {}
	mails = {}
	deaths = {}
	
	if op_isvalid:
		marriages = get_marriages( op_number )
		print( "marriages: ", marriages )
	
		missing_data = get_missing( op_number )
		print( "missing data: ", missing_data )
	
		hsnmanage = get_hsnmanage( op_number )
		print( "hsnmanage: ", hsnmanage )
	
		partners = get_partners( op_number )
		print( "partners: ", partners )
	
		mails = get_mails( op_number )
		print( "mails: ", mails )
	
		deaths = get_deaths( op_number )
		print( "deaths: ", deaths )
		
		# sometimes the death location is not [yet] present in the HsnBeheer table, 
		# but we [sometimes] can display it from the Ovlknd table
		if hsnmanage.get( "ovlplaats" ) == "":
			for death in deaths:
				if death.get( "table_name" ) == "Ovlknd":
					hsnmanage[ "ovlplaats" ] = death.get( "death_location" )
		
	OP = \
	{
		"op_num"       : op_number,
		"op_err_str"   : op_err_str,
		"op_info_list" : op_info_list,
		
		"hsnmanage"    : hsnmanage,
		"marriages"    : marriages,
		"missing_data" : missing_data,
		"partners"     : partners,
		"mails"        : mails,
		"deaths"       : deaths
	}
		
	dictionary = \
	{
		"op_isvalid" : op_isvalid,
		"OP" : OP
	}
	

	"""	
#	scheme_authority, sub_site = get_server_info( request )

	template = "index.html"
	dictionary = \
	{
	#	'SUB_SITE'      : sub_site,
	#	'STATIC_PREFIX' : scheme_authority,
		'STATIC_PREFIX' : '',
	#	'STATIC_URL'    : settings.STATIC_URL,
	#	'STATIC_URL'    : '127.0.0.1',
		'STATIC_URL'    : '/',
	}

	context = RequestContext( request )
		
#	json_data = json.dumps( dictionary )
#	content_type = "application/json; charset=UTF-8"
#	return HttpResponse( json_data, content_type )
#	return render_to_response( template, dictionary, context )
#	return render( json_data, content_type, context )
	"""
	
	return JsonResponse( dictionary )
Esempio n. 2
0
def print_mailbev():
	if debug: print( "mail/print/print_mailbev(" )
	
	# notice, no cups.py, but just a .cups.so
	#print( os.path.abspath( cups.__file__ ) )
	# .../python2710/lib/python2.7/site-packages/cups.so
	
	ids = []
	
	try:
		from qx.views import none2empty
		
		ret_status = "OK"
		msg = ""
	#	mail_qs = Mail.objects.using( "mail" ).filter( status = 0, type = "BEV" ).order_by( "provnr", "archiefnaam", "id" )	# "provnr" not in Mail table
	#	mail_qs = Mail.objects.using( "mail" ).filter( status = 0, type = "BEV" ).order_by( "archiefnaam", "id" )	# "archiefnaam" not in Mail table
		mail_qs = Mail.objects.using( "mail" ).filter( status = 0, type = "BEV" ).order_by( "gemnr", "id" )
		
		if mail_qs is None:
			msg = "Mail does not contain entries with status = 0"
			if debug: print( msg )
		else:
			nmails_bev = mail_qs.count()
			if debug: print( "Number of mails with status = 0:", nmails_bev )
			
			for mail in mail_qs:
				if debug: print( mail )
				id = str( mail.id )
				ids.append( id )
				
				opsex    = none2empty( get_opsex(    mail.idnr ) )
				mailtype = none2empty( get_mailtype( mail.idnr ) )
				if debug: print( "opsex:", opsex, ", mailtype:", mailtype )
				
				archive = none2empty( get_archive( mail.gemnr ) )
				if debug: print( "archive:", archive )
				
				info_list = none2empty( get_op_info( mail.idnr ) )
				if debug: print( "info_list:", info_list )
				
				pathname_psfile = get_pathname_psfile( mail.gemnr, id )
				
				OP = {
					"info_list"   : info_list,
					"mailtype"    : mailtype,
					"idnr"        : str( mail.idnr ),
					"kind"        : none2empty( mail.aard ),
					"gemnr"       : mail.gemnr,
					"archive"     : archive,
					"datum"       : none2empty( mail.datum ),
					"periode"     : none2empty( mail.periode ),
					"naamgem"     : none2empty( mail.naamgem ),
					"opmerk"      : none2empty( mail.opmerk ),
					"opsex"       : opsex,
					"opident"     : none2empty( mail.opident ),
					"oppartner"   : none2empty( mail.oppartner ),
					"opvader"     : none2empty( mail.opvader ),
					"opmoeder"    : none2empty( mail.opmoeder ),
					"infoouders"  : none2empty( mail.infoouders ),
					"infopartner" : none2empty( mail.infopartner ),
					"inforeis"    : none2empty( mail.inforeis )
				}
				
				create_ps_letter( pathname_psfile, OP )
				
				try:
					MAIL_SENT_TO_PRINTER = settings.MAIL_SENT_TO_PRINTER
				except:
					MAIL_SENT_TO_PRINTER = MAIL_SENT_TO_PRINTER_DEFAULT
		
				if MAIL_SENT_TO_PRINTER:
					ret_status, msg = print_ps_letter( id, pathname_psfile )
					
					try:
						MAIL_UPDATE_TABLE = settings.MAIL_UPDATE_TABLE
					except:
						MAIL_UPDATE_TABLE = MAIL_UPDATE_TABLE_DEFAULT
		
					if ret_status == "OK" and MAIL_UPDATE_TABLE:
						update_status_date( id )
				
				
			#	break	# test: create/print only 1 letter

	except:
		ret_status = "ERROR"
		print( "print_mailbev()" )
		type, value, tb = exc_info()
		msg = "Mail.objects.filter failed: %s" % value
		print( "%s\n" % msg )
	
	return ret_status, msg, ids