Eluza133 commited on
Commit
94c0f58
·
verified ·
1 Parent(s): 48cc5e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -23
app.py CHANGED
@@ -315,7 +315,7 @@ def register():
315
  data = load_data()
316
 
317
  if username in data['users']:
318
- flash('Пользователь уже существует!')
319
  return redirect(url_for('register'))
320
 
321
  if 'register_seller' in request.form and user_type == 'seller':
@@ -325,7 +325,7 @@ def register():
325
  org_address = request.form.get('org_address') if not is_online else None
326
 
327
  if not org_name or not org_phone:
328
- flash('Укажите название организации и рабочий номер!')
329
  return redirect(url_for('register'))
330
 
331
  data['users'][username] = {
@@ -345,7 +345,7 @@ def register():
345
  'submitted_at': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
346
  })
347
  save_data(data)
348
- flash('Регистрация успешна! Ваша организация на проверке, мы с вами свяжемся.')
349
  return redirect(url_for('login'))
350
  elif 'register_buyer' in request.form and user_type == 'buyer':
351
  data['users'][username] = {
@@ -357,10 +357,10 @@ def register():
357
  'verified': True
358
  }
359
  save_data(data)
360
- flash('Регистрация успешна! Войдите в систему.')
361
  return redirect(url_for('login'))
362
  else:
363
- flash('Выберите тип пользователя и нажмите соответствующую кнопку!')
364
  return redirect(url_for('register'))
365
 
366
  is_authenticated = 'username' in session
@@ -396,12 +396,17 @@ def register():
396
  color: transparent;
397
  }
398
  .flash {
399
- color: var(--secondary);
400
  text-align: center;
401
  margin-bottom: 20px;
402
  font-size: 1.1em;
403
  font-weight: 500;
404
  }
 
 
 
 
 
 
405
  .link {
406
  text-align: center;
407
  margin-top: 25px;
@@ -431,10 +436,10 @@ def register():
431
  <button class="theme-toggle" onclick="toggleTheme()">🌙</button>
432
  <div class="container">
433
  <h1>Регистрация</h1>
434
- {% with messages = get_flashed_messages() %}
435
  {% if messages %}
436
- {% for message in messages %}
437
- <div class="flash">{{ message }}</div>
438
  {% endfor %}
439
  {% endif %}
440
  {% endwith %}
@@ -494,7 +499,7 @@ def login():
494
  session['username'] = username
495
  session.permanent = True
496
  return redirect(url_for('feed'))
497
- flash('Неверный логин или пароль!')
498
  return redirect(url_for('login'))
499
 
500
  is_authenticated = 'username' in session
@@ -530,12 +535,17 @@ def login():
530
  color: transparent;
531
  }
532
  .flash {
533
- color: var(--secondary);
534
  text-align: center;
535
  margin-bottom: 20px;
536
  font-size: 1.1em;
537
  font-weight: 500;
538
  }
 
 
 
 
 
 
539
  .link {
540
  text-align: center;
541
  margin-top: 25px;
@@ -554,10 +564,10 @@ def login():
554
  <button class="theme-toggle" onclick="toggleTheme()">🌙</button>
555
  <div class="container">
556
  <h1>Вход</h1>
557
- {% with messages = get_flashed_messages() %}
558
  {% if messages %}
559
- {% for message in messages %}
560
- <div class="flash">{{ message }}</div>
561
  {% endfor %}
562
  {% endif %}
563
  {% endwith %}
@@ -925,7 +935,7 @@ def post_page(post_id):
925
  @app.route('/profile', methods=['GET', 'POST'])
926
  def profile():
927
  if 'username' not in session:
928
- flash('Войдите, чтобы просмотреть профиль!')
929
  return redirect(url_for('login'))
930
 
931
  data = load_data()
@@ -1346,14 +1356,14 @@ def user_profile(username):
1346
  @app.route('/upload', methods=['GET', 'POST'])
1347
  def upload():
1348
  if 'username' not in session:
1349
- flash('Войдите, чтобы загрузить контент!')
1350
  return redirect(url_for('login'))
1351
 
1352
  data = load_data()
1353
  username = session['username']
1354
  user_data = data['users'].get(username, {})
1355
  if user_data.get('type') != 'seller' or not user_data.get('verified'):
1356
- flash('Только проверенные продавцы могут загружать видео!')
1357
  return redirect(url_for('profile'))
1358
 
1359
  if request.method == 'POST':
@@ -1365,11 +1375,11 @@ def upload():
1365
  uploader = session['username']
1366
 
1367
  if not title or not price or not currency or not file:
1368
- flash('Укажите название, цену, валюту и выберите видео!')
1369
  return redirect(url_for('upload'))
1370
 
1371
  if not file.filename.lower().endswith(('.mp4', '.mov', '.avi')):
1372
- flash('Загружайте только видео файлы (mp4, mov, avi)!')
1373
  return redirect(url_for('upload'))
1374
 
1375
  filename = secure_filename(file.filename)
@@ -1460,12 +1470,17 @@ def upload():
1460
  transition: width 0.4s ease;
1461
  }
1462
  .flash {
1463
- color: var(--secondary);
1464
  text-align: center;
1465
  margin-bottom: 20px;
1466
  font-size: 1.1em;
1467
  font-weight: 500;
1468
  }
 
 
 
 
 
 
1469
  </style>
1470
  </head>
1471
  <body>
@@ -1474,10 +1489,10 @@ def upload():
1474
  <button class="theme-toggle" onclick="toggleTheme()">🌙</button>
1475
  <div class="container">
1476
  <h1>Загрузить видео</h1>
1477
- {% with messages = get_flashed_messages() %}
1478
  {% if messages %}
