Ejemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        """Добавить товар в корзину на странице - карточка товара - Ajax"""
        # TODO: |[!]|: перенести в метод товара
        # одиночный товар или у товара есть позиции для выбора
        obj = ProductItem.objects.get(id=request.POST['product_id'])

        product_detail = ProductDetail()
        product_detail.post(request)

        response_data = {
            'product_id': obj.id,
            'name': obj.name,
            'articul': obj.articul,
            'quantity': int(request.POST.get('quantity', 0)),
            'price': float(obj.price)
        }

        return HttpResponse(json.dumps(response_data), content_type="application/json")
Ejemplo n.º 2
0
    def get_context_data(self, **kwargs):
        context = super(CatalogView, self).get_context_data(**kwargs)
        try:
            context['object'] = Catalog.objects.get(slug=context['slug'], is_show=True)
            context['leftbar'] = get_leftbar(Catalog, context['object'])
            catalog_id = context['leftbar']['root_obj'].id
            context['current_mainmenu'] = context['mainmenu'].filter(
                catalog_id=catalog_id
            ).first()

            context['objects'] = Product.objects.filter(catalog=context['object'], is_show=True).order_by('-id')
            context['objects'] = sort_by_params(self.request, context['objects'])
            context['objects'] = get_pagination(self.request, context['objects'])
        except Catalog.DoesNotExist:
            # --- redirect in product  ---
            self.template_name = 'product/templates/product_detail.html'
            context = ProductDetail.get_context_for_catalog(context)
        return context
Ejemplo n.º 3
0
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
from user.views import index, RegisterView, LoginView, logout
from product.views import (
    ProductList,
    ProductCreate,
    ProductDetail,
    ProductListAPI,
    ProductDetailAPI,
)
from order.views import OrderCreate, OrderList

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', index),
    path('register/', RegisterView.as_view()),
    path('login/', LoginView.as_view()),
    path('logout/', logout),
    path('product/', ProductList.as_view()),
    path('product/create/', ProductCreate.as_view()),
    path('product/<int:pk>/', ProductDetail.as_view()),
    path('order/', OrderList.as_view()),
    path('order/create/', OrderCreate.as_view()),
    path('api/product/', ProductListAPI.as_view()),
    path('api/product/<int:pk>/', ProductDetailAPI.as_view()),
]
Ejemplo n.º 4
0
    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
from stuser.views import index, RegisterView, LoginView
from product.views import ProductList, ProductCreate, ProductDetail
from order.views import OrderCreate

urlpatterns = [
    path('admin/', admin.site.urls, name='admin'),
    path('', index, name='index'),
    path('register/', RegisterView.as_view(), name='register'),
    path('login/', LoginView.as_view(), name='login'),
    path('product/', ProductList.as_view(), name='product'),
    path('product/<int:pk>/', ProductDetail.as_view(), name='productdetail'),
    path('product/create/', ProductCreate.as_view(), name='productcreate'),
    path('order/create/', OrderCreate.as_view(), name='ordercreate'),
]

#  path('admin/', admin.site.urls),
#     path('', index),
#     path('register/', RegisterView.as_view()),
#     path('login/', LoginView.as_view()),
#     path('product/', ProductList.as_view()),
#     path('product/<int:pk>/', ProductDetail.as_view()),
#     path('product/create/', ProductCreate.as_view()),
#     path('order/create/', OrderCreate.as_view()),
Ejemplo n.º 5
0
    https://docs.djangoproject.com/en/3.1/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
from users.views import home, LoginView, logout, RegisterView
from product.views import ProductCreate, ProductList, ProductDetail
from order.views import OrderCreate, OrderList

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', home),
    path('user/login/', LoginView.as_view()),
    path('user/logout/', logout),
    path('user/register/', RegisterView.as_view()),
    path('product/create/', ProductCreate.as_view()),
    path('product/list/', ProductList.as_view()),
    path('product/detail/<int:pk>', ProductDetail.as_view()),
    path('order/create/', OrderCreate.as_view()),
    path('order/list/', OrderList.as_view()),
]
Ejemplo n.º 6
0
The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/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
from fcuser.views import index, RegisterView, LoginView
from product.views import ProductList, ProductCreate, ProductDetail
from order.views import OrderCreate

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', index),
    path('login/', LoginView.as_view()),
    path('register/', RegisterView.as_view()), # 클래스는 as_view() 함수 이용해야함
    path('product/', ProductList.as_view()),
    path('product/<int:pk>/', ProductDetail.as_view()), # int 형일 때 pk라는 변수에 저장됨
    path('product/create/', ProductCreate.as_view()),
    path('order/create/', OrderCreate.as_view()),
]
Ejemplo n.º 7
0
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
from fcuser.views import index, RegisterView, LoginView
from product.views import ProductList, ProductCreate, ProductDetail
from order.views import OrderCreate, OrderList

