8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 06:32:26 +00:00

Add Inhibited services (M2M BanType<->Services)

This commit is contained in:
Daniel STAN 2017-10-12 20:19:12 +02:00
parent 5b96a94774
commit a2b4ee8db6
2 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-10-11 20:59
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('machines', '0059_iptype_prefix_v6'),
('users', '0056_3_bantype_clean'),
]
operations = [
migrations.AddField(
model_name='bantype',
name='inhibited_services',
field=models.ManyToManyField(to='machines.Service'),
),
]

View file

@ -343,7 +343,7 @@ class User(AbstractBaseUser):
else: else:
return True return True
def has_access(self): def has_access(self): #TODO consider service type
""" Renvoie si un utilisateur a accès à internet """ """ Renvoie si un utilisateur a accès à internet """
return self.state == User.STATE_ACTIVE \ return self.state == User.STATE_ACTIVE \
and not self.is_ban and (self.is_adherent() or self.is_whitelisted) and not self.is_ban and (self.is_adherent() or self.is_whitelisted)
@ -730,7 +730,11 @@ class BanType(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
description = models.TextField(help_text="Description de l'effet et des " description = models.TextField(help_text="Description de l'effet et des "
"raisons de la blacklist") "raisons de la blacklist")
inhibited_services = models.ManyToManyField('machines.Service',
help_text="Services désactivés par le ban"
)
# d'autres champs pour décrire les effets viendront si besoin # d'autres champs pour décrire les effets viendront si besoin
# Radius ?
def __str__(self): def __str__(self):
return "%s (%s)" % (self.name, self.description) return "%s (%s)" % (self.name, self.description)