def __kylm_ennistamine(self, input_list, good_list, bad_list, action_list): for el in input_list: code = el[0] if not self.haaletanud(code): bad_list.append(el) evlog.log_error('Isik koodiga %s ei ole hääletanud' % code) continue user_key = htscommon.get_user_key(code) vc = htscommon.VoteCounter() revoked_key = '' for vote_file in self._reg.list_keys(user_key): if htscommon.VALID_VOTE_PATTERN.match(vote_file): vc.inc_valid() elif htscommon.USERREVOKED_VOTE_PATTERN.match(vote_file): vc.inc_userrevoked() revoked_key = vote_file elif htscommon.AUTOREVOKED_VOTE_PATTERN.match(vote_file): pass elif htscommon.REVOKE_REASON_PATTERN.match(vote_file): pass else: vc.inc_unknown() if ((vc.userrevoked() == 0) or (vc.valid() > 0)): bad_list.append(el) evlog.log_error(\ 'Isik koodiga %s ei ole oma häält tühistanud' % code) continue if (vc.userrevoked() > 1): self._errmsg = 'Serveri andmestruktuurid ei ole kooskõlalised' raise Exception(self._errmsg) if (vc.unknown() > 0): self._errmsg = 'Tundmatu viga häälte tühistamisel' raise Exception(self._errmsg) if (vc.userrevoked() == 1): valid_key = \ htscommon.change_votefile_name(\ revoked_key, htscommon.BVALID) act = ActionInfo() act.set_old_name(self._reg.path(user_key + [revoked_key])) act.set_new_name(self._reg.path(user_key + [valid_key])) act.set_reason_name(self._reg.path(user_key + ['reason'])) act.set_timestamp(htscommon.get_votefile_time(revoked_key)) act.set_code(el[0]) act.set_name(el[1]) act.set_reason(el[2]) good_list.append(el) action_list.append(act)
def __kylm_tyhistamine(self, input_list, good_list, bad_list, action_list): for el in input_list: code = el[0] if not self.haaletanud(code): bad_list.append(el) evlog.log_error('Isik koodiga %s ei ole hääletanud' % code) continue user_key = htscommon.get_user_key(code) vc = htscommon.VoteCounter() valid_key = '' for vote_file in self._reg.list_keys(user_key): if htscommon.VALID_VOTE_PATTERN.match(vote_file): vc.inc_valid() valid_key = vote_file elif htscommon.USERREVOKED_VOTE_PATTERN.match(vote_file): vc.inc_userrevoked() elif htscommon.AUTOREVOKED_VOTE_PATTERN.match(vote_file): pass elif htscommon.REVOKE_REASON_PATTERN.match(vote_file): pass else: vc.inc_unknown() if (vc.valid() > 1): self._errmsg = 'Serveri andmestruktuurid ei ole kooskõlalised' raise Exception(self._errmsg) if ((vc.valid() == 0) or (vc.userrevoked() > 0)): bad_list.append(el) evlog.log_error(\ 'Kasutaja isikukoodiga %s hääl on juba tühistatud' % \ code) if (vc.unknown() > 0): self._errmsg = 'Tundmatu viga häälte tühistamisel' raise Exception(self._errmsg) if (vc.valid() == 1): revoked_key = \ htscommon.change_votefile_name(\ valid_key, htscommon.BUSERREVOKED) act = ActionInfo() act.set_old_name(self._reg.path(user_key + [valid_key])) act.set_new_name(self._reg.path(user_key + [revoked_key])) act.set_reason_name(self._reg.path(user_key)) act.set_timestamp(htscommon.get_votefile_time(valid_key)) act.set_code(el[0]) act.set_name(el[1]) act.set_reason(el[2]) good_list.append(el) action_list.append(act)
def __kylm_tyhistamine(self, input_list, good_list, bad_list, action_list): for el in input_list: code = el[0] if not self.haaletanud(code): bad_list.append(el) evlog.log_error("Isik koodiga %s ei ole hääletanud" % code) continue user_key = htscommon.get_user_key(code) vc = htscommon.VoteCounter() valid_key = "" for vote_file in self._reg.list_keys(user_key): if htscommon.VALID_VOTE_PATTERN.match(vote_file): vc.inc_valid() valid_key = vote_file elif htscommon.USERREVOKED_VOTE_PATTERN.match(vote_file): vc.inc_userrevoked() elif htscommon.AUTOREVOKED_VOTE_PATTERN.match(vote_file): pass elif htscommon.REVOKE_REASON_PATTERN.match(vote_file): pass elif htscommon.VOTE_VERIFICATION_ID_FILENAME == vote_file: pass else: vc.inc_unknown() if vc.valid() > 1: self._errmsg = "Serveri andmestruktuurid ei ole kooskõlalised" raise Exception(self._errmsg) if (vc.valid() == 0) or (vc.userrevoked() > 0): bad_list.append(el) evlog.log_error("Kasutaja isikukoodiga %s hääl on juba tühistatud" % code) if vc.unknown() > 0: self._errmsg = "Tundmatu viga häälte tühistamisel" raise Exception(self._errmsg) if vc.valid() == 1: revoked_key = htscommon.change_votefile_name(valid_key, htscommon.BUSERREVOKED) act = ActionInfo() act.set_old_name(self._reg.path(user_key + [valid_key])) act.set_new_name(self._reg.path(user_key + [revoked_key])) act.set_reason_name(self._reg.path(user_key)) act.set_timestamp(htscommon.get_votefile_time(valid_key)) act.set_code(el[0]) act.set_name(el[1]) act.set_reason(el[2]) good_list.append(el) action_list.append(act)
def __tyhista_korduv_haal(self, code, haale_rasi): user_key = htscommon.get_user_key(code) if not self._reg.check(user_key): return flist = self._reg.list_keys(user_key) for elem in flist: if htscommon.VALID_VOTE_PATTERN.match(elem): rev_name = htscommon.change_votefile_name(\ elem, htscommon.BAUTOREVOKED) old_name = self._reg.path(user_key + [elem]) new_name = self._reg.path(user_key + [rev_name]) bdoc = bdocpythonutils.BDocContainer() bdoc.load(old_name) profile = bdocpythonutils.ManifestProfile('TM') bdoc.validate(profile) vote = bdoc.documents["%s.evote" % self._elid] voter = htscommon.get_votefile_voter(elem) vote_time = htscommon.get_votefile_time(elem) # logimine self._log2.log_info( tyyp=2, haal_rasi=ksum.votehash(vote), jaoskond=voter['jaoskond'], jaoskond_omavalitsus=voter['jaoskond_omavalitsus'], ringkond=voter['ringkond'], ringkond_omavalitsus=voter['ringkond_omavalitsus'], isikukood=code, pohjus='korduv e-hääl: ' + haale_rasi) self._revlog.log_info( tegevus='korduv e-hääl', isikukood=code, nimi=voter['nimi'], timestamp=vote_time, operaator='', pohjus=haale_rasi) os.rename(old_name, new_name)
def __tyhista_korduv_haal(self, code, haale_rasi): user_key = htscommon.get_user_key(code) if not self._reg.check(user_key): return flist = self._reg.list_keys(user_key) for elem in flist: if htscommon.VALID_VOTE_PATTERN.match(elem): rev_name = htscommon.change_votefile_name(\ elem, htscommon.BAUTOREVOKED) old_name = self._reg.path(user_key + [elem]) new_name = self._reg.path(user_key + [rev_name]) bdoc = bdocpythonutils.BDocContainer() bdoc.load(old_name) profile = bdocpythonutils.ManifestProfile('TM') bdoc.validate(profile) vote = bdoc.documents["%s.evote" % self._elid] voter = htscommon.get_votefile_voter(elem) vote_time = htscommon.get_votefile_time(elem) # logimine self._log2.log_info( tyyp=2, haal_rasi=ksum.votehash(vote), jaoskond=voter['jaoskond'], jaoskond_omavalitsus=voter['jaoskond_omavalitsus'], ringkond=voter['ringkond'], ringkond_omavalitsus=voter['ringkond_omavalitsus'], isikukood=code, pohjus='korduv e-hääl: ' + haale_rasi) self._revlog.log_info(tegevus='korduv e-hääl', isikukood=code, nimi=voter['nimi'], timestamp=vote_time, operaator='', pohjus=haale_rasi) os.rename(old_name, new_name)