mirror of
https://github.com/TakeusV1/flask_ipam.git
synced 2026-10-13 17:15:33 +02:00
V1.5
- BLACKLIST SYSTEM - FIXES
This commit is contained in:
1 parent
1f32755ade
commit
a2a86db788
4 files changed
+37
-3
No files matched your search
@@ -20,13 +20,15 @@ def home():
|
||||
def dashboard():
|
||||
|
||||
db_networks = Network.query.count()
|
||||
db_allocations = Allocation.query.filter_by(is_used=True).count()
|
||||
db_inventory = Inventory.query.count()
|
||||
db_users = User.query.count()
|
||||
available_alloc = 0
|
||||
db_allocations = 0
|
||||
|
||||
for available_ip in Network.query.all():
|
||||
available_alloc += int(available_ip.hosts)
|
||||
for network in Network.query.all():
|
||||
if network.is_blacklisted == False:
|
||||
available_alloc += int(network.hosts)
|
||||
db_allocations += Allocation.query.filter_by(net_id=network.id, is_used=True).count()
|
||||
|
||||
return render_template(
|
||||
'panel/dashboard.html',
|
||||
|
||||
@@ -202,6 +202,31 @@ def network_delete(net_id):
|
||||
flash("Network Not Found", 'danger')
|
||||
return redirect(url_for('network.networks'))
|
||||
|
||||
@network.get('/<int:net_id>/blacklist/<action>')
|
||||
@login_required
|
||||
def network_blacklist(net_id, action):
|
||||
if current_user.is_reado:
|
||||
return abort(403)
|
||||
|
||||
db_network = Network.query.filter_by(id=net_id).first()
|
||||
|
||||
if db_network == None:
|
||||
flash("Network Not Found", 'danger')
|
||||
return redirect(url_for('network.networks'))
|
||||
|
||||
if action == 'blacklist':
|
||||
db_network.is_blacklisted = True
|
||||
db.session.commit()
|
||||
flash("Network Blacklisted", 'warning')
|
||||
|
||||
elif action == 'unblacklist':
|
||||
db_network.is_blacklisted = False
|
||||
db.session.commit()
|
||||
flash("Network Unblacklisted", 'success')
|
||||
|
||||
|
||||
return redirect(url_for('network.networks'))
|
||||
|
||||
## HTMX SEARCH
|
||||
@network.post('/<int:net_id>/allocations/search')
|
||||
@login_required
|
||||
|
||||
Reference in new issue
Block a user