Ejemplo n.º 1
0
"""easycoding URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url, patterns
from django.contrib import admin

from events.views import IndexView, MainPanelView, CrearEvento, EventDetail, EventEdit, DeleteEvent

urlpatterns = [
    url(r'^$', IndexView.as_view(), name="index"),
    url(r'^panel/$', MainPanelView.as_view(), name="panel"),
    url(r'^panel/evento/nuevo/$', CrearEvento.as_view(), name="nuevo"),
    url(r'^panel/evento/(?P<pk>\d+)/$', EventDetail.as_view(), name="detalle"),
    url(r'^panel/evento/editar/(?P<pk>\d+)/$', EventEdit.as_view(), name="editar"),
    url(r'^panel/evento/eliminar/(?P<pk>\d+)/$', DeleteEvent.as_view(), name="eliminar")
]
Ejemplo n.º 2
0
from django.conf.urls import patterns, url
from django.contrib.auth.decorators import login_required

from events.views import (CreateEquipmentEvent, DeleteEvent, DeleteReservation,
                          EquipmentQR, ReturnEquipmentFromBuildingSite,
                          ReturnEquipmentFromEmployee, ReturnTool)

urlpatterns = patterns(
    'events.views',
    url(r'^vaerktoej/(?P<tool>\d+)/slet-reservation/(?P<pk>\d+)/$',
        login_required(DeleteReservation.as_view()),
        name='delete_reservation'),
    url(r'^vaerktoej/(?P<tool>\d+)/slet-begivenhed/(?P<pk>\d+)/$',
        login_required(DeleteEvent.as_view()),
        name='delete_event'),

    url(r'^medarbejdere/(?P<employee>\d+)/aflever-udstyr/(?P<equipment>\d+)/$',
        login_required(ReturnEquipmentFromEmployee.as_view()),
        name='return_equipment_from_employee'),
    url(r'^medarbejdere/(?P<employee>\d+)/aflever-vaerktoej/(?P<tool>\d+)/$',
        login_required(ReturnTool.as_view()),
        name='return_tool'),

    url((r'^byggepladser/(?P<building_site>\d+)/aflever-udstyr/' +
        '(?P<equipment>\d+)/$'),
        login_required(ReturnEquipmentFromBuildingSite.as_view()),
        name='return_equipment_from_building_site'),

    url(r'^udstyr/(?P<pk>\d+)/qr-aktion/$',
        login_required(EquipmentQR.as_view()),
        name='equipment_qr_action'),
router.register(r'agents', views.AgentAPIViewSet)
router.register(r'users', views.UserAPIViewSet)
router.register(r'groups', views.GroupAPIViewSet)


class NestedDefaultRouter(NestedRouterMixin, DefaultRouter):
    '''#resource to get acess to get, post ,put , delete of /agent/id/event'''
    pass


#router for get acess to "get", "post", "put", "delete" of endpoint /agent/id/event
router_agent_events = NestedDefaultRouter()
agents_router = router_agent_events.register(r'agent', views.AgentAPIViewSet)
agents_router.register('events',
                       views.EventAPIViewSet,
                       basename='events-agents',
                       parents_query_lookups=['agent'])

urlpatterns = [
    path('api/', include(router.urls)),
    path('api/', include(agents_router.router.urls)),
    path('', EventFilter.as_view(), name='events-list'),
    # re_path(r'agents/(?P<id_agent>\d+)/events/(?P<id_event>\d+)', agent_id_event_id , name='events_by_agents'),
    # path('<str:envName>', EventFilter.as_view(), name='filter_events'),
    path('<int:event_id>', EventDetail.as_view(), name='detail'),
    re_path(r'(?P<pk>\d+)?/shelved', ShelveEvent.as_view(), name='shelved'),
    re_path(r'(?P<pk>\d+)?/unshelved',
            UnshelveEvent.as_view(),
            name='unshelved'),
    re_path(r'(?P<pk>\d+)?/delete', DeleteEvent.as_view(), name='delete')
]