This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<br> | |
<h2>Thank you for your order {{ order.full_name }}</h2> | |
<h3>Your Order ID: {{ order.short_uuid }}</h3> | |
<h3>Shipping Details:</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import status | |
from rest_framework.response import Response | |
from rest_framework_simplejwt.authentication import JWTAuthentication | |
# parametre olarak verilen methodlara sadece admin user erişebilir demek | |
# db ile iletişim kuruluyor, admin kullanıcısı olduğu için db ile iletişimini önemsemedim | |
def only_admin(methods=[], err_message="Admin authorization required."): | |
def decorator(view_function): | |
def decorated_function(request, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Resources | |
Simple JWT Token bearer authentication : https://gist.github.com/ridvanaltun/6e3a7513519f998bd3f770c117e18f07 | |
custom Decorators : https://docs.djangoproject.com/en/2.2/topics/class-based-views/intro/#decorating-the-class | |
''' | |
from django.http import response | |
from functools import wraps | |
## is authenticated | |
def IsLogin(func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.exceptions import ValidationError | |
''' | |
Custom file validation function | |
''' | |
def ValidFile(value): | |
''' | |
1 mb = 1,048,576 bytes | |
15 mb = 15728640 bytes | |
''' |