def get_death_hsnmanage(op_numstr): print("hsn_manage/views/get_death_hsnmanage:", op_numstr) death = None # get death info info from HsnBeheer try: from qx.views import none2empty entry = HsnBeheer.objects.using("mail").get(idnr=op_numstr) death_location = none2empty(entry.ovlplaats) if entry is not None: death = { "table_name": "HsnBeheer", "edit": True, "death_day": entry.ovldag, "death_month": entry.ovlmnd, "death_year": entry.ovljaar, "death_location": death_location } print(death) else: print("HsnBeheer entry %s does not exist" % op_numstr) except: print("hsn_manage/views/get_death_hsnmanage( %s )" % op_numstr) type, value, tb = exc_info() msg = "HsnBeheer.objects.get failed: %s" % value print("%s\n" % msg) return death
def get_death_ovlknd(op_numstr): print("hsn_manage/views/get_death_ovlknd:", op_numstr) death = None death_location = "" death_location_nr = "" # get death info info from Ovlknd entry = get_ovlknd(op_numstr) if entry is None: print("Ovlknd entry %s does not exist" % op_numstr) else: from qx.views import none2empty death_location = none2empty(entry.oacgemnm) death_location_nr = none2empty(entry.oacgemnr) death = { "table_name": "Ovlknd", "edit": False, "death_day": entry.ovldag, "death_month": entry.ovlmnd, "death_year": entry.ovljr, "death_location": death_location, "death_location_nr": death_location_nr } print(death) # sometimes the death location is empty, but it might be retrieved via the nr if death is not None and death_location == "" and death_location_nr != "": plaats_qs = get_location_by_gemnr(death_location_nr) if plaats_qs is not None: death_location = plaats_qs.gemnaam death["death_location"] = death_location else: print("Plaats with gemnr %s does not exist", death_location_nr) return death
def get_mails(op_number): """ List of existing mails of OP """ print("get_mails()") nmails = 0 mails_bev = [] mails_huw = [] mails_oth = [] try: mail_qs = Mail.objects.using("mail").filter(idnr=op_number).order_by("id") if mail_qs is None: print("Mail does not contain entries for OP %d", op_number) else: from qx.views import none2empty nmails = mail_qs.count() print("Mail has %d entries for OP %s" % (nmails, op_number)) for mail in mail_qs: mail_dict = { "id": mail.id, # AI PK "idnr": none2empty(mail.idnr), "briefnr": none2empty(mail.briefnr), "aard": none2empty(mail.aard), "datum": none2empty(mail.datum), "periode": none2empty(mail.periode), "gemnr": none2empty(mail.gemnr), "naamgem": none2empty(mail.naamgem), "status": none2empty(mail.status), "printdatum": none2empty(mail.printdatum), "printen": none2empty(mail.printen), "ontvdat": none2empty(mail.ontvdat), "opmerk": none2empty(mail.opmerk), "opident": none2empty(mail.opident), "oppartner": none2empty(mail.oppartner), "opvader": none2empty(mail.opvader), "opmoeder": none2empty(mail.opmoeder), "type": none2empty(mail.type), "infoouders": none2empty(mail.infoouders), "infopartner": none2empty(mail.infopartner), "inforeis": none2empty(mail.inforeis), } if mail.type == "BEV": mails_bev.append(mail_dict) if mail.status == "0": nstatus0_bev += 1 elif mail.type == "HUW": mails_huw.append(mail_dict) else: mails_oth.append(mail_dict) except: print("get_mails()") type, value, tb = exc_info() msg = "Mail.objects.filter failed: %s" % value print("%s\n" % msg) mails = {"bev": mails_bev, "huw": mails_huw, "oth": mails_oth} return mails
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
def get_op_info( op_number ): """ get birth info from table Hsnrp id_origin values: >=10 and < 17 a given idnr may occur multiple times *_firstname is actually firstnames """ op_info_list = [] if op_number == "": print( "op/get_op_info(): empty op_number: doing nothing" ) return op_info_list print( "op/get_op_info():", op_number ) hsnrp_qs = get_hsnrp( op_number ) if hsnrp_qs is None: print( "Hsnrp entry idnr %d does not exist", op_number ) else: from qx.views import none2empty for hsnrp in hsnrp_qs: id = hsnrp.id # AI PK idnr = none2empty( hsnrp.idnr ) id_origin = none2empty( hsnrp.id_origin ) project = none2empty( hsnrp.project ) gemnr = none2empty( hsnrp.gemnr ) valid_day = none2empty( hsnrp.valid_day ) valid_month = none2empty( hsnrp.valid_month ) valid_year = none2empty( hsnrp.valid_year ) rp_family = none2empty( hsnrp.rp_family ) rp_prefix = none2empty( hsnrp.rp_prefix ) rp_firstname = none2empty( hsnrp.rp_firstname ) rp_b_day = none2empty( hsnrp.rp_b_day ) rp_b_month = none2empty( hsnrp.rp_b_month ) rp_b_year = none2empty( hsnrp.rp_b_year ) rp_b_sex = none2empty( hsnrp.rp_b_sex ) rp_b_place = none2empty( hsnrp.rp_b_place ) rp_b_prov = none2empty( hsnrp.rp_b_prov ) rp_b_coh = none2empty( hsnrp.rp_b_coh ) mo_family = none2empty( hsnrp.mo_family ) mo_prefix = none2empty( hsnrp.mo_prefix ) mo_firstname = none2empty( hsnrp.mo_firstname ) fa_family = none2empty( hsnrp.fa_family ) fa_prefix = none2empty( hsnrp.fa_prefix ) fa_firstname = none2empty( hsnrp.fa_firstname ) op_info_dict = {} op_info_dict[ "id" ] = id op_info_dict[ "idnr" ] = idnr op_info_dict[ "id_origin" ] = id_origin op_info_dict[ "project" ] = project op_info_dict[ "gemnr" ] = gemnr op_info_dict[ "valid_day" ] = valid_day op_info_dict[ "valid_month" ] = valid_month op_info_dict[ "valid_year" ] = valid_year op_info_dict[ "rp_family" ] = rp_family op_info_dict[ "rp_prefix" ] = rp_prefix op_info_dict[ "rp_firstname" ] = rp_firstname op_info_dict[ "rp_b_day" ] = rp_b_day op_info_dict[ "rp_b_month" ] = rp_b_month op_info_dict[ "rp_b_year" ] = rp_b_year op_info_dict[ "rp_b_sex" ] = rp_b_sex op_info_dict[ "rp_b_place" ] = rp_b_place op_info_dict[ "rp_b_prov" ] = rp_b_prov op_info_dict[ "rp_b_coh" ] = rp_b_coh op_info_dict[ "mo_family" ] = mo_family op_info_dict[ "mo_prefix" ] = mo_prefix op_info_dict[ "mo_firstname" ] = mo_firstname op_info_dict[ "fa_family" ] = fa_family op_info_dict[ "fa_prefix" ] = fa_prefix op_info_dict[ "fa_firstname" ] = fa_firstname # some fields not in the table op_info_dict[ "remarks" ] = "" valid_date = "%s/%s/%s" % ( valid_day, valid_month, valid_year ) op_info_dict[ "valid_date" ] = valid_date rp_b_date = "%s/%s/%s" % ( rp_b_day, rp_b_month, rp_b_year ) op_info_dict[ "rp_b_date" ] = rp_b_date display_rp_family = rp_family if rp_prefix != "": display_rp_family += ", " + rp_prefix if int( id_origin ) == 10: display_str = "%s %s, %s [%s], geboren %s/%s/%s te %s" % ( idnr, display_rp_family, rp_firstname, rp_b_sex, rp_b_day, rp_b_month, rp_b_year, rp_b_place ) else: display_str = "%s, %s [%s], geboren %s/%s/%s te %s" % ( display_rp_family, rp_firstname, rp_b_sex, rp_b_day, rp_b_month, rp_b_year, rp_b_place ) op_info_dict[ "display_str" ] = display_str op_info_list.append( op_info_dict ) op_info_list_manual = get_id_change_manual( op_number ) for op_info in op_info_list_manual: op_info_list.append( op_info ) return op_info_list
def get_id_change_manual( op_number ): """ get id change id info from table HsnIdmut id_origin values: 17 and 18 a given idnr may occur multiple times *_firstname is actually firstnames """ print( "op/get_id_change_manual():", op_number ) # Get Identification mutations info from table HsnIdmut # Such id mutations has been created manually via the hsnmailenbeheer GUI # There can also be automatic id changes from table Hsnrp op_info_list = [] try: hsnidmut_qs = HsnIdmut.objects.using( "mail" ).filter( idnr = op_number ) if hsnidmut_qs is None: print( "HsnIdmut entry %d does not exist", op_number ) else: from qx.views import none2empty for hsnidmut in hsnidmut_qs: id = hsnidmut.id # AI PK idnr = none2empty( hsnidmut.idnr ) id_origin = none2empty( hsnidmut.id_origin ) rp_family = none2empty( hsnidmut.rp_family ) rp_prefix = none2empty( hsnidmut.rp_prefix ) rp_firstname = none2empty( hsnidmut.rp_firstname ) rp_b_day = none2empty( hsnidmut.rp_b_day ) rp_b_month = none2empty( hsnidmut.rp_b_month ) rp_b_year = none2empty( hsnidmut.rp_b_year ) rp_b_place = none2empty( hsnidmut.rp_b_place ) rp_b_sex = none2empty( hsnidmut.rp_b_sex ) valid_day = none2empty( hsnidmut.valid_day ) valid_month = none2empty( hsnidmut.valid_month ) valid_year = none2empty( hsnidmut.valid_year ) remarks = none2empty( hsnidmut.remarks ) op_info_dict = {} op_info_dict[ "id" ] = id op_info_dict[ "idnr" ] = idnr op_info_dict[ "id_origin" ] = id_origin op_info_dict[ "rp_family" ] = rp_family op_info_dict[ "rp_prefix" ] = rp_prefix op_info_dict[ "rp_firstname" ] = rp_firstname op_info_dict[ "rp_b_day" ] = rp_b_day op_info_dict[ "rp_b_year" ] = rp_b_year op_info_dict[ "rp_b_place" ] = rp_b_place op_info_dict[ "rp_b_sex" ] = rp_b_sex op_info_dict[ "valid_day" ] = valid_day op_info_dict[ "valid_month" ] = valid_month op_info_dict[ "valid_year" ] = valid_year op_info_dict[ "remarks" ] = remarks # some fields not in the table valid_date = "%s/%s/%s" % ( valid_day, valid_month, valid_year ) op_info_dict[ "valid_date" ] = valid_date rp_b_date = "%s/%s/%s" % ( rp_b_day, rp_b_month, rp_b_year ) op_info_dict[ "rp_b_date" ] = rp_b_date display_rp_family = rp_family if rp_prefix != "": display_rp_family += ", " + rp_prefix display_str = "%s, %s [%s], geboren %s/%s/%s te %s" % ( display_rp_family, rp_firstname, rp_b_sex, rp_b_day, rp_b_month, rp_b_year, rp_b_place ) op_info_dict[ "display_str" ] = display_str op_info_list.append( op_info_dict ) except: print( "op/get_id_change_manual()" ) type, value, tb = exc_info() msg = "HsnIdmut.objects.filter failed: %s" % value print( "%s\n" % msg ) return op_info_list
def get_hsnmanage(op_numstr): hsnopmanage = {} # get hsnmanage info info from HsnBeheer phase_a = None phase_b = None phase_c = None try: hsnmanage_qs = HsnBeheer.objects.using("mail").filter(idnr=op_numstr) if hsnmanage_qs is None: print("HsnBeheer entry %s does not exist", op_numstr) else: from qx.views import none2empty for hsnmanage in hsnmanage_qs: mailtype = hsnmanage.mail_type if mailtype is None: mailtype = "" ovldag = hsnmanage.ovldag ovlmnd = hsnmanage.ovlmnd ovljaar = hsnmanage.ovljaar if ovldag == 0: ovldag = "" if ovlmnd == 0: ovlmnd = "" if ovljaar == 0: ovljaar = "" ovlplaats = none2empty(hsnmanage.ovlplaats) phase_a = hsnmanage.fase_a phase_b = hsnmanage.fase_b phase_c = hsnmanage.fase_c_d # print( "phase_a:", phase_a, "phase_b:", phase_b, "phase_c:", phase_c ) hsnopmanage = \ { "invoerstatus": hsnmanage.invoerstatus, "mailtype": mailtype, "ovldag": ovldag, "ovlmnd": ovlmnd, "ovljaar": ovljaar, "ovlplaats": ovlplaats, "phase_a": phase_a, "phase_b": phase_b, "phase_c": phase_c } except: print("hsn_manage/views/get_hsnmanage( %s )" % op_numstr) type, value, tb = exc_info() msg = "HsnBeheer.objects.filter failed: %s" % value print("%s\n" % msg) # prevent selecting fixed string labels in the client that no longer exist print("phase_a:", phase_a, "phase_b:", phase_b, "phase_c:", phase_c) phase_a_str = "" try: tfasea = TekstFaseA.objects.using("mail").filter(fase_a=hsnmanage.fase_a).first() if tfasea is not None: phase_a_str = str(phase_a) + " - " + tfasea.fase_a_text except: phase_a = "" type, value, tb = exc_info() msg = "TekstFaseA.objects failed: %s" % value print("%s\n" % msg) phase_b_str = "" try: tfaseb = TekstFaseB.objects.using("mail").filter(fase_b=hsnmanage.fase_b).first() if tfaseb is not None: phase_b_str = str(phase_b) + " - " + tfaseb.fase_b_text except: phase_b = "" type, value, tb = exc_info() msg = "TekstFaseB.objects failed: %s" % value print("%s\n" % msg) phase_c_str = "" try: tfasec = TekstFaseCD.objects.using("mail").filter(fase_c_d=hsnmanage.fase_c_d).first() if tfasec is not None: phase_c_str = str(phase_c) + " - " + tfasec.fase_c_d_text except: phase_c = "" type, value, tb = exc_info() msg = "TekstFaseCD.objects failed: %s" % value print("%s\n" % msg) print("phase_a:", phase_a, "phase_b:", phase_b, "phase_c:", phase_c) hsnopmanage["phase_a_str"] = phase_a_str hsnopmanage["phase_b_str"] = phase_b_str hsnopmanage["phase_c_str"] = phase_c_str # also need the number of the location hsnopmanage["ovlplaats_gemnr"] = "" location = hsnmanage.ovlplaats plaats_qs = get_location_by_gemnaam(location) if plaats_qs is not None: location_num = plaats_qs.gemnr hsnopmanage["ovlplaats_gemnr"] = location_num else: print("Plaats entry %s does not exist", location) # also need the voortgang string invoerstatus = hsnmanage.invoerstatus print("invoerstatus:", invoerstatus) voortgang = get_voortgang(invoerstatus) print("voortgang:", voortgang) hsnopmanage["statustekst"] = voortgang return hsnopmanage