"""receipeServer URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path

from receipe import views
#from django.conf.urls import url

#from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
from django.conf import settings
from django.conf.urls.static import static


urlpatterns = [
    path('admin/', admin.site.urls),
    
    re_path(r'^api/purchase/$', views.purchase_list),
    re_path(r'^api/purchase/([0-9]*)$', views.purchases_detail),
    re_path(r'^api/markets/$', views.market_list),
    re_path(r'^api/market/([0-9]*)$', views.markets_detail),
    re_path(r'^api/exchangePurchaseMarket/([0-9]*)',views.exchange_purchase_market),
    re_path(r'^api/purchaseArticles/([0-9]*)',views.purchase_articles),  # Returns all articels for a given purchaseId
    re_path(r'^api/newPurchaseArticles/([0-9]*)',views.new_purchase_article),
    re_path(r'^api/exchangePurchaseArticles/',views.exchange_purchase_article),
    re_path(r'^api/purchase/article/([0-9]*)',views.purchaseArticleMod), # Allows for modification of a purchaseArticle element
    re_path(r'^api/purchase/post_receipe/', views.post_receipe),
    re_path(r'^api/receipeImage/([0-9]*)$', views.receipeImage),
    re_path(r'^api/article/([0-9]*)$', views.article_detail),
    re_path(r'^api/articles/$', views.article_list),

    re_path(r'^api/article/allergenes/$', views.articleAllergenes_list),
    re_path(r'^api/article/traces/$', views.articleTraces_list),
    re_path(r'^api/article/labels/$', views.articleLabels_list),
    re_path(r'^api/article/maps/([0-9]*)$', views.articleMapMod),
    re_path(r'^api/article/mapStrings/$', views.articleMapStrings_list),
    # TODO: Bessere Benennung!
    re_path(r'^api/article/packaging/$', views.articlePackaging_list),
    re_path(r'^api/article/packaging/([0-9]*)$', views.articlePackagingValues),
    re_path(r'^api/article/articlePackagings/([0-9]*)',views.articleArticlePackaging),
    re_path(r'^api/article/ingrediences/$', views.articleIngrediences_list),
    re_path(r'^api/article/ingredient/([0-9]*)$', views.articleIngredientValues),
    re_path(r'^api/article/articleIngrediences/([0-9]*)',views.articleArticleIngrediences),
    re_path(r'^api/article/brands/$', views.articleBrand_list),
    re_path(r'^api/article/embs/$', views.articleEMB_list),
    re_path(r'^api/article/originIngredients/$', views.articleOriginIngredients_list),
    re_path(r'^api/article/manufacturingPlaces/$', views.articleManufacturingPlaces_list),
    re_path(r'^api/article/nutrients/$', views.articleNutrient_list),
    re_path(r'^api/article/nutritionalValues/([0-9]*)$', views.articleNutritionalValues),
    re_path(r'^api/article/categories/$', views.categories_list),
    re_path(r'^api/article/categories/([0-9]*)$', views.singleCategory),
    re_path(r'^api/article/createdefaultcategories/$', views.categories_default),

    re_path(r'^api/article/post_articleImage/([0-9]*)$', views.post_articleImage),

    re_path(r'^api/offsearch_get_by_ean/([0-9]*)/([0-9]*)$', views.offsearch_get_by_ean),

    re_path(r'^api/scanner/postImage', views.receiveImageFromScanner),
    re_path(r'^api/scanner/receipeComplete', views.imageFromScannerComplete),
    re_path(r'^api/scanner/processAgain', views.imageFromScannerAgain),

    re_path(r'^api/analyses/countArticles', views.articleCountForInterval),
    re_path(r'^api/analyses/countBrands', views.brandCountForInterval),

    path("", TemplateView.as_view(template_name="index.html")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
