K-Fêt urlconf file + converter

This commit is contained in:
Ludovic Stephan 2019-04-12 17:06:53 +02:00
parent 019acb90ac
commit 271732f40d
3 changed files with 116 additions and 114 deletions

8
kfet/converters.py Normal file
View file

@ -0,0 +1,8 @@
class TrigrammeConverter:
regex = ".{3}"
def to_python(self, value):
return str(value)
def to_url(self, value):
return str(value)

View file

@ -1,8 +1,8 @@
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r"^raw_open$", views.raw_open, name="kfet.open.edit_raw_open"),
url(r"^force_close$", views.force_close, name="kfet.open.edit_force_close"),
path("raw_open", views.raw_open, name="kfet.open.edit_raw_open"),
path("force_close", views.force_close, name="kfet.open.edit_force_close"),
]

View file

@ -1,95 +1,97 @@
from django.conf.urls import include, url
from django.contrib.auth.decorators import permission_required
from django.urls import include, path, register_converter
from kfet import autocomplete, views
from kfet import autocomplete, converters, views
from kfet.decorators import teamkfet_required
register_converter(converters.TrigrammeConverter, "trigramme")
urlpatterns = [
url(r"^login/generic$", views.login_generic, name="kfet.login.generic"),
url(r"^history$", views.history, name="kfet.history"),
path("login/generic", views.login_generic, name="kfet.login.generic"),
path("history", views.history, name="kfet.history"),
# -----
# Account urls
# -----
# Account - General
url(r"^accounts/$", views.account, name="kfet.account"),
url(
r"^accounts/is_validandfree$",
path("accounts/", views.account, name="kfet.account"),
path(
"accounts/is_validandfree",
views.account_is_validandfree_ajax,
name="kfet.account.is_validandfree.ajax",
),
# Account - Create
url(r"^accounts/new$", views.account_create, name="kfet.account.create"),
url(
r"^accounts/new/user/(?P<username>.+)$",
path("accounts/new", views.account_create, name="kfet.account.create"),
path(
"accounts/new/user/<username>",
views.account_create_ajax,
name="kfet.account.create.fromuser",
),
url(
r"^accounts/new/clipper/(?P<login_clipper>[\w-]+)/(?P<fullname>.*)$",
path(
"accounts/new/clipper/<slug:login_clipper>/<fullname>",
views.account_create_ajax,
name="kfet.account.create.fromclipper",
),
url(
r"^accounts/new/empty$",
path(
"accounts/new/empty",
views.account_create_ajax,
name="kfet.account.create.empty",
),
url(
r"^autocomplete/account_new$",
path(
"autocomplete/account_new",
autocomplete.account_create,
name="kfet.account.create.autocomplete",
),
# Account - Search
url(
r"^autocomplete/account_search$",
path(
"autocomplete/account_search",
autocomplete.account_search,
name="kfet.account.search.autocomplete",
),
# Account - Read
url(
r"^accounts/(?P<trigramme>.{3})$", views.account_read, name="kfet.account.read"
path(
"accounts/<trigramme:trigramme>", views.account_read, name="kfet.account.read"
),
# Account - Update
url(
r"^accounts/(?P<trigramme>.{3})/edit$",
path(
"accounts/<trigramme:trigramme>/edit",
views.account_update,
name="kfet.account.update",
),
# Account - Groups
url(r"^accounts/groups$", views.account_group, name="kfet.account.group"),
url(
r"^accounts/groups/new$",
path("accounts/groups", views.account_group, name="kfet.account.group"),
path(
"accounts/groups/new",
permission_required("kfet.manage_perms")(views.AccountGroupCreate.as_view()),
name="kfet.account.group.create",
),
url(
r"^accounts/groups/(?P<pk>\d+)/edit$",
path(
"accounts/groups/<int:pk>/edit",
permission_required("kfet.manage_perms")(views.AccountGroupUpdate.as_view()),
name="kfet.account.group.update",
),
url(
r"^accounts/negatives$",
path(
"accounts/negatives",
permission_required("kfet.view_negs")(views.AccountNegativeList.as_view()),
name="kfet.account.negative",
),
# Account - Statistics
url(
r"^accounts/(?P<trigramme>.{3})/stat/operations/list$",
path(
"accounts/<trigramme:trigramme>/stat/operations/list",
views.AccountStatOperationList.as_view(),
name="kfet.account.stat.operation.list",
),
url(
r"^accounts/(?P<trigramme>.{3})/stat/operations$",
path(
"accounts/<trigramme:trigramme>/stat/operations",
views.AccountStatOperation.as_view(),
name="kfet.account.stat.operation",
),
url(
r"^accounts/(?P<trigramme>.{3})/stat/balance/list$",
path(
"accounts/<trigramme:trigramme>/stat/balance/list",
views.AccountStatBalanceList.as_view(),
name="kfet.account.stat.balance.list",
),
url(
r"^accounts/(?P<trigramme>.{3})/stat/balance$",
path(
"accounts/<trigramme:trigramme>/stat/balance",
views.AccountStatBalance.as_view(),
name="kfet.account.stat.balance",
),
@ -97,26 +99,26 @@ urlpatterns = [
# Checkout urls
# -----
# Checkout - General
url(
"^checkouts/$",
path(
"checkouts/",
teamkfet_required(views.CheckoutList.as_view()),
name="kfet.checkout",
),
# Checkout - Create
url(
"^checkouts/new$",
path(
"checkouts/new",
teamkfet_required(views.CheckoutCreate.as_view()),
name="kfet.checkout.create",
),
# Checkout - Read
url(
"^checkouts/(?P<pk>\d+)$",
path(
"checkouts/<int:pk>",
teamkfet_required(views.CheckoutRead.as_view()),
name="kfet.checkout.read",
),
# Checkout - Update
url(
"^checkouts/(?P<pk>\d+)/edit$",
path(
"checkouts/<int:pk>/edit",
teamkfet_required(views.CheckoutUpdate.as_view()),
name="kfet.checkout.update",
),
@ -124,20 +126,20 @@ urlpatterns = [
# Checkout Statement urls
# -----
# Checkout Statement - General
url(
"^checkouts/statements/$",
path(
"checkouts/statements/",
teamkfet_required(views.CheckoutStatementList.as_view()),
name="kfet.checkoutstatement",
),
# Checkout Statement - Create
url(
"^checkouts/(?P<pk_checkout>\d+)/statements/add",
path(
"checkouts/<int:pk_checkout>/statements/add",
teamkfet_required(views.CheckoutStatementCreate.as_view()),
name="kfet.checkoutstatement.create",
),
# Checkout Statement - Update
url(
"^checkouts/(?P<pk_checkout>\d+)/statements/(?P<pk>\d+)/edit",
path(
"checkouts/<int:pk_checkout>/statements/<int:pk>/edit",
teamkfet_required(views.CheckoutStatementUpdate.as_view()),
name="kfet.checkoutstatement.update",
),
@ -145,140 +147,132 @@ urlpatterns = [
# Article urls
# -----
# Category - General
url(
"^categories/$",
path(
"categories/",
teamkfet_required(views.CategoryList.as_view()),
name="kfet.category",
),
# Category - Update
url(
"^categories/(?P<pk>\d+)/edit$",
path(
"categories/<int:pk>/edit",
teamkfet_required(views.CategoryUpdate.as_view()),
name="kfet.category.update",
),
# Article - General
url(
"^articles/$",
teamkfet_required(views.ArticleList.as_view()),
name="kfet.article",
path(
"articles/", teamkfet_required(views.ArticleList.as_view()), name="kfet.article"
),
# Article - Create
url(
"^articles/new$",
path(
"articles/new",
teamkfet_required(views.ArticleCreate.as_view()),
name="kfet.article.create",
),
# Article - Read
url(
"^articles/(?P<pk>\d+)$",
path(
"articles/<int:pk>",
teamkfet_required(views.ArticleRead.as_view()),
name="kfet.article.read",
),
# Article - Update
url(
"^articles/(?P<pk>\d+)/edit$",
path(
"articles/<int:pk>/edit",
teamkfet_required(views.ArticleUpdate.as_view()),
name="kfet.article.update",
),
# Article - Statistics
url(
r"^articles/(?P<pk>\d+)/stat/sales/list$",
path(
"articles/<int:pk>/stat/sales/list",
views.ArticleStatSalesList.as_view(),
name="kfet.article.stat.sales.list",
),
url(
r"^articles/(?P<pk>\d+)/stat/sales$",
path(
"articles/<int:pk>/stat/sales",
views.ArticleStatSales.as_view(),
name="kfet.article.stat.sales",
),
# -----
# K-Psul urls
# -----
url("^k-psul/$", views.kpsul, name="kfet.kpsul"),
url(
"^k-psul/checkout_data$",
path("k-psul/", views.kpsul, name="kfet.kpsul"),
path(
"k-psul/checkout_data",
views.kpsul_checkout_data,
name="kfet.kpsul.checkout_data",
),
url(
"^k-psul/perform_operations$",
path(
"k-psul/perform_operations",
views.kpsul_perform_operations,
name="kfet.kpsul.perform_operations",
),
url(
"^k-psul/cancel_operations$",
path(
"k-psul/cancel_operations",
views.kpsul_cancel_operations,
name="kfet.kpsul.cancel_operations",
),
url(
"^k-psul/articles_data",
path(
"k-psul/articles_data",
views.kpsul_articles_data,
name="kfet.kpsul.articles_data",
),
url(
"^k-psul/update_addcost$",
path(
"k-psul/update_addcost",
views.kpsul_update_addcost,
name="kfet.kpsul.update_addcost",
),
url(
"^k-psul/get_settings$",
views.kpsul_get_settings,
name="kfet.kpsul.get_settings",
path(
"k-psul/get_settings", views.kpsul_get_settings, name="kfet.kpsul.get_settings"
),
# -----
# JSON urls
# -----
url(r"^history.json$", views.history_json, name="kfet.history.json"),
url(
r"^accounts/read.json$", views.account_read_json, name="kfet.account.read.json"
),
path("history.json", views.history_json, name="kfet.history.json"),
path("accounts/read.json", views.account_read_json, name="kfet.account.read.json"),
# -----
# Settings urls
# -----
url(r"^settings/$", views.config_list, name="kfet.settings"),
url(r"^settings/edit$", views.config_update, name="kfet.settings.update"),
path("settings/", views.config_list, name="kfet.settings"),
path("settings/edit", views.config_update, name="kfet.settings.update"),
# -----
# Transfers urls
# -----
url(r"^transfers/$", views.transfers, name="kfet.transfers"),
url(r"^transfers/new$", views.transfers_create, name="kfet.transfers.create"),
url(r"^transfers/perform$", views.perform_transfers, name="kfet.transfers.perform"),
url(r"^transfers/cancel$", views.cancel_transfers, name="kfet.transfers.cancel"),
path("transfers/", views.transfers, name="kfet.transfers"),
path("transfers/new", views.transfers_create, name="kfet.transfers.create"),
path("transfers/perform", views.perform_transfers, name="kfet.transfers.perform"),
path("transfers/cancel", views.cancel_transfers, name="kfet.transfers.cancel"),
# -----
# Inventories urls
# -----
url(
r"^inventaires/$",
path(
"inventaires/",
teamkfet_required(views.InventoryList.as_view()),
name="kfet.inventory",
),
url(r"^inventaires/new$", views.inventory_create, name="kfet.inventory.create"),
url(
r"^inventaires/(?P<pk>\d+)$",
path("inventaires/new", views.inventory_create, name="kfet.inventory.create"),
path(
"inventaires/<int:pk>",
teamkfet_required(views.InventoryRead.as_view()),
name="kfet.inventory.read",
),
# -----
# Order urls
# -----
url(r"^orders/$", teamkfet_required(views.OrderList.as_view()), name="kfet.order"),
url(
r"^orders/(?P<pk>\d+)$",
path("orders/", teamkfet_required(views.OrderList.as_view()), name="kfet.order"),
path(
"orders/<int:pk>",
teamkfet_required(views.OrderRead.as_view()),
name="kfet.order.read",
),
url(
r"^orders/suppliers/(?P<pk>\d+)/edit$",
path(
"orders/suppliers/<int:pk>/edit",
teamkfet_required(views.SupplierUpdate.as_view()),
name="kfet.order.supplier.update",
),
url(
r"^orders/suppliers/(?P<pk>\d+)/new-order$",
views.order_create,
name="kfet.order.new",
path(
"orders/suppliers/<int:pk>/new-order", views.order_create, name="kfet.order.new"
),
url(
r"^orders/(?P<pk>\d+)/to_inventory$",
path(
"orders/<int:pk>/to_inventory",
views.order_to_inventory,
name="kfet.order.to_inventory",
),
@ -286,5 +280,5 @@ urlpatterns = [
urlpatterns += [
# K-Fêt Open urls
url("^open/", include("kfet.open.urls"))
path("open/", include("kfet.open.urls"))
]