SHARE
TWEET

Untitled

a guest Jun 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.     "detail": "CSRF Failed: CSRF token missing or incorrect."
  3. }
  4.      
  5. from django.urls            import path,re_path,include
  6. from django.utils.text      import slugify,camel_case_to_spaces
  7. from PaymentsManagerApp     import views, models
  8. from rest_framework         import routers
  9.  
  10. APP_NAME = 'PaymentsManagerApp'
  11. router = routers.DefaultRouter()
  12.  
  13. router.register(r'payments', views.PaymentViewSet)
  14.  
  15. payments_list = views.PaymentViewSet.as_view({
  16.     'get':'list',
  17.     'post':'create'
  18. })
  19.  
  20. def urlpattern_from_route(route):
  21.     if "regex" in route and route['regex']:
  22.         path_method = re_path
  23.     else:
  24.         path_method = path
  25.     return path_method(route['path'],route['view'].as_view(),name=route['name'] if "name" in route else None)
  26.  
  27. routes_views = list(map(urlpattern_from_route,routes))
  28. route_services = [
  29.  
  30. payment_detail = views.PaymentViewSet.as_view({
  31.     'get':'retrieve',
  32.     'put':'update',
  33.     'patch':'partial_update',
  34.     'delete':'destroy'
  35. })
  36.  
  37. route_services = [
  38.     path('payments/', payments_list, name='rest_payments_list'),
  39.     path('payments/<int:pk>/', payment_detail, name='rest_payment_detail'),
  40. ]
  41.  
  42. urlpatterns = routes_views + route_services
  43.      
  44. import os
  45. import json
  46. from datetime                           import datetime, timedelta
  47. from django.shortcuts                   import render
  48. from PaymentsManagerApp                 import urls, models, serializers
  49. from FrontEndApp                        import urls as Fronturls
  50. from django.shortcuts                   import render,redirect
  51. from django.contrib.auth.mixins         import LoginRequiredMixin
  52. from django.contrib.contenttypes.models import ContentType
  53. from django.views.generic               import View
  54. from django.contrib.auth.models         import Permission
  55. from GeneralApp.utils                   import get_catalogs
  56. from django.contrib.staticfiles         import finders
  57. from django.utils.text                  import slugify,camel_case_to_spaces
  58. from rest_framework                     import viewsets, permissions
  59. from rest_framework.response            import Response
  60. from django_filters.rest_framework      import DjangoFilterBackend
  61. from rest_framework.response            import Response
  62. from rest_framework.filters             import OrderingFilter, SearchFilter
  63. from django.db.models                   import Q
  64.  
  65. class PaymentViewSet(viewsets.ModelViewSet):
  66.         exclude_from_schema = True
  67.  
  68.         permission_classes = (permissions.IsAuthenticated,)
  69.         queryset = models.Payment.objects.all()
  70.         serializer_class = serializers.PaymentSerializer
  71.         filter_backends = (DjangoFilterBackend, SearchFilter, OrderingFilter,)
  72.         search_fields = ('payment_type', 'creation_user__username', 'provider__name', 'invoice', 'payment_method_type', 'payment_document_number')
  73.         filter_fields = ('id', 'payment_type', 'creation_user', 'provider', 'is_payment_requested', 'is_paid', 'payment_method_type')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top