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