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

Discrimination de l'historique par application.

This commit is contained in:
LEVY-FALK Hugo 2018-01-06 19:09:18 +01:00 committed by root
parent 783c662e39
commit a24d2c26c0
6 changed files with 51 additions and 36 deletions

View file

@ -104,6 +104,7 @@ urlpatterns = [
r'history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$', r'history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$',
re2o.views.history, re2o.views.history,
name='history', name='history',
kwargs={'application':'cotisations'},
), ),
url(r'^control/$', url(r'^control/$',
views.control, views.control,

View file

@ -80,6 +80,7 @@ urlpatterns = [
r'history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$', r'history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$',
re2o.views.history, re2o.views.history,
name='history', name='history',
kwargs={'application':'machines'},
), ),
url(r'^$', views.index, name='index'), url(r'^$', views.index, name='index'),
url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'), url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'),

View file

@ -72,7 +72,8 @@ urlpatterns = [
url( url(
r'^history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$', r'^history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$',
re2o.views.history, re2o.views.history,
name='history' name='history',
kwargs={'application':'preferences'},
), ),
url(r'^$', views.display_options, name='display-options'), url(r'^$', views.display_options, name='display-options'),
] ]

View file

@ -54,23 +54,32 @@ def index(request):
#: Binding the corresponding char sequence of history url to re2o models. #: Binding the corresponding char sequence of history url to re2o models.
HISTORY_BIND = { HISTORY_BIND = {
'users' : {
'user' : users.models.User, 'user' : users.models.User,
'ban' : users.models.Ban, 'ban' : users.models.Ban,
'whitelist' : users.models.Whitelist, 'whitelist' : users.models.Whitelist,
'school' : users.models.School, 'school' : users.models.School,
'listright' : users.models.ListRight, 'listright' : users.models.ListRight,
'serviceuser' : users.models.ServiceUser, 'serviceuser' : users.models.ServiceUser,
},
'preferences' : {
'service' : preferences.models.Service, 'service' : preferences.models.Service,
},
'cotisations' : {
'facture' : cotisations.models.Facture, 'facture' : cotisations.models.Facture,
'article' : cotisations.models.Article, 'article' : cotisations.models.Article,
'paiement' : cotisations.models.Paiement, 'paiement' : cotisations.models.Paiement,
'banque' : cotisations.models.Banque, 'banque' : cotisations.models.Banque,
},
'topologie' : {
'switch' : topologie.models.Switch, 'switch' : topologie.models.Switch,
'port' : topologie.models.Port, 'port' : topologie.models.Port,
'room' : topologie.models.Room, 'room' : topologie.models.Room,
'stack' : topologie.models.Stack, 'stack' : topologie.models.Stack,
'model_switch' : topologie.models.ModelSwitch, 'model_switch' : topologie.models.ModelSwitch,
'constructor_switch' : topologie.models.ConstructorSwitch, 'constructor_switch' : topologie.models.ConstructorSwitch,
},
'machines' : {
'machine' : machines.models.Machine, 'machine' : machines.models.Machine,
'interface' : machines.models.Interface, 'interface' : machines.models.Interface,
'alias' : machines.models.Domain, 'alias' : machines.models.Domain,
@ -85,10 +94,11 @@ HISTORY_BIND = {
'service' : machines.models.Service, 'service' : machines.models.Service,
'vlan' : machines.models.Vlan, 'vlan' : machines.models.Vlan,
'nas' : machines.models.Vlan, 'nas' : machines.models.Vlan,
},
} }
@login_required @login_required
def history(request, object_name, object_id): def history(request, application, object_name, object_id):
"""Render history for a model. """Render history for a model.
The model is determined using the `HISTORY_BIND` dictionnary if none is The model is determined using the `HISTORY_BIND` dictionnary if none is
@ -108,7 +118,7 @@ def history(request, object_name, object_id):
Http404: This kind of models doesn't have history. Http404: This kind of models doesn't have history.
""" """
try: try:
model = HISTORY_BIND[object_name] model = HISTORY_BIND[application][object_name]
except KeyError as e: except KeyError as e:
raise Http404(u"Il n'existe pas d'historique pour ce modèle.") raise Http404(u"Il n'existe pas d'historique pour ce modèle.")
try: try:

View file

@ -49,7 +49,8 @@ urlpatterns = [
url( url(
r'^history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$', r'^history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$',
re2o.views.history, re2o.views.history,
name='history' name='history',
kwargs={'application':'topologie'},
), ),
url(r'^edit_port/(?P<port_id>[0-9]+)$', views.edit_port, name='edit-port'), url(r'^edit_port/(?P<port_id>[0-9]+)$', views.edit_port, name='edit-port'),
url(r'^new_port/(?P<switch_id>[0-9]+)$', views.new_port, name='new-port'), url(r'^new_port/(?P<switch_id>[0-9]+)$', views.new_port, name='new-port'),

View file

@ -97,7 +97,8 @@ urlpatterns = [
url( url(
r'^history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$', r'^history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$',
re2o.views.history, re2o.views.history,
name='history' name='history',
kwargs={'application':'users'},
), ),
url(r'^$', views.index, name='index'), url(r'^$', views.index, name='index'),
url(r'^index_clubs/$', views.index_clubs, name='index-clubs'), url(r'^index_clubs/$', views.index_clubs, name='index-clubs'),