1479
- {% for message in messages %}
1480
- <div class="flash">{{ message }}</div>
1481
  {% endfor %}
1482
  {% endif %}
1483
  {% endwith %}
 
315
  data = load_data()
316
 
317
  if username in data['users']:
318
+ flash('Пользователь уже существует!', 'error')
319
  return redirect(url_for('register'))
320
 
321
  if 'register_seller' in request.form and user_type == 'seller':
 
325
  org_address = request.form.get('org_address') if not is_online else None
326
 
327
  if not org_name or not org_phone:
328
+ flash('Укажите название организации и рабочий номер!', 'error')
329
  return redirect(url_for('register'))
330
 
331
  data['users'][username] = {
 
345
  'submitted_at': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
346
  })
347
  save_data(data)
348
+ flash('Ваша заявка принята, мы с вами свяжемся в течение 2 суток.', 'success')
349
  return redirect(url_for('login'))
350
  elif 'register_buyer' in request.form and user_type == 'buyer':
351
  data['users'][username] = {
 
357
  'verified': True
358
  }
359
  save_data(data)
360
+ flash('Регистрация успешна! Войдите в систему.', 'success')
361
  return redirect(url_for('login'))
362
  else:
363
+ flash('Выберите тип пользователя и нажмите соответствующую кнопку!', 'error')
364
  return redirect(url_for('register'))
365
 
366
  is_authenticated = 'username' in session
 
396
  color: transparent;
397
  }
398
  .flash {
 
399
  text-align: center;
400
  margin-bottom: 20px;
401
  font-size: 1.1em;
402
  font-weight: 500;
403
  }
404
+ .flash.success {
405
+ color: #10b981;
406
+ }
407
+ .flash.error {
408
+ color: var(--secondary);
409
+ }
410
  .link {
411
  text-align: center;
412
  margin-top: 25px;
 
436
  <button class="theme-toggle" onclick="toggleTheme()">🌙</button>
437
  <div class="container">
438
  <h1>Регистрация</h1>
439
+ {% with messages = get_flashed_messages(with_categories=true) %}
440
  {% if messages %}
441
+ {% for category, message in messages %}
442
+ <div class="flash {{ category }}">{{ message }}</div>
443
  {% endfor %}
444
  {% endif %}
445
  {% endwith %}
 
499
  session['username'] = username
500
  session.permanent = True
501
  return redirect(url_for('feed'))
502
+ flash('Неверный логин или пароль!', 'error')
503
  return redirect(url_for('login'))
504
 
505
  is_authenticated = 'username' in session
 
535
  color: transparent;
536
  }
537
  .flash {
 
538
  text-align: center;
539
  margin-bottom: 20px;
540
  font-size: 1.1em;
541
  font-weight: 500;
542
  }
543
+ .flash.success {
544
+ color: #10b981;
545
+ }
546
+ .flash.error {
547
+ color: var(--secondary);
548
+ }
549
  .link {
550
  text-align: center;
551
  margin-top: 25px;
 
564
  <button class="theme-toggle" onclick="toggleTheme()">🌙</button>
565
  <div class="container">
566
  <h1>Вход</h1>
567
+ {% with messages = get_flashed_messages(with_categories=true) %}
568
  {% if messages %}
569
+ {% for category, message in messages %}
570
+ <div class="flash {{ category }}">{{ message }}</div>
571
  {% endfor %}
572
  {% endif %}
573
  {% endwith %}
 
935
  @app.route('/profile', methods=['GET', 'POST'])
936
  def profile():
937
  if 'username' not in session:
938
+ flash('Войдите, чтобы просмотреть профиль!', 'error')
939
  return redirect(url_for('login'))
940
 
941
  data = load_data()
 
1356
  @app.route('/upload', methods=['GET', 'POST'])
1357
  def upload():
1358
  if 'username' not in session:
1359
+ flash('Войдите, чтобы загрузить контент!', 'error')
1360
  return redirect(url_for('login'))
1361
 
1362
  data = load_data()
1363
  username = session['username']
1364
  user_data = data['users'].get(username, {})
1365
  if user_data.get('type') != 'seller' or not user_data.get('verified'):
1366
+ flash('Только проверенные продавцы могут загружать видео!', 'error')
1367
  return redirect(url_for('profile'))
1368
 
1369
  if request.method == 'POST':
 
1375
  uploader = session['username']
1376
 
1377
  if not title or not price or not currency or not file:
1378
+ flash('Укажите название, цену, валюту и выберите видео!', 'error')
1379
  return redirect(url_for('upload'))
1380
 
1381
  if not file.filename.lower().endswith(('.mp4', '.mov', '.avi')):
1382
+ flash('Загружайте только видео файлы (mp4, mov, avi)!', 'error')
1383
  return redirect(url_for('upload'))
1384
 
1385
  filename = secure_filename(file.filename)
 
1470
  transition: width 0.4s ease;
1471
  }
1472
  .flash {
 
1473
  text-align: center;
1474
  margin-bottom: 20px;
1475
  font-size: 1.1em;
1476
  font-weight: 500;
1477
  }
1478
+ .flash.success {
1479
+ color: #10b981;
1480
+ }
1481
+ .flash.error {
1482
+ color: var(--secondary);
1483
+ }
1484
  </style>
1485
  </head>
1486
  <body>
 
1489
  <button class="theme-toggle" onclick="toggleTheme()">🌙</button>
1490
  <div class="container">
1491
  <h1>Загрузить видео</h1>
1492
+ {% with messages = get_flashed_messages(with_categories=true) %}
1493
  {% if messages %}
1494
+ {% for category, message in messages %}
1495
+ <div class="flash {{ category }}">{{ message }}</div>
1496
  {% endfor %}
1497
  {% endif %}
1498
  {% endwith %}