default agreement text fixed

This commit is contained in:
Volkan Şahin 2016-08-15 11:22:10 +03:00
parent bf37183005
commit acf65a2d5b

View file

@ -24,9 +24,13 @@ class Agreement:
self.logger.debug('[Agreement] There is no any contract in database.') self.logger.debug('[Agreement] There is no any contract in database.')
contract_id = '-1' contract_id = '-1'
if self.db_service.select_one_result('agreement', 'id', " contract_id='{0}' and username='{1}' and choice='Y' ".format(contract_id, username)) is not None: if self.db_service.select_one_result('agreement', 'id',
" contract_id='{0}' and username='{1}' and choice='Y' "
.format(contract_id, username)) is not None:
return True return True
elif self.db_service.select_one_result('agreement', 'id', " contract_id='{0}' and username='{1}' and choice='N' ".format(contract_id, username)) is not None: elif self.db_service.select_one_result('agreement', 'id',
" contract_id='{0}' and username='{1}' and choice='N' ".format(
contract_id, username)) is not None:
return False return False
else: else:
return None return None
@ -42,8 +46,8 @@ class Agreement:
content = 'Ahenk kurulu bu bilgisayarda ilk defa oturum açıyorsunuz. ' \ content = 'Ahenk kurulu bu bilgisayarda ilk defa oturum açıyorsunuz. ' \
'Devam ederseniz Lider-Ahenk in bilgisayar üzeride yapacağı ' \ 'Devam ederseniz Lider-Ahenk in bilgisayar üzeride yapacağı ' \
'tüm işlemlere onay vermiş sayılacaksınız. Kabul ediyor musunuz?' \ 'tüm işlemlere onay vermiş sayılacaksınız. Kabul ediyor musunuz?' \
' \n({} saniye içinde olumlu cevaplandırmadığınız takdirde oturumunuz ' \ ' \n(Tanımlanmış zaman aralığında olumlu cevaplandırmadığınız takdirde oturumunuz ' \
'sonlandırılacaktır.)'.format(10) 'sonlandırılacaktır.)'
title = 'Ahenk Kurulu Bilgisayar Kullanım Anlaşması' title = 'Ahenk Kurulu Bilgisayar Kullanım Anlaşması'
contract_id = '-1' contract_id = '-1'
else: else:
@ -54,21 +58,31 @@ class Agreement:
agreement_path = System.Ahenk.received_dir_path() + Util.generate_uuid() agreement_path = System.Ahenk.received_dir_path() + Util.generate_uuid()
Util.write_file(agreement_path, content) Util.write_file(agreement_path, content)
Util.set_permission(agreement_path, 777) Util.set_permission(agreement_path, 777)
command = 'export DISPLAY={0};su - {1} -c \'python3 {2} \"$(cat {3})\" \"{4}\"\''.format(display, username, self.ask_path, agreement_path, title) command = 'export DISPLAY={0};su - {1} -c \'python3 {2} \"$(cat {3})\" \"{4}\"\''.format(display, username,
self.ask_path,
agreement_path,
title)
result_code, p_out, p_err = Util.execute(command) result_code, p_out, p_err = Util.execute(command)
pout = str(p_out).replace('\n', '') pout = str(p_out).replace('\n', '')
if pout != 'Error': if pout != 'Error':
if pout == 'Y': if pout == 'Y':
self.logger.debug('[Agreement] Agreement was accepted by {}.'.format(username)) self.logger.debug('[Agreement] Agreement was accepted by {}.'.format(username))
self.db_service.update('agreement', self.db_service.get_cols('agreement'), [contract_id, username, Util.timestamp(), 'Y']) self.db_service.update('agreement', self.db_service.get_cols('agreement'),
[contract_id, username, Util.timestamp(), 'Y'])
elif pout == 'N': elif pout == 'N':
self.db_service.update('agreement', self.db_service.get_cols('agreement'), [contract_id, username, Util.timestamp(), 'N']) self.db_service.update('agreement', self.db_service.get_cols('agreement'),
self.logger.debug('[Agreement] Agreement was ignored by {}. Session will be closed'.format(username)) [contract_id, username, Util.timestamp(), 'N'])
self.logger.debug(
'[Agreement] Agreement was ignored by {}. Session will be closed'.format(username))
else: else:
self.logger.error('[Agreement] A problem occurred while executing ask.py. Error Message: {}'.format(str(pout))) self.logger.error(
'[Agreement] A problem occurred while executing ask.py. Error Message: {}'.format(str(pout)))
Util.delete_file(agreement_path) Util.delete_file(agreement_path)
else: else:
self.logger.error('[Agreement] A problem occurred while executing ask.py (Probably argument fault). Error Message: {}'.format(str(pout))) self.logger.error(
'[Agreement] A problem occurred while executing ask.py (Probably argument fault). Error Message: {}'.format(
str(pout)))
except Exception as e: except Exception as e:
self.logger.error('[Agreement] A Problem occurred while displaying agreement. Error Message: {}'.format(str(e))) self.logger.error(
'[Agreement] A Problem occurred while displaying agreement. Error Message: {}'.format(str(e)))