models.py 4.08 KB
Newer Older
1
# -*- mode: python; coding: utf-8 -*-
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# Re2o un logiciel d'administration développé initiallement au rezometz. Il
# se veut agnostique au réseau considéré, de manière à être installable en
# quelques clics.
#
# Copyright © 2017  Gabriel Détraz
# Copyright © 2017  Goulven Kermarec
# Copyright © 2017  Augustin Lemesle
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

24
from __future__ import unicode_literals
25 26

from django.db import models
chibrac's avatar
chibrac committed
27
from cotisations.models import Paiement
28
from machines.models import Vlan
29 30

class OptionalUser(models.Model):
31 32
    PRETTY_NAME = "Options utilisateur"

33 34
    is_tel_mandatory = models.BooleanField(default=True)
    user_solde = models.BooleanField(default=False)
chibrac's avatar
chibrac committed
35
    solde_negatif = models.DecimalField(max_digits=5, decimal_places=2, default=0) 
36 37
    gpg_fingerprint = models.BooleanField(default=True)

chibrac's avatar
chibrac committed
38 39 40 41
    def clean(self):
        if self.user_solde:
            Paiement.objects.get_or_create(moyen="Solde")

42
class OptionalMachine(models.Model):
43 44
    PRETTY_NAME = "Options machines"

45 46 47
    password_machine = models.BooleanField(default=False)
    max_lambdauser_interfaces = models.IntegerField(default=10)
    max_lambdauser_aliases = models.IntegerField(default=10)
48
    ipv6 = models.BooleanField(default=False)
49

50 51
class OptionalTopologie(models.Model):
    PRETTY_NAME = "Options topologie"
52 53 54 55 56 57
    MACHINE = 'MACHINE'
    DEFINED = 'DEFINED'
    CHOICE_RADIUS = (
            (MACHINE, 'Sur le vlan de la plage ip machine'),
            (DEFINED, 'Prédéfini dans "Vlan où placer les machines après acceptation RADIUS"'),
    )
58

59

60
    radius_general_policy = models.CharField(max_length=32, choices=CHOICE_RADIUS, default='DEFINED')
61 62
    vlan_decision_ok = models.OneToOneField('machines.Vlan', on_delete=models.PROTECT, related_name='decision_ok', blank=True, null=True)
    vlan_decision_nok = models.OneToOneField('machines.Vlan', on_delete=models.PROTECT, related_name='decision_nok', blank=True, null=True)
63 64

class GeneralOption(models.Model):
65 66
    PRETTY_NAME = "Options générales"

67 68 69
    search_display_page = models.IntegerField(default=15)
    pagination_number = models.IntegerField(default=25)
    pagination_large_number = models.IntegerField(default=8)
70 71 72
    req_expire_hrs = models.IntegerField(default=48)
    site_name = models.CharField(max_length=32, default="Re2o")
    email_from = models.EmailField(default="www-data@serveur.net")
73

74 75 76 77 78 79
class Service(models.Model):
    name = models.CharField(max_length=32)
    url = models.URLField()
    description = models.TextField()
    image = models.ImageField(upload_to='logo', blank=True)    

80 81 82
    def __str__(self):
        return str(self.name)

83 84 85 86 87 88 89 90 91 92 93
class AssoOption(models.Model):
    PRETTY_NAME = "Options de l'association"

    name = models.CharField(default="Association réseau école machin", max_length=256)
    siret = models.CharField(default="00000000000000", max_length=32)
    adresse1 = models.CharField(default="1 Rue de exemple", max_length=128)
    adresse2 = models.CharField(default="94230 Cachan", max_length=128)
    contact = models.EmailField(default="contact@example.org")
    telephone = models.CharField(max_length=15, default="0000000000")
    pseudo = models.CharField(default="Asso", max_length=32)
    utilisateur_asso = models.OneToOneField('users.User', on_delete=models.PROTECT, blank=True, null=True)
94 95 96 97 98 99 100

class MailMessageOption(models.Model):
    PRETTY_NAME = "Options de corps de mail"

    welcome_mail_fr = models.TextField(default="")
    welcome_mail_en = models.TextField(default="")