bg_domain button for operators and higher

This commit is contained in:
RoeiGanor 2021-08-13 20:03:06 +03:00
parent 993e02b635
commit 10dc2b0273

View File

@ -3,6 +3,7 @@ from flask import Blueprint, render_template, url_for, current_app, request, jso
from flask_login import login_required, current_user, login_manager from flask_login import login_required, current_user, login_manager
from sqlalchemy import not_ from sqlalchemy import not_
from ..decorators import operator_role_required
from ..lib.utils import customBoxes from ..lib.utils import customBoxes
from ..models.user import User, Anonymous from ..models.user import User, Anonymous
from ..models.account import Account from ..models.account import Account
@ -150,6 +151,10 @@ def dashboard():
else: else:
current_app.logger.info('Updating domains in background...') current_app.logger.info('Updating domains in background...')
show_bg_domain_button = BG_DOMAIN_UPDATE
if BG_DOMAIN_UPDATE and current_user.role.name not in ['Administrator', 'Operator']:
show_bg_domain_button = False
# Stats for dashboard # Stats for dashboard
domain_count = 0 domain_count = 0
history_number = 0 history_number = 0
@ -198,12 +203,13 @@ def dashboard():
history_number=history_number, history_number=history_number,
uptime=uptime, uptime=uptime,
histories=history, histories=history,
show_bg_domain_button=BG_DOMAIN_UPDATE, show_bg_domain_button=show_bg_domain_button,
pdns_version=Setting().get('pdns_version')) pdns_version=Setting().get('pdns_version'))
@dashboard_bp.route('/domains-updater', methods=['GET', 'POST']) @dashboard_bp.route('/domains-updater', methods=['GET', 'POST'])
@login_required @login_required
@operator_role_required
def domains_updater(): def domains_updater():
current_app.logger.debug('Update domains in background') current_app.logger.debug('Update domains in background')
d = Domain().update() d = Domain().update()