Browse Source

Dispatch des modèles dans le tag de gestion des acl plus simple.

test-front-curly
LEVY-FALK Hugo 8 years ago
committed by root
parent
commit
06fe4d568a
  1. 100
      re2o/templatetags/acl.py

100
re2o/templatetags/acl.py

@ -75,65 +75,65 @@ from django import template
from django.template.base import Node, NodeList from django.template.base import Node, NodeList
import cotisations.models as cotisations import cotisations.models as cotisations
import logs.models as logs
import machines.models as machines import machines.models as machines
import topologie.models as topologie import topologie.models as topologie
import users.models as users import users.models as users
register = template.Library() register = template.Library()
MODEL_NAME = {
def get_model(model_name): # topologie
"""Retrieve the model object from its name""" 'Stack' : topologie.Stack,
'Switch' : topologie.Switch,
'ModelSwitch' : topologie.ModelSwitch,
'ConstructorSwitch' : topologie.ConstructorSwitch,
'Port' : topologie.Port,
'Room' : topologie.Room,
# cotisations # cotisations
# TODO 'Facture' : cotisations.Facture,
# logs 'Vente' : cotisations.Vente,
# TODO 'Article' : cotisations.Article,
'Banque' : cotisations.Banque,
'Paiement' : cotisations.Paiement,
'Cotisation' : cotisations.Cotisation,
# machines # machines
if model_name == 'Machine': 'Machine' : machines.Machine,
return machines.Machine 'MachineType' : machines.MachineType,
if model_name == 'MachineType': 'IpType' : machines.IpType,
return machines.MachineType 'Vlan' : machines.Vlan,
if model_name == 'IpType': 'Nas' : machines.Nas,
return machines.IpType 'SOA' : machines.SOA,
if model_name == 'Vlan': 'Extension' : machines.Extension,
return machines.Vlan 'Mx' : machines.Mx,
if model_name == 'Nas': 'Ns' : machines.Ns,
return machines.Nas 'Txt' : machines.Txt,
if model_name == 'SOA': 'Srv' : machines.Srv,
return machines.SOA 'Interface' : machines.Interface,
if model_name == 'Extension': 'Domain' : machines.Domain,
return machines.Extension 'IpList' : machines.IpList,
if model_name == 'Mx': 'Service' : machines.Service,
return machines.Mx 'Service_link' : machines.Service_link,
if model_name == 'Ns': 'OuverturePortList' : machines.OuverturePortList,
return machines.Ns 'OuverturePort' : machines.OuverturePort,
if model_name == 'Txt':
return machines.Txt
if model_name == 'Srv':
return machines.Srv
if model_name == 'Interface':
return machines.Interface
if model_name == 'Domain':
return machines.Domain
if model_name == 'IpList':
return machines.IpList
if model_name == 'Service':
return machines.Service
if model_name == 'Service_link':
return machines.Service_link
if model_name == 'OuverturePortList':
return machines.OuverturePortList
if model_name == 'OuverturePort':
return machines.OuverturePort
# topologie
# TODO
# users # users
# TODO 'User' : users.User,
raise template.TemplateSyntaxError( 'Club' : users.Club,
"%r is not a valid model for an acl tag" % model_name 'ServiceUser' : users.ServiceUser,
) 'Right' : users.Right,
'School' : users.School,
'ListRight' : users.ListRight,
'Ban' : users.Ban,
'Whitelist' : users.Whitelist,
}
def get_model(model_name):
"""Retrieve the model object from its name"""
try:
return MODEL_NAME[model_name]
except KeyError:
raise template.TemplateSyntaxError(
"%r is not a valid model for an acl tag" % model_name
)
def get_callback(tag_name, obj): def get_callback(tag_name, obj):

Loading…
Cancel
Save