first part of master_slave relation
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from flask import Blueprint, Flask, render_template
|
from flask import Blueprint, Flask, render_template
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
from models import SiteSettings
|
from models import SiteSettings
|
||||||
|
import os
|
||||||
|
|
||||||
def init_app(app: Flask):
|
def init_app(app: Flask):
|
||||||
# Create blueprints
|
# Create blueprints
|
||||||
@@ -28,6 +29,11 @@ def init_app(app: Flask):
|
|||||||
site_settings = SiteSettings.query.first()
|
site_settings = SiteSettings.query.first()
|
||||||
return dict(site_settings=site_settings)
|
return dict(site_settings=site_settings)
|
||||||
|
|
||||||
|
# Add MASTER environment variable to all templates
|
||||||
|
@app.context_processor
|
||||||
|
def inject_master():
|
||||||
|
return dict(is_master=os.environ.get('MASTER', 'false').lower() == 'true')
|
||||||
|
|
||||||
# Register blueprints
|
# Register blueprints
|
||||||
app.register_blueprint(main_bp)
|
app.register_blueprint(main_bp)
|
||||||
app.register_blueprint(auth_bp)
|
app.register_blueprint(auth_bp)
|
||||||
|
|||||||
Binary file not shown.
@@ -31,6 +31,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
|
{% if not is_master %}
|
||||||
<div class="d-none d-lg-flex align-items-center me-3">
|
<div class="d-none d-lg-flex align-items-center me-3">
|
||||||
<a class="nav-link text-white position-relative" href="{{ url_for('main.notifications') }}">
|
<a class="nav-link text-white position-relative" href="{{ url_for('main.notifications') }}">
|
||||||
<i class="fas fa-bell text-xl" style="width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;"></i>
|
<i class="fas fa-bell text-xl" style="width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;"></i>
|
||||||
@@ -41,6 +42,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<a class="nav-link d-flex align-items-center gap-2 d-lg-none" href="{{ url_for('main.profile') }}">
|
<a class="nav-link d-flex align-items-center gap-2 d-lg-none" href="{{ url_for('main.profile') }}">
|
||||||
<img src="{{ url_for('profile_pic', filename=current_user.profile_picture) if current_user.profile_picture else url_for('static', filename='default-avatar.png') }}"
|
<img src="{{ url_for('profile_pic', filename=current_user.profile_picture) if current_user.profile_picture else url_for('static', filename='default-avatar.png') }}"
|
||||||
@@ -56,11 +58,13 @@
|
|||||||
<span class="text-white font-medium">{{ current_user.username }}</span>
|
<span class="text-white font-medium">{{ current_user.username }}</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
|
{% if not is_master %}
|
||||||
<li><a class="dropdown-item" href="{{ url_for('main.profile') }}"><i class="fas fa-user"></i> Profile</a></li>
|
<li><a class="dropdown-item" href="{{ url_for('main.profile') }}"><i class="fas fa-user"></i> Profile</a></li>
|
||||||
{% if current_user.is_admin %}
|
{% if current_user.is_admin %}
|
||||||
<li><a class="dropdown-item" href="{{ url_for('main.settings') }}"><i class="fas fa-cog"></i> Settings</a></li>
|
<li><a class="dropdown-item" href="{{ url_for('main.settings') }}"><i class="fas fa-cog"></i> Settings</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li><hr class="dropdown-divider"></li>
|
<li><hr class="dropdown-divider"></li>
|
||||||
|
{% endif %}
|
||||||
<li><a class="dropdown-item" href="{{ url_for('auth.logout') }}"><i class="fas fa-sign-out-alt"></i> Logout</a></li>
|
<li><a class="dropdown-item" href="{{ url_for('auth.logout') }}"><i class="fas fa-sign-out-alt"></i> Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -79,6 +83,7 @@
|
|||||||
<i class="fas fa-home"></i> Dashboard
|
<i class="fas fa-home"></i> Dashboard
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if not is_master %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link {% if request.endpoint == 'conversations.conversations' %}active{% endif %}" href="{{ url_for('conversations.conversations') }}">
|
<a class="nav-link {% if request.endpoint == 'conversations.conversations' %}active{% endif %}" href="{{ url_for('conversations.conversations') }}">
|
||||||
<i class="fas fa-comments"></i> Conversations
|
<i class="fas fa-comments"></i> Conversations
|
||||||
@@ -106,7 +111,9 @@
|
|||||||
<i class="fas fa-trash"></i> Trash
|
<i class="fas fa-trash"></i> Trash
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
<!-- Mobile-only menu items -->
|
<!-- Mobile-only menu items -->
|
||||||
|
{% if not is_master %}
|
||||||
<li class="nav-item d-lg-none">
|
<li class="nav-item d-lg-none">
|
||||||
<hr class="my-2">
|
<hr class="my-2">
|
||||||
<a class="nav-link" href="{{ url_for('main.notifications') }}">
|
<a class="nav-link" href="{{ url_for('main.notifications') }}">
|
||||||
@@ -125,6 +132,7 @@
|
|||||||
<i class="fas fa-user"></i> Profile
|
<i class="fas fa-user"></i> Profile
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li class="nav-item d-lg-none">
|
<li class="nav-item d-lg-none">
|
||||||
<a class="nav-link" href="{{ url_for('auth.logout') }}">
|
<a class="nav-link" href="{{ url_for('auth.logout') }}">
|
||||||
<i class="fas fa-sign-out-alt"></i> Logout
|
<i class="fas fa-sign-out-alt"></i> Logout
|
||||||
|
|||||||
@@ -16,6 +16,14 @@
|
|||||||
icon="fa-home"
|
icon="fa-home"
|
||||||
) }}
|
) }}
|
||||||
|
|
||||||
|
{% if is_master %}
|
||||||
|
<div class="container mx-auto px-4 py-8">
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="text-2xl font-bold mb-4">Master Instance</h2>
|
||||||
|
<p class="text-gray-600">This is a master instance of DocuPulse. Additional functionality will be available soon.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
{% from 'components/storage_overview.html' import storage_overview %}
|
{% from 'components/storage_overview.html' import storage_overview %}
|
||||||
{% from 'components/storage_usage.html' import storage_usage %}
|
{% from 'components/storage_usage.html' import storage_usage %}
|
||||||
{% from 'components/contacts.html' import contacts %}
|
{% from 'components/contacts.html' import contacts %}
|
||||||
@@ -79,6 +87,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user