def check_vote(self, mobid): try: bdocpython.initialize() conf = bdocpythonutils.BDocConfig() conf.load(Election().get_bdoc_conf()) res = None if mobid: res = regrights.check_vote_hes_mobid(self._decoded_vote, conf) else: res = regrights.check_vote_hes(self._decoded_vote, conf) if not res.result: self.error.log_msg = res.error if self.error.user_msg == '': self.error.user_msg = evmessage.EvMessage().\ get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \ evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL) self.error.user_code = evcommon.EVOTE_ERROR if not res.cert_is_valid: self.error.user_msg = evmessage.EvMessage().\ get_str("SERTIFIKAAT_ON_AEGUNUD", \ evstrings.SERTIFIKAAT_ON_AEGUNUD) self.error.user_code = evcommon.EVOTE_CERT_ERROR return False ik_ver = regrights.get_personal_code(res.subject) if self._ik != ik_ver: self.error.log_msg = \ 'Autentija (%s) ja allkirjastaja (%s) erinevad' % \ (self._ik, ik_ver) self.error.user_msg = \ evmessage.EvMessage().get_str("ERINEV_KASUTAJA", \ evstrings.ERINEV_KASUTAJA) self.error.user_code = evcommon.EVOTE_ERROR return False return True except: self.error.user_msg = evmessage.EvMessage().\ get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \ evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL) self.error.user_code = evcommon.EVOTE_ERROR self.error.log_msg = exception_msg.trace() finally: bdocpython.terminate() return False
def work(self): valid, msg = is_valid_id_cert() if not valid: self.logmsg = msg self.errcode = evcommon.EVOTE_CERT_ERROR self.errmsg = evmessage.EvMessage().\ get_str("SERTIFIKAAT_POLE_SELLE_CA_POOLT_VALJA_ANTUD", \ evstrings.SERTIFIKAAT_POLE_SELLE_CA_POOLT_VALJA_ANTUD) return False self._ik, self._en, self._pn = cert_info() if not birthday.is_18(self._ik): self.errcode = evcommon.EVOTE_ERROR self.errmsg = evmessage.EvMessage().\ get_str("POLE_18", evstrings.POLE_18) self.logmsg = self.errmsg return False return True
def bad_parameters(): protocol.http_response(evcommon.VERSION + "\n" + \ evcommon.VERIFY_ERROR + "\n" + \ evmessage.EvMessage().get_str("BAD_PARAMETERS", \ evstrings.BAD_PARAMETERS)) cgi.sys.exit(0)
def get_mid_text(status): import evmessage import evstrings if status == 'MID_NOT_READY': return evmessage.EvMessage(). \ get_str("MID_NOT_READY", evstrings.MID_NOT_READY) elif status == 'USER_CANCEL': return evmessage.EvMessage(). \ get_str("MID_USER_CANCEL", evstrings.MID_USER_CANCEL) elif status == 'PHONE_ABSENT': return evmessage.EvMessage(). \ get_str("MID_PHONE_ABSENT", evstrings.MID_PHONE_ABSENT) elif status == 'SENDING_ERROR': return evmessage.EvMessage(). \ get_str("MID_SENDING_ERROR", evstrings.MID_SENDING_ERROR) elif status == 'SIM_ERROR': return evmessage.EvMessage(). \ get_str("MID_SIM_ERROR", evstrings.MID_SIM_ERROR) elif status == 'INTERNAL_ERROR': return evmessage.EvMessage(). \ get_str("MID_INTERNAL_ERROR", evstrings.MID_INTERNAL_ERROR) elif status == 'MID_ERROR_301': return evmessage.EvMessage(). \ get_str("MID_ERROR_301", evstrings.MID_ERROR_301) elif status in ['MID_ERROR_302', 'REVOKED', 'SUSPENDED']: return evmessage.EvMessage(). \ get_str("MID_ERROR_302", evstrings.MID_ERROR_302) elif status in ['MID_ERROR_303', 'NOT_ACTIVATED']: return evmessage.EvMessage(). \ get_str("MID_ERROR_303", evstrings.MID_ERROR_303) elif status == 'MID_POLICY': return evmessage.EvMessage(). \ get_str("MID_POLICY", evstrings.MID_POLICY) return evmessage.EvMessage(). \ get_str("MID_UNKNOWN_ERROR", evstrings.MID_UNKNOWN_ERROR)
def do_import_error_strings(): import evmessage evstrings_file = uiutil.ask_file_name("Sisesta teadete-faili asukoht") evm = evmessage.EvMessage() evm.import_str_file(evstrings_file)
def technical_error(): protocol.http_response(evcommon.VERSION + "\n" + \ evcommon.VERIFY_ERROR + "\n" + \ evmessage.EvMessage().get_str("TECHNICAL_ERROR_VOTE_VERIFICATION", \ evstrings.TECHNICAL_ERROR_VOTE_VERIFICATION))
def pole_valija(self, ik): self.user_code = evcommon.EVOTE_VOTER_ERROR self.user_msg = evmessage.EvMessage().\ get_str("POLE_VALIJA", evstrings.POLE_VALIJA) self.log_msg = \ 'Isikukood %s ei kuulu ühegi hääletuse valijate nimekirja' % ik
def __init__(self, logit=None): self.user_code = evcommon.EVOTE_ERROR self.user_msg = evmessage.EvMessage().\ get_str("TEHNILINE_VIGA", evstrings.TEHNILINE_VIGA) self.log_msg = logit