интерфейсные правки для auto_unit
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2025-10-12 18:03:22 +03:00
parent a8c9d158aa
commit 8777426756
3 changed files with 72 additions and 6 deletions
+30 -6
View File
@@ -113,7 +113,7 @@ class DatabaseManager:
with self.conn.cursor() as cursor:
cursor.execute("""
SELECT id, vk_post_id, shortname, text, published_at,
marked_for_publication, published_in_tg, is_event, is_poll, action_number
marked_for_publication, published_in_tg, is_event, is_poll, action_number, auto_unit
FROM posts
ORDER BY published_at DESC
""")
@@ -141,6 +141,17 @@ class DatabaseManager:
cursor.execute("SELECT * FROM events WHERE id = %s", (event_id,))
return cursor.fetchone()
def get_venues(self):
"""Получает список всех уникальных площадок из таблицы events"""
with self.conn.cursor() as cursor:
cursor.execute("""
SELECT DISTINCT unit_name
FROM events
WHERE unit_name IS NOT NULL AND unit_name != ''
ORDER BY unit_name
""")
return cursor.fetchall()
def toggle_event_publication(self, event_id):
with self.conn.cursor() as cursor:
cursor.execute("""
@@ -305,8 +316,8 @@ class DatabaseManager:
vk_post_id, shortname, text, image_url, vk_post_url, published_at,
is_event, is_poll, poll_question, poll_options, poll_multiple, poll_end_date,
marked_for_publication, published_in_tg, tg_publication_date, tg_message_id,
tg_poll_id, tg_markpost_id, tg_poll_results, action_number
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
tg_poll_id, tg_markpost_id, tg_poll_results, action_number, auto_unit
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
"""
values = (
clean_int(data['vk_post_id']),
@@ -328,7 +339,8 @@ class DatabaseManager:
clean_int(data.get('tg_poll_id', '')),
clean_int(data.get('tg_markpost_id', '')),
data.get('tg_poll_results', ''),
clean_int(data.get('action_number', ''))
clean_int(data.get('action_number', '')),
data.get('auto_unit', '')
)
cursor.execute(query, values)
self.conn.commit()
@@ -354,7 +366,7 @@ class DatabaseManager:
published_at = %s, is_event = %s, is_poll = %s, poll_question = %s, poll_options = %s,
poll_multiple = %s, poll_end_date = %s, marked_for_publication = %s,
published_in_tg = %s, tg_publication_date = %s, tg_message_id = %s,
tg_poll_id = %s, tg_markpost_id = %s, tg_poll_results = %s, action_number = %s
tg_poll_id = %s, tg_markpost_id = %s, tg_poll_results = %s, action_number = %s, auto_unit = %s
WHERE id = %s
"""
values = (
@@ -378,6 +390,7 @@ class DatabaseManager:
clean_int(data.get('tg_markpost_id', '')),
data.get('tg_poll_results', ''),
clean_int(data.get('action_number', '')),
data.get('auto_unit', ''),
post_id
)
cursor.execute(query, values)
@@ -597,6 +610,16 @@ def logout():
log_event(f"Пользователь {username} вышел из системы с IP {client_ip}")
return redirect(url_for('zilant.login'))
@bp.route('/api/venues')
@login_required
def api_venues():
db = get_db()
try:
venues = db.get_venues()
return jsonify(venues)
finally:
db.close()
@bp.route('/api/posts')
@login_required
def api_posts():
@@ -615,7 +638,8 @@ def api_posts():
'published_in_tg': bool(post['published_in_tg']),
'is_event': bool(post['is_event']),
'is_poll': bool(post['is_poll']),
'action_number': post['action_number']
'action_number': post['action_number'],
'auto_unit': post['auto_unit']
})
return jsonify(posts_list)
finally: