test
This commit is contained in:
Generated
+3
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.8 (tgflaskform)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (tgFlaskForm)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/tgflaskform.iml" filepath="$PROJECT_DIR$/.idea/tgflaskform.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.8 (tgFlaskForm)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[WEB_APP]
|
||||
PORT = 8084
|
||||
template_folder = C:\TgBotPage\webApp\templates
|
||||
template_folder = C:\Users\ilyac\PycharmProjects\tgFlaskForm\webApp\templates
|
||||
environment = test
|
||||
[GOOGLE]
|
||||
type = service_account
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,4 +13,9 @@ def send_css(path):
|
||||
def send_js(path):
|
||||
resp = make_response(send_from_directory(os.path.join(config['WEB_APP']['template_folder'], 'static/js'), path), 200)
|
||||
resp.headers['Cache-Control'] = 'public, max-age=31536000'
|
||||
return resp
|
||||
return resp
|
||||
|
||||
|
||||
@webApp.route('/pic/<path:path>')
|
||||
def send_pic(path):
|
||||
return send_from_directory(os.path.join(config['WEB_APP']['template_folder'], 'static/pics'), path), 200
|
||||
@@ -19,13 +19,15 @@ def authorize_google():
|
||||
return client
|
||||
|
||||
# Функция проверки существования пользователя в таблице
|
||||
def user_exists(sheet, fio, tel): #, user_id):
|
||||
def user_exists(sheet, fio, tel, user_id):
|
||||
records = sheet.get_all_values() # Получаем все данные таблицы без заголовков
|
||||
|
||||
for row in records[1:]: # Пропускаем первую строку, если там заголовки, или уберите [1:], если заголовков нет
|
||||
if len(row) > 1 and row[0] == fio and row[1] == tel:# and row[13] == user_id:
|
||||
return True # Если ФИО, телефон и user_id совпадают, значит, запись уже существует
|
||||
return False
|
||||
return True, 'Ваши данные уже присутствуют в таблице' # Если ФИО, телефон и user_id совпадают, значит, запись уже существует
|
||||
if row[13] == user_id:
|
||||
return True, 'C данного Telegram аккаунта уже проведена регистрация'
|
||||
return False, 'Ок'
|
||||
|
||||
|
||||
# Обработка формы
|
||||
@@ -39,8 +41,9 @@ def form_submit():
|
||||
sheet = authorize_google().open("Информация о сотрудниках").sheet1
|
||||
|
||||
# Проверка, существует ли уже пользователь
|
||||
if user_exists(sheet, data['fio'], data['tel']): #, data['user_id']):
|
||||
return jsonify({'success': False, 'error': 'Ваши данные уже присутствуют в таблице'}), 400
|
||||
exists_flag, message = user_exists(sheet, data['fio'], data['tel'], data['user_id'])
|
||||
if exists_flag:
|
||||
return jsonify({'success': False, 'error': message})
|
||||
|
||||
sheet.append_row([
|
||||
data['fio'],
|
||||
|
||||
@@ -106,7 +106,7 @@ $(document).ready(function(){
|
||||
const ageAtPassportIssue = passportDate.getFullYear() - dob.getFullYear();
|
||||
|
||||
// Проверка на возраст, в котором может быть выдан паспорт
|
||||
if (ageAtPassportIssue === 14 || ageAtPassportIssue === 20 || ageAtPassportIssue === 45) {
|
||||
if (ageAtPassportIssue > 12) {
|
||||
// Если возраст при выдаче паспорта соответствует требованиям, подсвечиваем ячейку как успешную
|
||||
$(this).parent().removeClass('errors-field').addClass('success-field');
|
||||
} else {
|
||||
@@ -282,8 +282,8 @@ $(document).ready(function(){
|
||||
return;
|
||||
}
|
||||
|
||||
if ($('#passport_date').val().length !== 10 || ![14, 20, 45].includes(new Date($('#passport_date').val()).getFullYear() - new Date($('#dob').val()).getFullYear())) {
|
||||
show_error('Дата выдачи паспорта должна быть в 14, 20 или 45 лет', false);
|
||||
if ($('#passport_date').val().length !== 10 || (new Date($('#passport_date').val()).getFullYear() - new Date($('#dob').val()).getFullYear()) < 13) {
|
||||
show_error('Проверьте дату выдачи паспорта, паспорт РФ может быть выдан с 14 лет', false);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
return;
|
||||
@@ -350,10 +350,17 @@ $(document).ready(function(){
|
||||
async: true,
|
||||
data: JSON.stringify(message),
|
||||
success: (data) => {
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
console.log(data);
|
||||
show_success("Данные сохранены!")
|
||||
if(data.success==true){
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
console.log(data);
|
||||
show_success("Данные сохранены!")
|
||||
}
|
||||
else{
|
||||
show_error(data.error);
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
$(this).removeAttr("disabled");
|
||||
}
|
||||
},
|
||||
error:function (jqXHR, exception) {
|
||||
$(this).children(".spinner-border").addClass('d-none');
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -5,4 +5,4 @@ from config import config
|
||||
|
||||
if __name__ == '__main__':
|
||||
webApp.run(debug=True, port=config['WEB_APP']['PORT'])
|
||||
#serve(webApp, host='0.0.0.0', port=config['WEB_APP']['PORT'])
|
||||
#serve(webApp, host='0.0.0.0', port=config['WEB_APP']['PORT'])
|
||||
|
||||
Reference in New Issue
Block a user