unread notifs
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,9 +1,18 @@
|
||||
from flask import render_template, request, flash, redirect, url_for
|
||||
from flask import render_template, request, flash, redirect, url_for, Blueprint, jsonify
|
||||
from flask_login import login_user, logout_user, login_required, current_user
|
||||
from models import db, User
|
||||
from models import db, User, Notif
|
||||
from functools import wraps
|
||||
from datetime import datetime
|
||||
from utils import log_event, create_notification
|
||||
from utils import log_event, create_notification, get_unread_count
|
||||
|
||||
auth_bp = Blueprint('auth', __name__)
|
||||
|
||||
@auth_bp.context_processor
|
||||
def inject_unread_notifications():
|
||||
if current_user.is_authenticated:
|
||||
unread_count = get_unread_count(current_user.id)
|
||||
return {'unread_notifications': unread_count}
|
||||
return {'unread_notifications': 0}
|
||||
|
||||
def require_password_change(f):
|
||||
@wraps(f)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash, request
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash, request, jsonify
|
||||
from flask_login import login_required, current_user
|
||||
from models import db, User
|
||||
from models import db, User, Notif
|
||||
from forms import UserForm
|
||||
from flask import abort
|
||||
from sqlalchemy import or_
|
||||
from routes.auth import require_password_change
|
||||
from utils import log_event, create_notification
|
||||
from utils import log_event, create_notification, get_unread_count
|
||||
import json
|
||||
import os
|
||||
from werkzeug.utils import secure_filename
|
||||
@@ -17,6 +17,13 @@ UPLOAD_FOLDER = os.path.join(os.getcwd(), 'uploads', 'profile_pics')
|
||||
if not os.path.exists(UPLOAD_FOLDER):
|
||||
os.makedirs(UPLOAD_FOLDER)
|
||||
|
||||
@contacts_bp.context_processor
|
||||
def inject_unread_notifications():
|
||||
if current_user.is_authenticated:
|
||||
unread_count = get_unread_count(current_user.id)
|
||||
return {'unread_notifications': unread_count}
|
||||
return {'unread_notifications': 0}
|
||||
|
||||
def admin_required():
|
||||
if not current_user.is_authenticated:
|
||||
return redirect(url_for('auth.login'))
|
||||
|
||||
@@ -3,7 +3,7 @@ from flask_login import login_required, current_user
|
||||
from models import db, Conversation, User, Message, MessageAttachment
|
||||
from forms import ConversationForm
|
||||
from routes.auth import require_password_change
|
||||
from utils import log_event, create_notification
|
||||
from utils import log_event, create_notification, get_unread_count
|
||||
import os
|
||||
from werkzeug.utils import secure_filename
|
||||
from datetime import datetime
|
||||
@@ -54,7 +54,8 @@ def conversations():
|
||||
if search:
|
||||
query = query.filter(Conversation.name.ilike(f'%{search}%'))
|
||||
conversations = query.order_by(Conversation.created_at.desc()).all()
|
||||
return render_template('conversations/conversations.html', conversations=conversations, search=search)
|
||||
unread_count = get_unread_count(current_user.id)
|
||||
return render_template('conversations/conversations.html', conversations=conversations, search=search, unread_notifications=unread_count)
|
||||
|
||||
@conversations_bp.route('/create', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
|
||||
@@ -10,7 +10,7 @@ import logging
|
||||
import sys
|
||||
import time
|
||||
from forms import CompanySettingsForm
|
||||
from utils import log_event, create_notification
|
||||
from utils import log_event, create_notification, get_unread_count
|
||||
|
||||
# Set up logging to show in console
|
||||
logging.basicConfig(
|
||||
@@ -28,6 +28,13 @@ def init_routes(main_bp):
|
||||
site_settings = SiteSettings.query.first()
|
||||
return dict(site_settings=site_settings)
|
||||
|
||||
@main_bp.context_processor
|
||||
def inject_unread_notifications():
|
||||
if current_user.is_authenticated:
|
||||
unread_count = get_unread_count(current_user.id)
|
||||
return {'unread_notifications': unread_count}
|
||||
return {'unread_notifications': 0}
|
||||
|
||||
@main_bp.route('/')
|
||||
@login_required
|
||||
@require_password_change
|
||||
|
||||
@@ -22,14 +22,14 @@ to maintain file metadata and content.
|
||||
from flask import Blueprint, jsonify, request, abort, send_from_directory, send_file
|
||||
from flask_login import login_required, current_user
|
||||
import os
|
||||
from models import Room, RoomMemberPermission, RoomFile, TrashedFile, db
|
||||
from models import Room, RoomMemberPermission, RoomFile, TrashedFile, db, User, Notif
|
||||
from werkzeug.utils import secure_filename, safe_join
|
||||
import time
|
||||
import shutil
|
||||
import io
|
||||
import zipfile
|
||||
from datetime import datetime
|
||||
from utils import log_event
|
||||
from utils import log_event, create_notification, get_unread_count
|
||||
|
||||
# Blueprint for room file operations
|
||||
room_files_bp = Blueprint('room_files', __name__, url_prefix='/api/rooms')
|
||||
@@ -61,6 +61,13 @@ ALLOWED_EXTENSIONS = {
|
||||
'eml', 'msg', 'vcf', 'ics'
|
||||
}
|
||||
|
||||
@room_files_bp.context_processor
|
||||
def inject_unread_notifications():
|
||||
if current_user.is_authenticated:
|
||||
unread_count = get_unread_count(current_user.id)
|
||||
return {'unread_notifications': unread_count}
|
||||
return {'unread_notifications': 0}
|
||||
|
||||
def get_room_dir(room_id):
|
||||
"""
|
||||
Get the absolute path to a room's directory.
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
from flask import Blueprint, jsonify, request, abort
|
||||
from flask import Blueprint, jsonify, request, abort, render_template, redirect, url_for, flash
|
||||
from flask_login import login_required, current_user
|
||||
from models import db, Room, User, RoomMemberPermission
|
||||
from utils import user_has_permission, log_event, create_notification
|
||||
from models import db, Room, User, RoomMemberPermission, Notif
|
||||
from utils import user_has_permission, log_event, create_notification, get_unread_count
|
||||
from routes.auth import require_password_change
|
||||
from datetime import datetime
|
||||
|
||||
room_members_bp = Blueprint('room_members', __name__)
|
||||
room_members_bp = Blueprint('room_members', __name__, url_prefix='/api/rooms')
|
||||
|
||||
@room_members_bp.context_processor
|
||||
def inject_unread_notifications():
|
||||
if current_user.is_authenticated:
|
||||
unread_count = get_unread_count(current_user.id)
|
||||
return {'unread_notifications': unread_count}
|
||||
return {'unread_notifications': 0}
|
||||
|
||||
@room_members_bp.route('/<int:room_id>/members', methods=['GET'])
|
||||
@login_required
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash, request
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash, request, jsonify
|
||||
from flask_login import login_required, current_user
|
||||
from models import db, Room, User, RoomMemberPermission, RoomFile
|
||||
from models import db, Room, User, RoomMemberPermission, RoomFile, Notif
|
||||
from forms import RoomForm
|
||||
from routes.room_files import user_has_permission
|
||||
from routes.auth import require_password_change
|
||||
from utils import log_event, create_notification
|
||||
from utils import log_event, create_notification, get_unread_count
|
||||
import os
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
|
||||
rooms_bp = Blueprint('rooms', __name__, url_prefix='/rooms')
|
||||
|
||||
@rooms_bp.context_processor
|
||||
def inject_unread_notifications():
|
||||
if current_user.is_authenticated:
|
||||
unread_count = get_unread_count(current_user.id)
|
||||
return {'unread_notifications': unread_count}
|
||||
return {'unread_notifications': 0}
|
||||
|
||||
@rooms_bp.route('/')
|
||||
@login_required
|
||||
@require_password_change
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
from flask import Blueprint, jsonify, request, abort
|
||||
from flask import Blueprint, jsonify, request, abort, render_template, redirect, url_for, flash
|
||||
from flask_login import login_required, current_user
|
||||
from models import db, Room, RoomFile, TrashedFile, UserStarredFile
|
||||
from utils import user_has_permission, clean_path, log_event
|
||||
from models import db, Room, RoomFile, TrashedFile, UserStarredFile, Notif
|
||||
from routes.auth import require_password_change
|
||||
from utils import user_has_permission, clean_path, log_event, create_notification, get_unread_count
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
trash_bp = Blueprint('trash', __name__)
|
||||
trash_bp = Blueprint('trash', __name__, url_prefix='/trash')
|
||||
|
||||
@trash_bp.context_processor
|
||||
def inject_unread_notifications():
|
||||
if current_user.is_authenticated:
|
||||
unread_count = get_unread_count(current_user.id)
|
||||
return {'unread_notifications': unread_count}
|
||||
return {'unread_notifications': 0}
|
||||
|
||||
@trash_bp.route('/<int:room_id>/trash', methods=['GET'])
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user