urlpatterns = [
    path("admin/", admin.site.urls),
    path("", index),
    path("register/",
         RegisterView.as_view()),  # 뷰클래스 사용시 as_view() 함수를 사용해야합니다
    path("login/", LoginView.as_view()),
    path("product/", ProductList.as_view()),
    path("product/<int:pk>/", ProductDetail.as_view()),
    # path("product/create", ProductCreate.as_view()) 로 입력해서 계속 에러가 났엇음 슬래시 주의할것
    path("product/create/", ProductCreate.as_view()),
    path("order/", OrderList.as_view()),
    path("order/create/", OrderCreate.as_view()),
]
Ejemplo n.º 8
0
from django.conf.urls import patterns, url
from django.contrib import admin
from product.views import ProductList, ProductDetail, CommentAdd

admin.autodiscover()

urlpatterns = patterns(
    '',
    url(r'^$', ProductList.as_view(), name='products'),
    url(r'^products/(?P<slug>.+)/comment/$', CommentAdd.as_view(), name='comment_add'),
    url(r'^products/(?P<slug>.+)/like/$', 'product.views.like', name='like'),
    url(r'^products/(?P<slug>.+)/$', ProductDetail.as_view(), name='product_view'),
                       )
Ejemplo n.º 9
0
The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/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, include
from product.views import ProductDetails, ProductList, ProductDetail
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
from user.views import RegisterDetail, LoginDetail

urlpatterns = [
    path('api/products', ProductList.as_view()),
    path('api/products/<int:pk>', ProductDetail.as_view()),
    path('admin/', admin.site.urls),
    path('api-auth', include('rest_framework.urls')),
    path('api/token', TokenObtainPairView.as_view()),
    path('api/token/refresh', TokenRefreshView.as_view()),
    path('api/register', RegisterDetail.as_view()),
    path('api/login', LoginDetail.as_view()),
]
Ejemplo n.º 10
0
from django.conf.urls import url
from product.views import manage_product_categories, manage_product_types, manage_units_of_measurement, ProductList, ProductDetail, ProductCreate, ProductUpdate, ProductDelete, manage_pricelist

urlpatterns = [
    url(r'^$', ProductList.as_view(), name='product-list'),
    url(r'^detail/(?P<pk>[0-9]*)/$',
        ProductDetail.as_view(),
        name='product-detail'),
    url(r'^add/$', ProductCreate.as_view(), name='product-add'),
    url(r'^update/(?P<pk>[0-9]*)/$',
        ProductUpdate.as_view(),
        name='product-update'),
    url(r'^delete/(?P<pk>[0-9]*)/$',
        ProductDelete.as_view(),
        name="product-delete"),
    url(r'^type/$', manage_product_types, name='product-type-list'),
    url(r'^uom/$', manage_units_of_measurement, name='uom-list'),
    url(r'category/$', manage_product_categories,
        name='product-category-list'),
    url(r'pricelist/$', manage_pricelist, name="pricelist"),
]
Ejemplo n.º 11
0
from django.contrib import admin
from django.conf.urls import include
from django.urls import path

from product import views
from product.views import PostDetail, PostDetailCreate, ProductDetail, AddressDetail, CancelOrderDetail
urlpatterns = [
    path('api/v1/get_products/', views.get_products),
    path('api/v1/get_product/<int:id>/', ProductDetail.as_view()),
    path('api/v1/post_product/', views.post_product),
    path('api/v1/get_addresses/', views.get_addresses),
    path('api/v1/post_address/', views.post_address),
    path('api/v1/get_address/<int:id>/', AddressDetail.as_view()),
    path('api/v1/get_medicines/', views.medicine_list),
    path('api/v1/medicine_search/', views.medicine_search),
    path('api/v1/get_cancel_orders/', views.get_cancel_orders),
    path('api/v1/post_cancel_order/', views.post_cancel_order),
    path('api/v1/get_cancel_order/<int:id>', CancelOrderDetail.as_view()),
    path('api/v1/post/<int:id>/', PostDetail.as_view()),
    path('api/v1/post/', PostDetailCreate.as_view())
]
Ejemplo n.º 12
0
            register_date__date=target_date).count()
        order_data[date_key] = order_cnt
    extra_context = {'orders': order_data}

    return orig_index(request, extra_context)


urlpatterns = [
    re_path(
        r'^admin/manual/$',
        TemplateView.as_view(template_name='admin/manual.html',
                             extra_context={
                                 'title': '메뉴얼',
                                 'site_title': 'Django_project',
                                 'site_header': 'Django_project'
                             })),  #주소가 정확히 일치할때 연결하겠다
    path('admin/', admin.site.urls),
    path('baton/', include('baton.urls')),
    path('', index),
    path('register/', RegisterView.as_view()),  #클래스는 .as_view()사용
    path('login/', LoginView.as_view()),
    path('logout/', logout),
    path('product/', ProductList.as_view()),
    path('product/<int:pk>/', ProductDetail.as_view()),  #숫자형인데 bk란 변수로 채워짐
    path('product/create/', ProductCreate.as_view()),
    path('order/', OrderList.as_view()),
    path('order/create/', OrderCreate.as_view()),
    path('api/product/', ProductListAPI.as_view()),
    path('api/product/<int:pk>', ProductDetailAPI.as_view())
]