from django.urls import path
from . import views
from .views import *
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import RedirectView, TemplateView
from django.conf.urls import url, include

urlpatterns = [
    path('', RedirectView.as_view(url='projekte/'), name='index'),
    path('about/', views.about, name='about'),
    path('submit/', views.submit, name='submit'),
    path('admin_panel/', views.AdminView.as_view(), name='admin-panel'),
    path('meine-projekte/', views.UsersProducts.as_view(), name='meine-projekte'),

    # Contact
    path('register/', views.registerView.as_view(), name='register-view'),
    path('meine-daten/<int:pk>/', views.ContactUpdateView.as_view(), name='meine-daten'),


    path('products-list/', views.ProductsListView.as_view(), name='products-list'),
    path('products-list/embed', views.ProductsListView.as_view(  embed=True,  ), name='products-list-embed'),

    # OVERVIEW (LISTVIEW)
    path('projekte/',            views.ProductsView.as_view(), name='products'),
    path('wohnprojekte/',        views.WohnprojekteView.as_view(),          name='wohnprojekte-list'),
    path('mobilitaetsprojekte/', views.MobilitaetsProjekteView.as_view(),   name='mobilitaetsprojekte-list'),
    path('ernaerungsprojekte/',  views.ErnaerungsProjekteView.as_view(),    name='ernaerungsprojekte-list'),
    path('energieprojekte/',     views.EnergyProjekteView.as_view(),        name='energieprojekte-list'),

    path('projekte/urbanem/', views.UrbanemProductsView.as_view(), name='products-filter-view'),
    # path('wohnprojekte/', views.WohnProjekteView.as_view(), name='wohnprojekte-list'),

    # CREATE
    path('neues-projekt/',             views.ProductDispatchView.as_view(),          name='neues-projekt-dispatch'),
    path('neues-projekt/<slug:type>/', views.ProductGenericCreateView.as_view(),     name='neues-projekt-type'),
    path('np-submit-pics/<slug:type>/',  views.ProductCreateAddPicsView.as_view(),     name='neues-projekt-submit-pics'),
    path('np-publish/<slug:type>/',      views.ProductCreatePublishView.as_view(),     name='neues-projekt-publish'),

    # UPDATE
    path('projekt-bearbeiten/<slug:type>/<int:pk>', views.ProductGenericUpdateView.as_view(),     name='projekt-bearbeiten-type'),
    path('projekt-bearbeiten/<int:pk>',             views.ProductUpdateView.as_view(),            name='projekt-bearbeiten'),
    path('up-submit-pics/<slug:type>/<int:pk>',  views.ProductUpdateAddPicsView.as_view(),     name='projekt-bearbeiten-submit-pics'),
    path('up-publish/<slug:type>/<int:pk>',      views.ProductUpdatePublishView.as_view(),     name='projekt-bearbeiten-publish'),

    # DELETE
    path('projekt/<int:pk>/delete', views.ProductDelete.as_view(), name='product-delete'),

    # DETAIL
    path('projekt/<slug:type>/<int:pk>',            views.ProduktGenericDetailView.as_view(), name='product-detail-type'),
    path('projekt/<slug:type>/<int:pk>/embed',      views.ProduktGenericDetailView.as_view( embed=True, ), name='product-detail-type-embed'),

    path('projekt/<int:pk>/',                       views.ProduktDetailView.as_view(), name='product-detail'),
    path('projekt/<int:pk>/embed',                  views.ProduktDetailView.as_view( embed=True, ), name='product-detail-embed'),

    # CARDS
    path('projekt-card/<int:pk>', views.ProduktCardDetailView.as_view(), name='projekt-card'),
    path('projekt-card/<int:pk>/embed', views.ProduktCardDetailView.as_view( embed=True, ), name='projekt-card-embed'),
    path('projekt-card/<slug:type>/<int:pk>/embed', views.ProduktGenericCardDetailView.as_view( embed=True, ), name='projekt-card-type-embed'),

    # SEARCH & FILTERS
    path('projekte/<slug:type>/search', views.GenericSearchView.as_view(), name='generic-search-products'),
    path('projekte/search', views.SearchProductsView.as_view(), name='search-products'),
        # - FILTERS
    path('projekte/filter/<slug:filter>/', views.FilterProductsView.as_view(), name='products-filter-view'),




    path('projekt/<int:pk>/freigeben', views.ProductPublish.as_view(  ), name='product-publish'),

    # NEWSLETTER & AGENT

    path('search-agent-form/', views.AgentNewslwtterFormView.as_view(), name='search-agent-form'),
    path('search-agent-form/embed/', views.AgentNewslwtterFormView.as_view( embed=True, ), name='search-agent-form-embed'),
    path('search-agent-create/<slug:newsletter_slug>/anmelden/', views.AgentNewsletterSubscribeView.as_view(   ), name='agent-newsletter-create'),
    path('newsletter-anmeldung/<slug:newsletter_slug>/anmelden/', views.SubscribeRequestView.as_view(   ), name='newsletter-anmeldung'),
    path('only-newsletter-anmeldung/<slug:newsletter_slug>/anmelden/', views.OnlySubscribeRequestView.as_view(   ), name='only-newsletter-anmeldung'),
    path('news/<slug:newsletter_slug>/', views.OnlySubscribeRequestView.as_view(   ), name='only-newsletter-anmeldung'),
    path('suchagent/<int:pk>/<slug:hash>/', views.SearchAgentDelete.as_view(), name='search-agent-delete'),
    path('newsletter', RedirectView.as_view(url='/gem/news/gemeinschaffen-newsletter/'), name='short-newsletter-anmeldung'),
    # path('suchagent/embed', views.SearchAgentCreate.as_view( embed=True, ), name='search-agent-create-embed'),


    path('add-image/<int:pk>', views.addImageView.as_view(), name='add-image'),

    path('pages/<slug:page>/', pagesView.as_view(template_name="marktplatz/generic.html"), name='pages-generic'),
    path('generic/', TemplateView.as_view(template_name="marktplatz/generic.html"), name='generic'),
    url(r'^delete_media/(?P<pk>\d+)/$', views.delete_media, name='delete-media'),
    url(r'^delete_video/(?P<pk>\d+)/$', views.delete_video, name='delete-video'),
    url(r'^upload/', include('django_file_form.urls')),
    url(r'^handle_upload$', views.handle_upload, name='file_form_handle_upload'),
    url(r'^upload_mab$', views.handle_upload, name='upload_mab'),
    url(r'^home', views.home, name='home'),
    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
