-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added swagger for code documantation and configuration pytest
- Loading branch information
1 parent
7d2e3fa
commit 9d3d10d
Showing
15 changed files
with
172 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,53 @@ | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin | ||
|
||
from .forms import CustomUserChangeForm, CustomUserCreationForm | ||
from .models import CustomUser | ||
|
||
# Register your models here. | ||
|
||
|
||
# !CustomUserAdmin | ||
class CustomUserAdmin(UserAdmin): | ||
add_form = CustomUserCreationForm | ||
form = CustomUserChangeForm | ||
model = CustomUser | ||
list_display = ( | ||
"email", | ||
"is_staff", | ||
"is_active", | ||
) | ||
list_filter = ( | ||
"email", | ||
"is_staff", | ||
"is_active", | ||
) | ||
fieldsets = ( | ||
(None, {"fields": ("email", "password")}), | ||
( | ||
"Permissions", | ||
{"fields": ("is_staff", "is_active", "groups", "user_permissions")}, | ||
), | ||
) | ||
add_fieldsets = ( | ||
( | ||
None, | ||
{ | ||
"classes": ("wide",), | ||
"fields": ( | ||
"email", | ||
"password1", | ||
"password2", | ||
"is_staff", | ||
"is_active", | ||
"groups", | ||
"user_permissions", | ||
), | ||
}, | ||
), | ||
) | ||
search_fields = ("email",) | ||
ordering = ("email",) | ||
|
||
|
||
admin.site.register(CustomUser, CustomUserAdmin) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.contrib.auth.forms import UserChangeForm, UserCreationForm | ||
|
||
from .models import CustomUser | ||
|
||
|
||
# !CustomUserCreationForm | ||
class CustomUserCreationForm(UserCreationForm): | ||
class Meta: | ||
model = CustomUser | ||
fields = ("email",) | ||
|
||
|
||
# !CustomUserChangeForm | ||
class CustomUserChangeForm(UserChangeForm): | ||
class Meta: | ||
model = CustomUser | ||
fields = ("email",) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.urls import path | ||
|
||
from .views import hello_world | ||
|
||
app_name = "users" | ||
urlpatterns = [path("sayhello/", hello_world, name="hello_world")] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
from django.shortcuts import render | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
|
||
# Create your views here. | ||
|
||
|
||
@api_view(["GET", "POST"]) | ||
def hello_world(request): | ||
if request.method == "POST": | ||
return Response({"message": "Got some data!", "data": request.data}) | ||
return Response({"message": "Hello, world!"}) |
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
Empty file.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def add_numbers(a, b): | ||
return a + b | ||
|
||
|
||
def test_add_numbers(): | ||
result = add_numbers(2, 3) | ||
assert result == 5 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: Django DRF Ecommerce | ||
version: 1.0.0 | ||
description: This project purpose creating ecommerce api for business company | ||
paths: | ||
/users/sayhello/: | ||
get: | ||
operationId: users_sayhello_retrieve | ||
tags: | ||
- users | ||
security: | ||
- cookieAuth: [] | ||
- basicAuth: [] | ||
- {} | ||
responses: | ||
'200': | ||
description: No response body | ||
post: | ||
operationId: users_sayhello_create | ||
tags: | ||
- users | ||
security: | ||
- cookieAuth: [] | ||
- basicAuth: [] | ||
- {} | ||
responses: | ||
'200': | ||
description: No response body | ||
components: | ||
securitySchemes: | ||
basicAuth: | ||
type: http | ||
scheme: basic | ||
cookieAuth: | ||
type: apiKey | ||
in: cookie | ||
name: sessionid |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
[tool:pytest] | ||
DJANGO_SETTINGS_MODULE = config.settings | ||
python_files = test_*.py | ||
addopts = --cov -x |
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