From 327b81ba785ea774c26185b5424abdbbd8c39042 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 10 Mar 2024 20:56:23 -0300 Subject: [PATCH 01/42] Definindo os models --- api/admin.py | 3 - api/apps.py | 6 -- api/models.py | 3 - api/tests.py | 3 - api/views.py | 3 - .../__pycache__/settings.cpython-312.pyc | Bin 2550 -> 2566 bytes bookstore/settings.py | 2 + db.sqlite3 | Bin 131072 -> 188416 bytes order/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 163 bytes order/__pycache__/admin.cpython-312.pyc | Bin 0 -> 251 bytes order/__pycache__/apps.cpython-312.pyc | Bin 0 -> 467 bytes order/admin.py | 1 + order/migrations/0001_initial.py | 40 +++++++++++++ .../__pycache__/0001_initial.cpython-312.pyc | Bin 0 -> 1400 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 174 bytes order/models.py | 3 - order/models/__init__.py | 1 + .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 208 bytes .../models/__pycache__/order.cpython-312.pyc | Bin 0 -> 758 bytes order/models/order.py | 7 +++ {api => order/serializers}/__init__.py | 0 order/serializers/order-serializer.py | 16 +++++ poetry.lock | 41 ++++++++++++- product/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 165 bytes product/__pycache__/admin.cpython-312.pyc | Bin 0 -> 277 bytes product/__pycache__/apps.cpython-312.pyc | Bin 0 -> 473 bytes product/admin.py | 1 + product/migrations/0001_initial.py | 56 ++++++++++++++++++ .../__pycache__/0001_initial.cpython-312.pyc | Bin 0 -> 1777 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 176 bytes product/models.py | 3 - product/models/__init__.py | 2 + .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 256 bytes .../__pycache__/category.cpython-312.pyc | Bin 0 -> 951 bytes .../__pycache__/product.cpython-312.pyc | Bin 0 -> 967 bytes product/models/category.py | 10 ++++ product/models/product.py | 11 ++++ .../serializers}/__init__.py | 0 product/serializers/category-serializer.py | 0 product/serializers/product-serializer.py | 0 pyproject.toml | 1 + requirements.txt | 13 ++++ 42 files changed, 201 insertions(+), 25 deletions(-) delete mode 100644 api/admin.py delete mode 100644 api/apps.py delete mode 100644 api/models.py delete mode 100644 api/tests.py delete mode 100644 api/views.py create mode 100644 order/__pycache__/__init__.cpython-312.pyc create mode 100644 order/__pycache__/admin.cpython-312.pyc create mode 100644 order/__pycache__/apps.cpython-312.pyc create mode 100644 order/migrations/0001_initial.py create mode 100644 order/migrations/__pycache__/0001_initial.cpython-312.pyc create mode 100644 order/migrations/__pycache__/__init__.cpython-312.pyc delete mode 100644 order/models.py create mode 100644 order/models/__init__.py create mode 100644 order/models/__pycache__/__init__.cpython-312.pyc create mode 100644 order/models/__pycache__/order.cpython-312.pyc create mode 100644 order/models/order.py rename {api => order/serializers}/__init__.py (100%) create mode 100644 order/serializers/order-serializer.py create mode 100644 product/__pycache__/__init__.cpython-312.pyc create mode 100644 product/__pycache__/admin.cpython-312.pyc create mode 100644 product/__pycache__/apps.cpython-312.pyc create mode 100644 product/migrations/0001_initial.py create mode 100644 product/migrations/__pycache__/0001_initial.cpython-312.pyc create mode 100644 product/migrations/__pycache__/__init__.cpython-312.pyc delete mode 100644 product/models.py create mode 100644 product/models/__init__.py create mode 100644 product/models/__pycache__/__init__.cpython-312.pyc create mode 100644 product/models/__pycache__/category.cpython-312.pyc create mode 100644 product/models/__pycache__/product.cpython-312.pyc create mode 100644 product/models/category.py create mode 100644 product/models/product.py rename {api/migrations => product/serializers}/__init__.py (100%) create mode 100644 product/serializers/category-serializer.py create mode 100644 product/serializers/product-serializer.py create mode 100644 requirements.txt diff --git a/api/admin.py b/api/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/api/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/api/apps.py b/api/apps.py deleted file mode 100644 index 878e7d5..0000000 --- a/api/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class ApiConfig(AppConfig): - default_auto_field = "django.db.models.BigAutoField" - name = "api" diff --git a/api/models.py b/api/models.py deleted file mode 100644 index 71a8362..0000000 --- a/api/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/api/tests.py b/api/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/api/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/api/views.py b/api/views.py deleted file mode 100644 index 91ea44a..0000000 --- a/api/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index 2b752d8dfa3f536719c67f8132a84f6e1ea2ced1..a0cbb0fdae0a465d3f4118ed5bd86e1350789fc9 100644 GIT binary patch delta 80 zcmew++$O?%nwOW00SK;Yze_dW$UBjVkz?|FrfCAVSo4cgQj2b}7Zl~ElqQ#KHf8?G j#K^l@n{7K2qsHXN9D(edLQD;OpTs6xb8cr*0~!GU2s{`v delta 63 zcmZn@`6kSJnwOW00SK14yh@ea$UBjVk!|vPrfHj9nZGhIa&NX~+s?$OHu*D0AUnGd RQv=^8p~>Ey+gVhAIsipz5kCL` diff --git a/bookstore/settings.py b/bookstore/settings.py index 4cae424..7fb9146 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -37,6 +37,8 @@ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "order", + "product", ] MIDDLEWARE = [ diff --git a/db.sqlite3 b/db.sqlite3 index 07c4bca724d4d1afeaed8f2eabeb446ec266b6a1..5d2a7293c527601bcac32866a762b3e49e5163be 100644 GIT binary patch delta 4616 zcmeHKU2Gf25xxBv4YzM4z}ef`Z)d-motxcTTeGg+;IBHj4KWNeg8%gQ$cy`;JBFB%GjEx( zsteuL1|C5FM7OV(*U>iI5hGaa5Ctsz>>pRT9zVZU#)USBD)+9IR^QE@bB|K;;-_j`GWW! z$Ly-lXJ%k{zim~KFQ(`s)9Iq5DI}`c>&2*G)RvPAa#?P{HB_5OPXn1foi65EkqwoB z^tdrn^@nWfT&~3;?r(x54DyGpgr4rM!A|cFxiBUWvFhZSP&zk?8*JcoYDBAM%bGcz znhul(Fwh&cYQ&nXX}t9AU_VB<10116Vs4NkJ&zNQ`$L>g$w26Y8kjv8Gl4-m9|NS5 zA^rZ{7~~q}G%5x_BSJbGr)IxvGWmo9Rqj}1S2q&=CHzr%SNNH5UHGQ(ys#>q622%L zz{&KHL+xc@7+Sa4w}XWsv~Q}nq19Q@4Df7c!4EBaXFEh7bG z(G%z-I*uMiNi>NPD2hTjDj#&um`wmSACX=nJw&=SX_bg{5jjZYfF`+qBArC;A#(S| z%I{w|HPmf-lR>`jw{7oOZVDG2mo0tflkCg<-)xiCB!9^CCj1=wndfT{9D!8*dkP5b z_22C4s^5GBV$j7LtNxvvt)DBxRj9vn6c(U&r|5P=<*Vg%rXZ(R%BNHLQth>~@Otg= z5vbO$%))A~ic1J$=NWb$Eq31&ZVN$&i4WPIv;D>PhP8+Lfb&^yS&ntR1~-6ZlIQ>$ zVJ7gD#?O+lkcY~laZb!nKqajdbMjOA2GP_v-p$Pi1;4P7F*z1rQZrkjho?^@rxudZ z(Yc3{k4v7dV4aL+JktE!)>AyvUJp%6HKpV{fl4CIi86NJiO+U`lED0PxmadAu@t8& z+ET+qcSm0}qSR#b^Xb#o2>H?ht61SCU_E%(>?zAs052Pp$0LzkHj-K?D(9(X+ES#y zdS2L}QY~%iXtNiFuHE!KxwTI+_K0lJ`r|Q9OixU}v(qG>DFfQlRcW8LRPWRGV`1u{ z+2q!_QJr$cw$r&dx>82TE5&lHQh=R^>h-qvN&y1BbODWJGrEVODL{h{9SKy_F-{By z;h9(`KjM`ewTss^|LZuGJ|~sKK%FmOKa>-8#>OQKcV-~FVO4g+vqa7 zgqF~8T;bv<(Q9KF=YY-^_a)LrvyQH_q~a_QV? zoRo$Rg!YlD&|zSc>1L!_t=%1STn07`cmiL4kQ0+$s0=i_p=wv_)XD`cFy(l5DUr#J zW|~L^TO->va>uMYSZSNBoAw0Orw(#rGz!lK$h)f>nj-7#G@FgY+yS9got}oi zt%}$TbnROO2;NI+(rV2Y5}fGu!unz}UyZI|Rxa(`lAcDZYPBq?f%`b&{|g7a+W2(Q zc2~bP+`|cvXWj1suWFxVMvb5~@GehyV;*KtFAa?>qlryhYWR-&BHzymkC*-b0be$* ziT~>Ze)fJ3_~u;G$ePPaxgghGR6s1?YM7HRWJ}7qva($CNM-q{vNX3iJ4?!>l9fFY zzO2Z3xg@O=FDUtT)Vbs|^&4p2iY4cyE8H^h*=rV0Tq$i(9jfob0k)V@eqm)V^`nBg-6e->W>?^d1{T+g{|I9GDq6RoW<)r4NmdD2@mX>71mlmfMq4L5THz@1`>vb2SQTvx_S# zGB)N;HsF?=E}F$yD8$^yAQY(0$dH-Grq2fQ1jF>bnT)0&pBYVmn9iue)ocQFj`DVa z492yL%#A8alixBsZ$Fd8Xu`VvxFh3vrs=lcjJvnHc`)`fGIDKZeDL3YQUi+s8-EuA b|6Bf>{HOT$@XzP(0>)t(|Msr)jAaG@G*G4R diff --git a/order/__pycache__/__init__.cpython-312.pyc b/order/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dbcc97333b93f1a8a99c991db30ecbc89f50c07a GIT binary patch literal 163 zcmX@j%ge<81j+$#QbF`%5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!a&oqc2`x@7Dvrrb zEXhcXami0E%}vcKDUL}^N=%N44@%5S$iI30B%PfhH k*DI*}#bJ}1pHiBWYFESxG?EdBi$RQ!%#4hTMa)1J04C`v)c^nh literal 0 HcmV?d00001 diff --git a/order/__pycache__/admin.cpython-312.pyc b/order/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ea50caffff4b6ab3fae761d782ee91ba6388cf47 GIT binary patch literal 251 zcmX@j%ge<81osr*rA7nk#~=<2FhLogWq^$73@HpLj5!Rsj8Tk?3@J=0%sEWC%u&pY z43#XJtS>=IH5qTQCZ^^iZyg=duGb1D8T?U13 MYz&N2MVvqp0D4S9QUCw| literal 0 HcmV?d00001 diff --git a/order/__pycache__/apps.cpython-312.pyc b/order/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7b423209a02341dcf1ce6d7de70d2db9112c5f3a GIT binary patch literal 467 zcmXv~Jxc>Y5S_gbiTMzTB3M`mB3yH|hy*l2yC{Oqv9N5in;5;jJ$LVl*a`Uo7D9f5 z_)}~w!-18RU?D`CRPNrzEoR>Ado#Q9UK@=n=(Bh6#h-NkFvb6ImtelH!4w!U6hedo zgusF`VAcef&C!cp>H=%*ck{t9`6aJz%iZB%Xy+HdXgz|fCsw(=AHp4 zBC%VX0$uFKLdKie&oAHpNp9rOs z{4uQ^TSq)(NNV?5CeKo+oT$f>8>!t~YIkGSBI8l9yY{BGt6id7zeK0Msk=P;lfp5d z*&gv7;beX)bvUy$EE)?$*_(Fafc7Qd#{nF)BU0Gf+WNqDeK&HQ9uXg6h%n(@*d+YD zZ6ikt&L9fxHbzc_Aerl9*K_dDevF1h2@$4F?h`}`UnATKLS*}nhp= zVDM2uas%o`15g6rrqh5TgqNr})#R8jk&ax{gW&_?Eh5_~oNW`;w(0B)dWiA`+x}|c z^q4V~@{`ChYZ=kPZ=8PLX;DLn`pAdKZx1n>QnFA#Jh*EgKHAy0_a1KV+$V+C7A^|O zTqDhJk4-3MPlXgdbvt#Mdy~aO7WN!}cn~m}Db!|wk=yY>Wjul)*&rKXn9WbC9<}I_P|4a6k4d|v@Ltz@nPWE zRx1b|hY`KW3Rq*Ti`Qh$_O03<;ylGo39Eki8zs-ci(={N?pOlKMk1HLQ%7<+mdn4$ zqspDQa_0}ZJ{AQ{dU}6c0Lt6!crBLKlBH|ZWBGcbm7h09S~=Fr$)=HPR1%#r=Zd&| zWh}}|rEv+AR!&!IKQu?HwRp95`r+=Mt9MTq@4e7&B-$o(-i)=)M6dj8{A7&uTCCSb z`t4Z1J<=Po-bhy78LixkS8kn)0)vz&-#AW3xiN%WzZh3guqOA7}IR34V`?>{*BG<&6c7 g|PMgRZ+ literal 0 HcmV?d00001 diff --git a/order/migrations/__pycache__/__init__.cpython-312.pyc b/order/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9e6156fdfbee01804131627250ef1b22cb5a04f3 GIT binary patch literal 174 zcmX@j%ge<81j+$#QbF`%5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!@^!X~2`x@7Dvrrb zEXhcXami0E%}vcKDUL}^N=%N44@%5S$$<0hJN-W9D v&nu3JkI&4@EQycTE2#X%VUwGmQks)$SHuc5oe_wOL5z>gjEsy$%s>_ZZFnwu literal 0 HcmV?d00001 diff --git a/order/models.py b/order/models.py deleted file mode 100644 index 71a8362..0000000 --- a/order/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/order/models/__init__.py b/order/models/__init__.py new file mode 100644 index 0000000..0065b08 --- /dev/null +++ b/order/models/__init__.py @@ -0,0 +1 @@ +from .order import Order \ No newline at end of file diff --git a/order/models/__pycache__/__init__.cpython-312.pyc b/order/models/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7951c7b12f08e11a667ab7f7c1a792dbeb5d2323 GIT binary patch literal 208 zcmX@j%ge<81YElBQYC=&V-N=hn4pZ$0zk%eh7^Vr#vF!R#wbQchDs()=9i2>VNJ$c zto}tQsYQO8Ot)C`L98NXp!iCL&mi5uJe{p#LW@(2ieqvUOEOYpT=J7kb5rw5ieplf z5|d-%gA(&n@^j;3lJfJji%as0Qe(ho#N_6uq~;XI#K&jmWtPOp>lIY~;;;b$Jf23cMVVtim`WMsU@AW_5yaIRzJupJkH4$jA3dGn4Vp24ipB1|N9_fl*D=XR7 zH|f|YFNKWIAQogj=8UAhM4<6Bro4BV3Sbn@WGLVOD7c7#t7$;>LHX}M#ndF|SUb{` z=a!~%_5Z|`MgEn4_mA~Ixs}YY&D?y%3FRHpo7oNgXivZ#i?C>&CUnED=4Ff{KcpDv z6^w|-x@ypZ?)E_PfkT0zJQMSdT?eu9txRjP#LnS`1bQq`oo#-LWxV(hiYAru$ zEw@*4BNanAgo*6-qSIRRX_Uks?fN|rZ~75oA@;hA?Zt^G=`kt5 zQ`1(CGt9UpicO6?D|Uq0hx2-K^x~}EJgGN7Jpa6MT3>v%dR}de?wwT|C)LLLt&h(> zZ69u*R+nD4`PEs04ZEDrk%1rWFo$%N*6W2TM;+@Fu9AGS2=1{c;r*`Tr^#*+sFa)Q z@@c3R=19.1.0)"] bcrypt = ["bcrypt"] +[[package]] +name = "django-rest-framework" +version = "0.1.0" +description = "alias." +optional = false +python-versions = "*" +files = [ + {file = "django-rest-framework-0.1.0.tar.gz", hash = "sha256:47a8f496fa69e3b6bd79f68dd7a1527d907d6b77f009e9db7cf9bb21cc565e4a"}, +] + +[package.dependencies] +djangorestframework = "*" + +[[package]] +name = "djangorestframework" +version = "3.14.0" +description = "Web APIs for Django, made easy." +optional = false +python-versions = ">=3.6" +files = [ + {file = "djangorestframework-3.14.0-py3-none-any.whl", hash = "sha256:eb63f58c9f218e1a7d064d17a70751f528ed4e1d35547fdade9aaf4cd103fd08"}, + {file = "djangorestframework-3.14.0.tar.gz", hash = "sha256:579a333e6256b09489cbe0a067e66abe55c6595d8926be6b99423786334350c8"}, +] + +[package.dependencies] +django = ">=3.0" +pytz = "*" + [[package]] name = "factory-boy" version = "3.3.0" @@ -148,6 +176,17 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "pytz" +version = "2024.1" +description = "World timezone definitions, modern and historical" +optional = false +python-versions = "*" +files = [ + {file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"}, + {file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"}, +] + [[package]] name = "six" version = "1.16.0" @@ -189,4 +228,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "53e5b2a828b776d376ea78a8931feee2baf8a7d3c3e8515c368cc70d5a208f90" +content-hash = "5c25d985b0dd31a20b78db779261d77bd22c90b449a19a5a57659f8b419c82cd" diff --git a/product/__pycache__/__init__.cpython-312.pyc b/product/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b6765e97adc345b5834e93da0c0f4b3fac061ea6 GIT binary patch literal 165 zcmX@j%ge<81f~IRQbF`%5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!a&fkb2`x@7Dvrrb zEXhcXami0E%}vcKDUL}^N=%N44@%5S$5bWNUhj`*AY@)EqeSnA{XDlL^ECa{v&aj^D%p5bb!G4L~;J26<4;UF; zBEkjYMfT`j2h~+jR2Tg^ogM2<$;&jR+zUX`iUHPE}TC z2xC^|>u9eqEuVHA=bw literal 0 HcmV?d00001 diff --git a/product/__pycache__/apps.cpython-312.pyc b/product/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e28f29b63f06c9bf12a70db73f11aee37e81de85 GIT binary patch literal 473 zcmXv~F-yZh6n>YaT3ah3Rd8@{5wc_y5fN*P;!=v>5)O`Q?pmu!F6NS*l8UK@=XsJGwy;!i4n=;HrXN-*D3UJuY?Q6EqNpvx!D#3ebP-Wm%$o{KfrE<}xCTS6$qd&T zo3@oTda+=smlW;yJM4yrL*cN#69~qA>70&+tuzs5Bkr?oIV#j$yOLE232DFy$!dfs zaq4TlO2}PG{gT;Wd_Yq_AykbZgM5aixo4Q`7W{C z0pfNt=M5qmvM@%@5<9|#GX^p+4!Jge5RXo`SeOXWxe4fGJ9WVPflG%taRQEMPo2YM z{?;D@ryopE^6VFiyT8Wjpqnw_K;JzU8GoQ17XfHJQJNj zl9SAkCRU#*CbD#I8^>MK*U3NLw~VJg!c!2rnqxF+i=X^R@iENRP1V|UXm8@U<(nqv zRn0T@5V1=@w59r{M`j})hT^vjWI`7w9y&Jk3G9q?Bj!k&8o@iXZE#W>@_H^bBUE|x zM`oQog|MFeKo)RP2?;0)PAdwTH{V1=&M3-LUo~kwq9qK=@Ca?3fvAZrh%C)Ou0!V+ zPgTM?ZO}<|==k8w9YeoOD!5M5#Hq@*>I}t4q!N*sxntWVQmx^^CVJ*YqWI8uNvu6| z-y#=-hL*D%s@2-G=^nw-b`uR>iSNNFi3(mns@$kOCfDQE8mhOAYIkkTZy?KaYpAYj zHRTJ{f_6ix)opv%^=t>#hLx#}U!2;?%E}dG$hO>UIrP~IH!8SIQs|f9cqaGa-tmR} zi_ZrXg-JZ16k(Lg%u5=?1KI&&L1_gP4u2+yd1^H0y7On@vhsWaOzF49jOC7QF-L<32 z53nnKHsE5!QxfE)pjh6&-Yb?n#qy!oE#3@-j|Z2t;>;N*rqY9@KV>NWw+#O&7s6_d zvRdm%Ye(0*(kFp%yPqvg$dD8(m|xw0(wkrH%mg39CW{F6ZVa`1MJrk*FMFTbDT zzxvcEkFMYW8O;>jQ7zpr!+O|#VZ%k2v`k?k_5&ilPTq`q`Id8qsPwsZ>3cDVF%0t? Y4;cB3zsm5h(mkQn5lX)TqJ-AJ10!0v3;+NC literal 0 HcmV?d00001 diff --git a/product/migrations/__pycache__/__init__.cpython-312.pyc b/product/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..68f1ef71bd9a0f3d468d3db1d30353e2d5749293 GIT binary patch literal 176 zcmX@j%ge<81f~IRQbF`%5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!@^`k12`x@7Dvrrb zEXhcXami0E%}vcKDUL}^N=%N44@%5S$4d$Xm(q z8Avkx@^-e02`x@7DvrrbEXhcXami0E%}vcKDUL}^N=%N44@%5S$4BO~Ko2Dy6- JGDRFfJ^*-IMkoLP literal 0 HcmV?d00001 diff --git a/product/models/__pycache__/category.cpython-312.pyc b/product/models/__pycache__/category.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c172274a5ea2f27352e5566caf471203fce840cc GIT binary patch literal 951 zcmZ`%J#5oJ6uyh?#)%z%LI+4A5p_UBLYWXlg&1fFLRC9ZV2CW8F1~A;^lZ0hyCPMG z3?0&`Y*`tLS~0`Mh{QsqNQo>lF?B&mfu$37cAJKwH@y4a-S>XJd-pAu%L1`J7k<$d z2*6M2TrBMzj28sx0RjkQz=1UgK?*zvB()ESLSak22)Nvjl?2z6wp!LsrBjB{jN=i? zeEX6Iz@*4WaoPhE)F1)1R0>d~rB4$ROyEiCSTrhEO^aD(;!RtkoTw94`pR4yQ3P{l z(ySgc^V69UELiDDzAVxALCt7q%GpR?!~t!1ynRXpQ%KA@_$^}8Z3G*yq~g$RZin>r ztGrcsT5OS4XV~40R5xTyP|}31$Ok0Z#g*Fpw^OShYocE-=cMFTj(WriRU1z?s=Pj;BjhgagT&{ zU?oGc>~m$6t#)J}B!t*vdI;^#UTCgNon}N)UrwR}M%Qm0?jG!Z*YAvFzpG_4(h+j8 zBZ8wWLLz_2BsLM+4lzq^xRe`Z7B?`jHYp?gTI{c}uo3%0oPd!*sBiP;R?zg^$b9N~ zjAAz-%wRic?ofVH1bzTqj*;JxMt-r_$P)gVF#BL+7Q5AyA{{Y^_-TMFl literal 0 HcmV?d00001 diff --git a/product/models/__pycache__/product.cpython-312.pyc b/product/models/__pycache__/product.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ff117a003a9e86365be50117470929255335b9e8 GIT binary patch literal 967 zcmZuvJ!soN6uz@8|3#{cG4#*S5J-a{c*xj>4o&JdEeWBx9fUxfb(dJlNpeqeh_@6n zxKq1j&FGR09XodKQiH)pYsrwM6p}8PdZ&w>Ky$;p@4frp&%O74=z0P0b2$H-bRhu0 zgfc$rB{-{bZ~!pCkOB{y5DJ{4DNivK2vXn$z{)o`|F08Enq$s2_@yUqgKcA`_v z&AbZ*5AE8N_?uDFJ?9^(8wwN6jMWB3{&t-9+msrRiE(jy7LyIsrV+Q~xn<2L#yQ*e zkwtr{QmMKg^hq?vNFqkBE$&TFiAwtUU_?N{}!8GRP6cxVVb^PCXDZd0=UgGUr^*_zO7WI=FbX z^w@eE5*At>ikie)4xF|}{3x_Y138xc2KhMfY^xCj+hG(iVzp$yEV(yhwc6^i3=fzH z0m23s`(UJ1y0xKJ>1&mqGSKGto{vg1pC1iNGyT#`&-qsVzC0+c?7bdobAmV5*XDZl zfwsVT`gHf*P@nGW)4lRQukO`G#o6x8usGW<&K@?u;z9ArhnMXBIO&>^iSu|1`I|u% zH)MzJTozlE#a73^m(5UD#p=tl?};!;tOp!jM{{Yv|@CE Date: Sun, 10 Mar 2024 21:12:31 -0300 Subject: [PATCH 02/42] Condigurando serializers --- order/serializers/__init__.py | 1 + ...{order-serializer.py => order_serializer.py} | 0 product/serializers/__init__.py | 2 ++ product/serializers/category-serializer.py | 0 product/serializers/category_serializer.py | 13 +++++++++++++ product/serializers/product-serializer.py | 0 product/serializers/product_serializer.py | 17 +++++++++++++++++ 7 files changed, 33 insertions(+) rename order/serializers/{order-serializer.py => order_serializer.py} (100%) delete mode 100644 product/serializers/category-serializer.py create mode 100644 product/serializers/category_serializer.py delete mode 100644 product/serializers/product-serializer.py create mode 100644 product/serializers/product_serializer.py diff --git a/order/serializers/__init__.py b/order/serializers/__init__.py index e69de29..522d7a7 100644 --- a/order/serializers/__init__.py +++ b/order/serializers/__init__.py @@ -0,0 +1 @@ +from .order_serializer import OrderSerializer \ No newline at end of file diff --git a/order/serializers/order-serializer.py b/order/serializers/order_serializer.py similarity index 100% rename from order/serializers/order-serializer.py rename to order/serializers/order_serializer.py diff --git a/product/serializers/__init__.py b/product/serializers/__init__.py index e69de29..1236164 100644 --- a/product/serializers/__init__.py +++ b/product/serializers/__init__.py @@ -0,0 +1,2 @@ +from .product_serializer import ProductSerializer +from .category_serializer import CategorySerializer \ No newline at end of file diff --git a/product/serializers/category-serializer.py b/product/serializers/category-serializer.py deleted file mode 100644 index e69de29..0000000 diff --git a/product/serializers/category_serializer.py b/product/serializers/category_serializer.py new file mode 100644 index 0000000..de2dc99 --- /dev/null +++ b/product/serializers/category_serializer.py @@ -0,0 +1,13 @@ +from rest_framework import serializers + +from product.models.category import Category + +class CategorySerializer(serializers.ModelSerializer): + class Meta: + model = Category + fields = [ + 'title', + 'slug', + 'description', + 'active', + ] \ No newline at end of file diff --git a/product/serializers/product-serializer.py b/product/serializers/product-serializer.py deleted file mode 100644 index e69de29..0000000 diff --git a/product/serializers/product_serializer.py b/product/serializers/product_serializer.py new file mode 100644 index 0000000..f29ab4b --- /dev/null +++ b/product/serializers/product_serializer.py @@ -0,0 +1,17 @@ +from rest_framework import serializers + +from product.models.product import Product +from product.serializers.category_serializer import CategorySerializer + +class ProductSerializer(serializers.ModelSerializer): + category = CategorySerializer(required=True, many=True) + + class Meta: + model = Product + fields = [ + 'title', + 'description', + 'price', + 'active', + 'category', + ] \ No newline at end of file From 3c47e1f48dfd3e9f1447439b3a8d4f8f80c4cc1f Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Mon, 11 Mar 2024 19:38:06 -0300 Subject: [PATCH 03/42] Construindo factory.py em Order e Product --- order/factories.py | 28 ++++++++++++++++++++++++++++ product/factories.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 order/factories.py create mode 100644 product/factories.py diff --git a/order/factories.py b/order/factories.py new file mode 100644 index 0000000..cc751c6 --- /dev/null +++ b/order/factories.py @@ -0,0 +1,28 @@ +import factory + +from django.contrib.auth.models import User +from product.factories import ProductFactory + +from order.models import Order + +class UserFactory(factory.django.DjangoModelFactory): + email = factory.Faker('pystr') + username = factory.Faker('pystr') + + class Meta: + model = User + +class OrderFactory(factory.django.DjangoModelFactory): + user = factory.SubFactory(UserFactory) + + @factory.post_generation + def product(self, create, extracted, **kwargs): + if not create: + return + if extracted: + for product in extracted: + self.product.add(product) + + class Meta: + model = Order + \ No newline at end of file diff --git a/product/factories.py b/product/factories.py new file mode 100644 index 0000000..cda2d69 --- /dev/null +++ b/product/factories.py @@ -0,0 +1,29 @@ +import factory + +from product.models import Product +from product.models import Category + +class CategoryFactory(factory.django.DjangoModelFactory): + title = factory.Faker('pystr') + slug = factory.Faker('pystr') + description = factory.Faker('pystr') + active = factory.Iterator([True, False]) + + class Meta: + model = Category + +class ProductFactory(factory.django.DjangoModelFactory): + price = factory.Faker('pyint') + category = factory.LazyAttribute(CategoryFactory) + title = factory.Faker('pystr') + + @factory.post_generation + def category(self, create, extracted, **kwargs): + if not create: + return + if extracted: + for category in extracted: + self.category.add(category) + + class Meta: + model = Product \ No newline at end of file From bdb6eef20532a217e16898f66e00acc6eff6dbb2 Mon Sep 17 00:00:00 2001 From: Matheus Oliveira <118443175+matheus-dev-fullstack@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:09:56 +0000 Subject: [PATCH 04/42] =?UTF-8?q?Iniciando=20configura=C3=A7=C3=A3o=20do?= =?UTF-8?q?=20viewset=20de=20order?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bookstore/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 136 bytes bookstore/__pycache__/settings.cpython-310.pyc | Bin 0 -> 2284 bytes order/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 132 bytes order/__pycache__/admin.cpython-310.pyc | Bin 0 -> 214 bytes order/__pycache__/apps.cpython-310.pyc | Bin 0 -> 409 bytes .../models/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 174 bytes order/models/__pycache__/order.cpython-310.pyc | Bin 0 -> 573 bytes order/viewsets/__init__.py | 2 ++ order/viewsets/order_viewset.py | 12 ++++++++++++ product/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 134 bytes product/__pycache__/admin.cpython-310.pyc | Bin 0 -> 237 bytes product/__pycache__/apps.cpython-310.pyc | Bin 0 -> 415 bytes .../models/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 221 bytes .../models/__pycache__/category.cpython-310.pyc | Bin 0 -> 678 bytes .../models/__pycache__/product.cpython-310.pyc | Bin 0 -> 677 bytes 15 files changed, 14 insertions(+) create mode 100644 bookstore/__pycache__/__init__.cpython-310.pyc create mode 100644 bookstore/__pycache__/settings.cpython-310.pyc create mode 100644 order/__pycache__/__init__.cpython-310.pyc create mode 100644 order/__pycache__/admin.cpython-310.pyc create mode 100644 order/__pycache__/apps.cpython-310.pyc create mode 100644 order/models/__pycache__/__init__.cpython-310.pyc create mode 100644 order/models/__pycache__/order.cpython-310.pyc create mode 100644 order/viewsets/__init__.py create mode 100644 order/viewsets/order_viewset.py create mode 100644 product/__pycache__/__init__.cpython-310.pyc create mode 100644 product/__pycache__/admin.cpython-310.pyc create mode 100644 product/__pycache__/apps.cpython-310.pyc create mode 100644 product/models/__pycache__/__init__.cpython-310.pyc create mode 100644 product/models/__pycache__/category.cpython-310.pyc create mode 100644 product/models/__pycache__/product.cpython-310.pyc diff --git a/bookstore/__pycache__/__init__.cpython-310.pyc b/bookstore/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b2109ba39ea8f9469d18aa392d2ab09388917a9b GIT binary patch literal 136 zcmd1j<>g`kf;neCrh@3lAOaaM0yz#qT+9L_QW%06G#UL?G8BP?5yUTT{qp>x?BasN wd}dx|NqoFsLFFwDo80`A(wtN~kRioPK!Sw<0LY{slmGw# literal 0 HcmV?d00001 diff --git a/bookstore/__pycache__/settings.cpython-310.pyc b/bookstore/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..236acfbf8589911876f5afe34ce6a8d669952699 GIT binary patch literal 2284 zcmb7FOLN>r5SC=^BO9;d*m;o@RjNutSO;qZP9UKmMBbI1CHpE%8-ot0w3@LzwjLYJ zD2{dIZ{z?uP{m*1H}DJQ%84Tv4irUbY1j7FI#n3$YBZYe{<`Oz?p9Q-Rs^_S|N001 zWnK_|%U-6hBD_3-oBjj?5-b6UNbk7JV2(=rIDhfiSx#xslq)^Nl z2|cRpM6oiAqJ7Gu7%QVV+QTkWE0s+g;@DvrDZ@kM4$7@o9TbpIq0EWdMDvc4P{2_p zun*LG>Ka&Y0BVo{k`NpO4kJ;hz@P0Ba7ldp5k!D1yNr$K=k+>@T&j+J97W(pK^=#6 z0IaiUL|j@w3b{UpXS-P0Nqk@N31v#ObFw8TMBoUMSb6FA38w$YSB!V29Q_W*E7U|T z_Z_yIu1{DXA;oSIS3bV?!QsK$%Iz<2(NEI!2_2=6?(eVMUU~TN zRs7%{y@fn4x{1wNIlVN7QQatHF&U~ksp<0UY62c_%q(UmIArW_glT$pMo2NGK=Wxq z00PGYi|ex%3=YQ4j)U?-6eAq-67Y`_m(@z?>O?yr2>JNHiLsjRo3KOG$OwQ*=UA5B zp9PuA;^v7t zWjMQuBkHD&J7YShtUi6mCVb-V?>X*16o>lFM(hN*H_EDjPT4IS7oM8LK27Tr9EO9D z54EQb0RV^Ss5aDQUWVpGO!-ot5U-dGr{+RfQA}%c`r$0hX)P7uVdAALXV8rC3#cKM z-ksHUf*o>x<-2a zgt7zb5!D%ufa&}gc?sbiC-K>Fo}=LjgY<<@7+y;&usE65Bwp0Jo2{KsO0+Ox)851stv>l+O*!Mp}Zt4<%Di-=Dw&lR<>APt|qe zK}kg$1pBC4yUI(p4K3Zap`AeE^vN)mfLdO*?X1~k>oKO0{}S`!2>MFMtn#{M=-FBG zilH~QbklyOf6EI^eSNUWt6IC=+t!=*)1F}(e4*7fOjv>iNDzZpI<022t#4~vI-lR_ z^-O!P)o%2<8~mK9clvG3)D6D4ZEUtO{dTLNWx2%9H8oSq+#39vHZY&sea$eods|KW zxz=uhum>qvZEM}lfwrmJjb2j+z*a}MtsbOIc>n>oK7QEc#cXC;5V;A+jm$e=YU&%> zpl#ZK+_N`Ydb|0v5Z?qA^5L($bx5auI&z?F>&H1gH9Pv+siQ+){sMSTeEb+b-~#;` z23eS&U!0Rm@|-M{3+3~2MUo{^63deGR{mRlD=$hVNi2%;KQOPtnml#?DKE>Q4!>f# F@GqaK6j}fP literal 0 HcmV?d00001 diff --git a/order/__pycache__/__init__.cpython-310.pyc b/order/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cee84fd33405916d710a7896e71f2223018b7097 GIT binary patch literal 132 zcmd1j<>g`kf;neCrh@3lAOaaM0yz#qT+9L_QW%06G#UL?G8BP?5yUTb{qp>x?BasN z#-l++^q`1s7c%#!$cy@JYH95%W6DWy57b|3?anScZf0{}V= B9Mk{+ literal 0 HcmV?d00001 diff --git a/order/__pycache__/admin.cpython-310.pyc b/order/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e69e6cd9dbfbdbc47ecb53d25ecba52458a2fcc5 GIT binary patch literal 214 zcmd1j<>g`kf;neCrbYni#~=5FarQKu`)gY literal 0 HcmV?d00001 diff --git a/order/__pycache__/apps.cpython-310.pyc b/order/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9ece4fa639ff9bd5e2c7a2574ef61f642dba1dbf GIT binary patch literal 409 zcmYjNy-ve05I)BV3jJA7S0p5+EXfNX)Pe+C8M}mo z@I1h90ZH^tEJ&C;p4IiW-mQzx%2y7JQ8FdB69NS}L!jR*=NRN6a#9K1@Xnwzy})NLEli@`7=dniwF@!8; kU2UFlH{9>+xhC+sp8Y?ekA_rp@kPJtr9X`If+LvlKLaLW(f|Me literal 0 HcmV?d00001 diff --git a/order/models/__pycache__/__init__.cpython-310.pyc b/order/models/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..92afda2ae07c7c23a3edab78bb1b189f6266d5f1 GIT binary patch literal 174 zcmd1j<>g`kf;neCrb+&ryk0@&Ee;!?U};XO9ms}akZ}SG0In@4-T(jq literal 0 HcmV?d00001 diff --git a/order/models/__pycache__/order.cpython-310.pyc b/order/models/__pycache__/order.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9d8303d2cac1281fc7aed1f352324f7921bd7e14 GIT binary patch literal 573 zcmYjPyH3L}6t$B$NlST2r~`ixkkTC?1S*sPwIBgY7Ax(wpluQtClTrlD}TTb@GpFU zS0+YQCa&WOxRQ^~xw(%MCvttgO)y^HzeGR@`7q*tcqoqXlm`evfMz7838jWRnUlMT z+i*AYa+WYk&Ix$Ho(V8PXa19$1mItjDEP#F5>f5v5=2%a3$B!edQu_vZcCvirs9A6 z?%u;G%AWhr5_&mkNX$;AA$=(qfLJB@2#=MI}bj znhrTH(p+$^+nl4LIy1b(`9qy%_K9+EtKJ-@#qvfP985(9$~DCV)tEuZ z^bta`L3e1A8%3dR!7MHAWDMiRW71u@iS3YhC9T!nRq;d?m70#@w65+~h1M|}nh(+p c|1)dZHtyEpp}n6Y{5?n+B6LWHc4*i60djkf8UO$Q literal 0 HcmV?d00001 diff --git a/order/viewsets/__init__.py b/order/viewsets/__init__.py new file mode 100644 index 0000000..9a8e2a2 --- /dev/null +++ b/order/viewsets/__init__.py @@ -0,0 +1,2 @@ +from .order_viewset import OrderViewSet + diff --git a/order/viewsets/order_viewset.py b/order/viewsets/order_viewset.py new file mode 100644 index 0000000..077bbd1 --- /dev/null +++ b/order/viewsets/order_viewset.py @@ -0,0 +1,12 @@ +from rest_framework import status +from rest_framework.mixins import CreateModelMixin +from rest_framework.response import response +from rest_framework.viewsets import ModelViewSet + +from order.models import Order +from order.serializers import OrderSerializer + +class OrderViewSet(ModelViewSet): + + serializer_class = OrderSerializer + queryset = Order.objects.add() \ No newline at end of file diff --git a/product/__pycache__/__init__.cpython-310.pyc b/product/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..87be3e2881b0aa1cda9d52c313af2fd8e538511b GIT binary patch literal 134 zcmd1j<>g`kf;neCrh@3lAOaaM0yz#qT+9L_QW%06G#UL?G8BP?5yUS|{qp>x?BasN z-X%U@wyJ$yXwg zHq1d+%~Lw^Y_ubUzUXYc$vagdUA9S>P2iX}B`ykVI;sxjqU=B;sM=7#Kq1RbP~>(e r?|FJgI+->vlt~YWC(|LRwEfwq-_S*SvGI~^`dY2r1IBrc#MJ))Whyy} literal 0 HcmV?d00001 diff --git a/product/__pycache__/apps.cpython-310.pyc b/product/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..474891a3567813f28762f170e74b446f2ea0e584 GIT binary patch literal 415 zcmYjNy-ve05I)B#g#Ik3D-sJsmgEHxYC(dnLSoBexj8oqO=}Y;La@RUF!KVu3s2yc ziIJ6wb5e<(bf53%yYH;ilgSXs-amiT8@*pX*|(6A8M!?rKtNW(hGmSw4Pb!$6_6|T z!m|LwJBSD0#DbW)qq#9xdb=u%+*kIEQ8FX9QvwAUL!fDvaSXB$IjMwha$9R`^QM=0 zKEZprEp&p*WTR14Hn}W|dE4mgQdQ^w({{g`kf;neCrdk8(#~=G?&KKsI|oQGQBka*3ZN%Po#%sCW^`&|B;U5UC<&Aa5l@ z5gU*K6Tb}f%kzt}iwhEyQ;YSJ^7FHcOY)0S^`YwZbMsSDbBguj<1_OzOXB183My}L V*Z>7fb5iXtFY%fZ^3#*4MM%!k%`*%@fJ$P0;7eGC5M7c*e8M`ipe{Km5YjZBPAx`qj&9yz5TvF+>Oh3M2q**(w2l!c zfXxukhVvL%2+2cOr^qwJGtA|XLUvE;0&*N%xOBy>*eZQ{0&I)|@&o_Gr0BNx`n}iF zckN9tPTzet)Lw>*Hh7Eh^ammg-5zbLI#<3@N($bM1qp9#`$6b4yg0mU5+3=p5QBG9Vn|6zOZphS42H~l5xER@ lyxXcJY(_cph5r>pdeY2qP5X{6eK9`frC+)6pRXiOgFpDyq@e%+ literal 0 HcmV?d00001 diff --git a/product/models/__pycache__/product.cpython-310.pyc b/product/models/__pycache__/product.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..09e6119177a555a086189731180ab651e921b70e GIT binary patch literal 677 zcmYjP&2H2%5VrH5G)oae?K9+(yZ}NKl|UT2s>GgriM+AdX4i>>?S<~87r5>l@B+LG zPv9%39+5b4VjQ=kV|nz=jOX8Su_zGG_n*J{9Y*Mv6P{88!UbGi17nC`fd))4b~q5h z5Rwq1cZh{7`i5A<@izJzl9Fy$Xeoq=Lzf1Bou zR69M Date: Thu, 14 Mar 2024 16:43:59 +0000 Subject: [PATCH 05/42] /home/codespace --- order/viewsets/order_viewset.py | 5 +---- product/viewsets/__init__.py | 2 ++ product/viewsets/product_viewset.py | 0 3 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 product/viewsets/__init__.py create mode 100644 product/viewsets/product_viewset.py diff --git a/order/viewsets/order_viewset.py b/order/viewsets/order_viewset.py index 077bbd1..4a00acc 100644 --- a/order/viewsets/order_viewset.py +++ b/order/viewsets/order_viewset.py @@ -1,12 +1,9 @@ -from rest_framework import status -from rest_framework.mixins import CreateModelMixin -from rest_framework.response import response from rest_framework.viewsets import ModelViewSet from order.models import Order from order.serializers import OrderSerializer class OrderViewSet(ModelViewSet): - + serializer_class = OrderSerializer queryset = Order.objects.add() \ No newline at end of file diff --git a/product/viewsets/__init__.py b/product/viewsets/__init__.py new file mode 100644 index 0000000..d292b0e --- /dev/null +++ b/product/viewsets/__init__.py @@ -0,0 +1,2 @@ + +from .product_viewset import ProductViewSet \ No newline at end of file diff --git a/product/viewsets/product_viewset.py b/product/viewsets/product_viewset.py new file mode 100644 index 0000000..e69de29 From 9f7c44fd85b9d2964b6bc9de96b22c4608076a65 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sat, 16 Mar 2024 21:06:04 -0300 Subject: [PATCH 06/42] Ajustando serialyzers --- .../__pycache__/settings.cpython-312.pyc | Bin 2566 -> 2585 bytes bookstore/__pycache__/urls.cpython-312.pyc | Bin 1036 -> 1222 bytes bookstore/settings.py | 1 + bookstore/urls.py | 4 +++- order/__pycache__/urls.cpython-312.pyc | Bin 0 -> 604 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 234 bytes .../order_serializer.cpython-312.pyc | Bin 0 -> 1311 bytes order/serializers/order_serializer.py | 18 +++++++++++++++--- order/urls.py | 12 ++++++++++++ .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 225 bytes .../__pycache__/order_viewset.cpython-312.pyc | Bin 0 -> 651 bytes order/viewsets/order_viewset.py | 2 +- poetry.lock | 16 +++++++++++++++- product/__pycache__/urls.cpython-312.pyc | Bin 0 -> 610 bytes product/factories.py | 1 + .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 303 bytes .../category_serializer.cpython-312.pyc | Bin 0 -> 770 bytes .../product_serializer.cpython-312.pyc | Bin 0 -> 920 bytes product/serializers/product_serializer.py | 16 ++++++++++++++-- product/urls.py | 12 ++++++++++++ .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 231 bytes .../product_viewset.cpython-312.pyc | Bin 0 -> 810 bytes product/viewsets/product_viewset.py | 9 +++++++++ pyproject.toml | 1 + 24 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 order/__pycache__/urls.cpython-312.pyc create mode 100644 order/serializers/__pycache__/__init__.cpython-312.pyc create mode 100644 order/serializers/__pycache__/order_serializer.cpython-312.pyc create mode 100644 order/urls.py create mode 100644 order/viewsets/__pycache__/__init__.cpython-312.pyc create mode 100644 order/viewsets/__pycache__/order_viewset.cpython-312.pyc create mode 100644 product/__pycache__/urls.cpython-312.pyc create mode 100644 product/serializers/__pycache__/__init__.cpython-312.pyc create mode 100644 product/serializers/__pycache__/category_serializer.cpython-312.pyc create mode 100644 product/serializers/__pycache__/product_serializer.cpython-312.pyc create mode 100644 product/urls.py create mode 100644 product/viewsets/__pycache__/__init__.cpython-312.pyc create mode 100644 product/viewsets/__pycache__/product_viewset.cpython-312.pyc diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index a0cbb0fdae0a465d3f4118ed5bd86e1350789fc9..f2931e46432d91b24d5cfe09297db9d625c7bece 100644 GIT binary patch delta 81 zcmZn@nJL11nwOW00SM+D|C$=Ok#`~!Bj@D#Ow$DgQ?e5C((~g}D@s!HiZk=`Hk&ZB kF*EXQwr1PT#Hcy>Ge;mhmk?6}-zSO5-kjT6)PZII0QO23i2wiq delta 63 zcmbO!(k8-tnwOW00SK;Yze_dW$UBjVkz?|FrsJGb6KNUbJ?QU7#WxtQdv@1 zQkk;&U@8%GmH>hcW36U_uz>nlQ&@o{TMFB1Mu->|Id*ipbml0|N@fmC&W#;YnBtjl zu@oehWZYseN{xpwGV_viN>fs+*b-B6GxPMT;r7dQj3Z+^YiR9 z$_#7Dj5Ia%tGM!uQc{cbN{e!et9S~E@>5EaOTauoO|Hp$%m(a5tU%Wlu}zLNR{iz}R8cUj-2Mb{2l7M(!d|5CQ;=lk4l<_%cqPn~SBLfpdDoYAWDpM9%3rrP+ z&f=MvC&iJ@7{y-6s>!zT#1tkW##<}}i6t3TY>6qknR)ttnjDjNGaF3)%A9Y{2h_v} z#KpQm;sY}yBjZOVenytBN(_vOcNt_pvN5o7c1TPxoo+SJYP$VI`^zlKADEf=nHsr^ Hcz`+pYd(v1|v2))/', include('order.urls')), + re_path('bookstore/(?P(v1|v2))/', include('product.urls')) ] diff --git a/order/__pycache__/urls.cpython-312.pyc b/order/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..03a301eecce7fdc659e270f6128ca3f7ca81f59e GIT binary patch literal 604 zcmYLG&ubGw6rP!#o$Q*V0e?auhy~GH+Pg>(*0Vy26}AgulX=FZJ3C=!*V0>iYQ5D{ z{SQRqAK=M%#F+#r_DT7^s z*%u2=5l0-SNZ<$y5)te;Nj*U$I>%n>3l=eq2m(4l8LUUrpeVz+QHA&WY|QEk7{4*ojYCWela{I#hJvwm7|Xk$}R zvdBSc3xhX9*wc_}<4eUsxuag9Axi`p^sHSsRX$3xfm|z8s+F5bQJc()0-bkXDciRv z)vog0O~obmhNiYP6yp>+b0fnRh9*!j7;0;6YR{e9wl&{^+)yWOsy5qE?RBOnvMooW5vl&)TQq(Kg=%6;#DCZv{e literal 0 HcmV?d00001 diff --git a/order/serializers/__pycache__/__init__.cpython-312.pyc b/order/serializers/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..099c8fecfe6bddeebd4ebc156bc8f36dc371a031 GIT binary patch literal 234 zcmX@j%ge<81RK5IrRoCd#~=<2FhLog1%Qm{3@HpLj5!Rsj8Tk?43$ip%r6;%!kUb? z`2CAgQj3C9i!u{)GOJRH{4|+v3FL#s;)~&eMa)3OD;Yk6jQr*2Y!wpFG`I88yABxt~e$>J~J<~BtBlR lpz;@oO>TZlX-=wL5eLwCkh6+Gj1SC=jEwgfbc@)4902L~LZkoy literal 0 HcmV?d00001 diff --git a/order/serializers/__pycache__/order_serializer.cpython-312.pyc b/order/serializers/__pycache__/order_serializer.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cdfa2a8e4c1c48d127db2b531295950cf7a7179b GIT binary patch literal 1311 zcmZuw&rjS&6n-K>rVNYM9`b+mQbJVdD4ePudaKw*RXO#I?ZpIj4sYLk^ZdGgeaf-G|)^f_BCG*4AUS$VH`Yt9Xx}P zda(_Z{cdZCZ|0YCmHeM7s1SKpFkW-~+C#<#hWW2~=r!F4-R{(#J}z)GFaSLbS{6E6 zz`!IPn3Mw3JmQg`=r+!zj;UkL_}`9_0xPXN`PQp|Zf) zgJz90PwIiwSa#FbV#pj?HErt=nk|S(oJF%j>L=^cbiK`Xy9|G~Q-2hmQkTwyOJ_>} zt8|6d75b_3J$=%pW6dhvPTyM9RwDF)o$AemPmm$%1V+oPgQ3?6BS7W{>UP23#zeybi`xdFpx0r)>pYIqGx&Vwm+ns< z=lBK8@{4FDD;>OF1?QDf6L2M^q%9>t*_VkHk?)7zn0hmAnfIzv1;YoGiBVM(Jl{4- zX<``7I{a4p@W=A2(Kn?lYvcRH;f=5Mio-j_;oahAYc~&dYV`e6pvKT4ph=Jv$YiA; zOPqqCo^e?ku-NgF7b%6b3$>LO_wzN{vbz%tH~O! s@sF_^_0JHO(EOzlLJnZ)5BTT+M*r43$k67(UjOBt{>$$GgLr`d0LpDT5C8xG literal 0 HcmV?d00001 diff --git a/order/serializers/order_serializer.py b/order/serializers/order_serializer.py index a514f29..4b7c5d5 100644 --- a/order/serializers/order_serializer.py +++ b/order/serializers/order_serializer.py @@ -1,10 +1,11 @@ from rest_framework import serializers -from product.models import Product +from product.models import Order from product.serializers.product_serializer import ProductSerializer class OrderSerializer(serializers.ModelSerializer): product = ProductSerializer(required=True, many=True) + products_id = serializers.PrimaryKeyRelatedField(queryset=Product.objects.all(), write_only=True, many=True) total = serializers.SerializerMethodField() def get_total(self, instance): @@ -12,5 +13,16 @@ def get_total(self, instance): return total class Meta: - model = Product - fields = ['product', 'total'] \ No newline at end of file + model = Order + fields = ['product', 'total', 'user', 'products_id'] + extra_kwargs = {'product': {'required': False}} + + def create(self, validated_data): + product_data = validated_data.pop('products_id') + user_data = validated_data.pop('user') + + order = Order.objects.create(validated_data) + for product in product_data: + order.product.add(product) + + return order \ No newline at end of file diff --git a/order/urls.py b/order/urls.py new file mode 100644 index 0000000..044db6d --- /dev/null +++ b/order/urls.py @@ -0,0 +1,12 @@ + +from django.urls import path, include +from rest_framework import routers + +from order import viewsets + +router = routers.SimpleRouter() +router.register(r'order', viewsets.OrderViewSet, basename='order') + +urlpatterns = [ + path('', include(router.urls)), +] \ No newline at end of file diff --git a/order/viewsets/__pycache__/__init__.cpython-312.pyc b/order/viewsets/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0f0ec18f01113828b4cd4ea73a02fc10a8982433 GIT binary patch literal 225 zcmX@j%ge<81cx#{r)mS~#~=<2FhLog1%Qm{3@HpLj5!Rsj8Tk?43$ip%r6;%!kUb? zc>Ie}Qj5YeQ_F)>OZ+sMZt>=W1meqpBE_jCMa)2DD;Yk64EyEnY!wq)oLW>IlbcwQ zks9NYpIn-onpaXBlbV#691|aun3s~D8y}ODpPyY^l3$b>12!uLYF2Sfe0*kJW=VX! mUP0wA4x8Nkl+v73yCM#t*&x>xgBTx}85tSxF{l@@0XYC-n?DTz literal 0 HcmV?d00001 diff --git a/order/viewsets/__pycache__/order_viewset.cpython-312.pyc b/order/viewsets/__pycache__/order_viewset.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9a6ec807a28a25923f97fccaa0f571b650927e6b GIT binary patch literal 651 zcmZWm&ubJh6i(*H?pmfy3zb3-QWS(axOkS*OAGeWS}ckT17UXZ#NB2#Hkq|-p@%{* zp4wag2I)Ui@KW)h1PX$9@Fr|~>B*PLtO^G5@_jFPzrK8&ot+`LUR~V4HJ;xsnXa$_ zlT`#~gcD8$DQQZn#h&m=KlN+ui=YhCkP?qPB|JDLJOp~~yZE#5>&9*IEVE-Il!p z6qPo9E`;gqjX;exR3FI17QWqHdy>7tNS&2=^#-zaS&T{;Ryu=TUS#ZfKIF1wSx?Gc zT}cI*w9;hnP%BKM9c2yez8$MJrmam2fnGv$Ouj8XybKn;#tSEh?+?Gk%b()q&++}E z4K+7?yp^=gq5@s9*9ynomuj~=t)c9nnW!$@MF~JOv&}o#-@$b)g=@iT?efnfy6vnu k@mAGcq!f4E+b^F|dPN@pAos4wqwBz@4^CHZ2p)CpZz#{GhyVZp literal 0 HcmV?d00001 diff --git a/order/viewsets/order_viewset.py b/order/viewsets/order_viewset.py index 4a00acc..de8771c 100644 --- a/order/viewsets/order_viewset.py +++ b/order/viewsets/order_viewset.py @@ -6,4 +6,4 @@ class OrderViewSet(ModelViewSet): serializer_class = OrderSerializer - queryset = Order.objects.add() \ No newline at end of file + queryset = Order.objects.all() \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 4c5cc68..2829174 100644 --- a/poetry.lock +++ b/poetry.lock @@ -45,6 +45,20 @@ tzdata = {version = "*", markers = "sys_platform == \"win32\""} argon2 = ["argon2-cffi (>=19.1.0)"] bcrypt = ["bcrypt"] +[[package]] +name = "django-extensions" +version = "3.2.3" +description = "Extensions for Django" +optional = false +python-versions = ">=3.6" +files = [ + {file = "django-extensions-3.2.3.tar.gz", hash = "sha256:44d27919d04e23b3f40231c4ab7af4e61ce832ef46d610cc650d53e68328410a"}, + {file = "django_extensions-3.2.3-py3-none-any.whl", hash = "sha256:9600b7562f79a92cbf1fde6403c04fee314608fefbb595502e34383ae8203401"}, +] + +[package.dependencies] +Django = ">=3.2" + [[package]] name = "django-rest-framework" version = "0.1.0" @@ -228,4 +242,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "5c25d985b0dd31a20b78db779261d77bd22c90b449a19a5a57659f8b419c82cd" +content-hash = "666f30d1d7a5685d05ac3522b273bef1005787ee9f01023cdcf3c4863ac7d9db" diff --git a/product/__pycache__/urls.cpython-312.pyc b/product/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8e79d6a7943c79f8b68bd7854e493458bc63b1e8 GIT binary patch literal 610 zcmYLG&ubGw6rS1L%nKI5i4J7H$m(p!77 z-s-9T0bV5j0iOH^Je3HQ0YMNEZ zF|?_6r6_Wc3ZeHpfg=UE((Xu#xajBRuoo%FA`Y57ZP#=)9!A+fY!)(A(o7{COu8;X z<=vMO`;LS>lofO1nq*#4ukIy$ltO1_rP<5mtC&!ruHu;7#FC8E7?=Fy(%jU%lH!=uq{QTy z_@KnRl>FTIn56vt?BbIAqSP3uRWS&wieuvAGxIV_;^XxSDt~d<elgQcGm7*WsNt` zUvS1|azDk$NNF$<0~3*3McByddAKe%OwCu_)n8S8UGKZy4$yjd?>p`?fG@^rm)n5( z9ReqiLdtR|Sjd>cR&Et`Xfv?jE~NGhQU}>nzrDQtpV~DJ-KiUR-;5J5y(Up)ah| zhj!=;sk^s~YP14-vGqUCU>{XXDO{DQ9JM3!$xyGQC=-#5RaTC)7bhxvjt7CKea=U5 zft>3O=S7)La)Z}7e>REp`b3!Cv`dGWYwsw-JeBWYZrWKq-n$V!B7J03#Oet~x65Qw z;7G{`591`__v2Ao7CbsE%VViZfzen{l0-%Sh#Do0qI|hI7*Dlh8WHB5Jo@AYnHhXK zzx~QRv)o?iwI?pnmbgUbAaF$2I3`GJw%ej-P!)C2Aj4A`Gcac8TdiT?->hZ6CHlljlMM0- gnIAS|>@!^Z3fF%+KI^=>{IS3Dp}+GB$f+v(10P|(kN^Mx literal 0 HcmV?d00001 diff --git a/product/serializers/__pycache__/product_serializer.cpython-312.pyc b/product/serializers/__pycache__/product_serializer.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3d3972686fa7ff2136b709a0ce236fdf097aab1f GIT binary patch literal 920 zcmZWozi-n(6n9Fw$78>BQW2o{hTva}N*mLfnxt)PX)vShiwYjJDG>74^I6GI00 z3(Cv{Dg*xq6A}{iq)v!|1)&Cnl!-h4NE&gHKY#Dt^S$@Jcm6m(UkAA!-v3FD5x_TP zR1246v?<9U5FjXm7&!j`J9^Ib$cV9n5omB1h%p3$DcYN>4w}A?^nyFJ%(QDi zlwl*$;FN`a6h5bnOSATXC1en!lD5|Tll?C0%kz4E zOg&H3JujB(M2gRO-oe0+iXEo35Lj-~NSHezjR=1SBh~)cS-b8&mLhXE_R}ZSy`2Pu znD$cc(rrI*y-mMIlGt;%lVqQ#38QYm7=e3cGL_Gp`nvs07^)@KkZI1zhc8GN!q>&+ zm-tjOTlH5aTb3?%L4xdrEh(d=;JgBL$Jn9*6~NjG@^~dJt5sl1!j)?X$IZ)cS3i)? z%^NT7{WUCHKLrWJM=E~9w!{LXJoR>%l&BPP N%BRlCACN}g$v>Bo@TLF& literal 0 HcmV?d00001 diff --git a/product/serializers/product_serializer.py b/product/serializers/product_serializer.py index f29ab4b..48e9b80 100644 --- a/product/serializers/product_serializer.py +++ b/product/serializers/product_serializer.py @@ -1,17 +1,29 @@ from rest_framework import serializers -from product.models.product import Product +from product.models.product import Product, Category from product.serializers.category_serializer import CategorySerializer class ProductSerializer(serializers.ModelSerializer): category = CategorySerializer(required=True, many=True) + category_id = serializers.PrimaryKeyRelatedField(queryset=Category.objects.all(), write_only=True, many=True) class Meta: model = Product fields = [ + 'id', 'title', 'description', 'price', 'active', 'category', - ] \ No newline at end of file + 'categories_id', + ] + + def create(self, validated_data): + category_data = validated_data.pop('categories_id') + + product = Product.objects.create(**validated_data) + for category in category_data: + product.category.add(category) + + return product \ No newline at end of file diff --git a/product/urls.py b/product/urls.py new file mode 100644 index 0000000..3610b7b --- /dev/null +++ b/product/urls.py @@ -0,0 +1,12 @@ + +from django.urls import path, include +from rest_framework import routers + +from product import viewsets + +router = routers.SimpleRouter() +router.register(r'product', viewsets.ProductViewSet, basename='product') + +urlpatterns = [ + path('', include(router.urls)), +] \ No newline at end of file diff --git a/product/viewsets/__pycache__/__init__.cpython-312.pyc b/product/viewsets/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..152cffd3add519da839ae0ef78f490110e91b788 GIT binary patch literal 231 zcmX@j%ge<81cx#{r|JUf#~=<2FhLog1%Qm{3@HpLj5!Rsj8Tk?43$ip%r6;%!kUb? z_yUUZQ%aLd!ZK6KgHucVG?{Mk7eIvK%Yb6VsU=0sK&2}gK7$PWVgqsjLUTdT literal 0 HcmV?d00001 diff --git a/product/viewsets/__pycache__/product_viewset.cpython-312.pyc b/product/viewsets/__pycache__/product_viewset.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e9797dad7f267b0e6d46843a5895d26b0d77f4d5 GIT binary patch literal 810 zcmZ8eJ8u&~5T3n<&x-s20kH%PvJ%8KRthSF(h!LX3t^x*owPdNO~B5cFYKO)oF)`* zsG!SlK=~;&K@^}9sSpKSq=P0Ev-gk#Bkk<$Ja)cs=2N@91|;W`9PcrJANo;?T^ac{ z8OIPo#0135V@%tIFk;g)3)>V{Yu&p*7Ps=PbzyvOopy0EqZ58GM-|Xs>}?8AR3lJv8#07 z+ZWFs-uIs?l**5T^cDI$NjQ&jmMR~|LFn_R!7NH*?vImXPo;@Of4>}u|Ar={kP<5g zuN;H@Mb>(WDStgjxuA^0TmLd1Tn;t~g}OoNEqw2;zdw3+^tIdn-0gqqZk#qZatgrE zZDdW(XF-gdXKS3tv=5=}7N;hGC?isjBfCOes@?EV1WL&^xj%yJ&?Q@1IknOSN{5&5 zt#|j-x}ICi-Yhe9($ICXo Date: Sun, 31 Mar 2024 17:54:52 -0300 Subject: [PATCH 07/42] Criando Products pelo ProductFactory --- bookstore/__pycache__/urls.cpython-312.pyc | Bin 1222 -> 1222 bytes db.sqlite3 | Bin 188416 -> 192512 bytes order/__pycache__/factories.cpython-312.pyc | Bin 0 -> 1747 bytes order/__pycache__/tests.cpython-312.pyc | Bin 0 -> 207 bytes order/factories.py | 4 +- order/migrations/0002_alter_order_user.py | 26 +++++++ order/migrations/0003_alter_order_user.py | 23 +++++++ .../0002_alter_order_user.cpython-312.pyc | Bin 0 -> 1134 bytes .../0003_alter_order_user.cpython-312.pyc | Bin 0 -> 1118 bytes .../models/__pycache__/order.cpython-312.pyc | Bin 758 -> 758 bytes .../order_serializer.cpython-312.pyc | Bin 1311 -> 2147 bytes order/serializers/order_serializer.py | 7 +- order/tests.py | 3 - order/tests/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 169 bytes order/tests/test_viewsets/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 183 bytes .../test_order_viewset.cpython-312.pyc | Bin 0 -> 3412 bytes .../tests/test_viewsets/test_order_viewset.py | 65 ++++++++++++++++++ product/__pycache__/factories.cpython-312.pyc | Bin 0 -> 1872 bytes product/factories.py | 9 +-- .../__pycache__/__init__.cpython-312.pyc | Bin 256 -> 256 bytes .../__pycache__/category.cpython-312.pyc | Bin 951 -> 951 bytes .../__pycache__/product.cpython-312.pyc | Bin 967 -> 967 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 303 -> 303 bytes .../category_serializer.cpython-312.pyc | Bin 770 -> 770 bytes .../product_serializer.cpython-312.pyc | Bin 920 -> 1633 bytes product/serializers/product_serializer.py | 10 +-- product/tests.py | 3 - product/tests/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 171 bytes product/tests/tests_viewsets/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 186 bytes .../test_product_viewset.cpython-312.pyc | Bin 0 -> 3252 bytes .../tests_viewsets/test_product_viewset.py | 55 +++++++++++++++ .../__pycache__/__init__.cpython-312.pyc | Bin 231 -> 231 bytes 36 files changed, 183 insertions(+), 22 deletions(-) create mode 100644 order/__pycache__/factories.cpython-312.pyc create mode 100644 order/__pycache__/tests.cpython-312.pyc create mode 100644 order/migrations/0002_alter_order_user.py create mode 100644 order/migrations/0003_alter_order_user.py create mode 100644 order/migrations/__pycache__/0002_alter_order_user.cpython-312.pyc create mode 100644 order/migrations/__pycache__/0003_alter_order_user.cpython-312.pyc delete mode 100644 order/tests.py create mode 100644 order/tests/__init__.py create mode 100644 order/tests/__pycache__/__init__.cpython-312.pyc create mode 100644 order/tests/test_viewsets/__init__.py create mode 100644 order/tests/test_viewsets/__pycache__/__init__.cpython-312.pyc create mode 100644 order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc create mode 100644 order/tests/test_viewsets/test_order_viewset.py create mode 100644 product/__pycache__/factories.cpython-312.pyc delete mode 100644 product/tests.py create mode 100644 product/tests/__init__.py create mode 100644 product/tests/__pycache__/__init__.cpython-312.pyc create mode 100644 product/tests/tests_viewsets/__init__.py create mode 100644 product/tests/tests_viewsets/__pycache__/__init__.cpython-312.pyc create mode 100644 product/tests/tests_viewsets/__pycache__/test_product_viewset.cpython-312.pyc create mode 100644 product/tests/tests_viewsets/test_product_viewset.py diff --git a/bookstore/__pycache__/urls.cpython-312.pyc b/bookstore/__pycache__/urls.cpython-312.pyc index 1715a862d1583cd7a841416a0437db7be2caf5cf..e739d8dc0fdf31ba4b604e18015b9564cdf65068 100644 GIT binary patch delta 19 ZcmX@cd5n|mG%qg~0}!k@y^(7V3jj971%?0s delta 19 ZcmX@cd5n|mG%qg~0}yODxshuR3jj9j1&jay diff --git a/db.sqlite3 b/db.sqlite3 index 5d2a7293c527601bcac32866a762b3e49e5163be..a644e7f52a4252e16a6cb514b1f8bf99aee89eea 100644 GIT binary patch delta 2067 zcmajgTZr7&83*vyUcBD9X*XW)y4jO@FR|-%y}Prs_S)-*QfV$4T}GF=YD8h9(P%U? zl13WM=rU@uU zFMZH=`1tA1ITAwO?O#T3e-?dvZAqG%n%XJ7|tnyQmbCJ&BfW2idE&--I{pgO5!>e^27U?+97zJKG^wZmK2 zZtNc3ym@$ZaCH8^qN)EE-M@7(i5{kI+&oAwPokG5yWao%i;20_$sy08@(lVH^fCHV z)I;Ayzm0w$mG5t?lj!+#@tJMJcC4nW43AIO)Lm~cbs-U(**XhP`n(Q0*6Pg60dn_O zv2%AH?OjDy-bg-3BC}80smSFi^bhDK==acXpk0(fchSYf-x7}#4-(%>go&>tzLeNV z%*6i~|1|!C_?vMv&c*lR=VJee{WkWK*mq*D#g1cGY%6vq`se7cqd$zk6}6+q=(Xrd z(+dqE{}%!baudSk~3O;4eY=$o)0m*Ty9tFcD0bz7%^?sFXP}U zRHKUp4WiLjJfp>kSPBk0k*fQm|FKvJ? zKy9~5e2GsRWj9L~B*L%IBQd6d%cn}^Yqn=I1}V_RaeB}br~w}PI=BSclY5q3*K2Hz z4g5+D8`?E-^T*(2sD#k!4zsOFmTn5PEe}0QF*crnEvS{CS*&^*!Df}7?sB~{M^@&p zuWde4WFc#tS)nB9o^RR8i0F*^HaC{Q2F#j4t3oQ3UcOkC%#2;oiWj6e} zsJW-$rDr;xUI;UER?V^1j-rW8R$^UGslNO!0H=wCz1k`ab*+_&eGPmLs-*HIb=*)WrrGZi zpi8W9{Pa*A|~KvQX~TXnQ2q2}x=<2bnP2QS3c{!t78_%lS5* z)kmGS?stZGIK+^rAOW@D7reSWNb}|>*QAMBRU#^z9*9H5%bX%l9*gZ)tCnHq97(G! zH9%~l?LIy-(n5L`c=BQ|ove+;b{d9-T=*tlhftszC zNre>YjOlQr0LMM19jqOK1*l@TLRWB>pv9n4YqWef^zfHb;4IX#O&7+aMyapiRNz%J z9HEnV;t`mKT+(xnRjXQTsg-AIL%E6vFxO~;bJbUx2U=C^+ zsM(yEHUeDe3WA%>H}C?I1hY_k1-U2|{3bW~sC!t@tLYMxj@$z?kokd;cFl$v8Z1`p zVpy+l7gzrUrlDFL&os4)H_ExR-mP*$y;_M?0RpvHvfHLg1uaM8`9@FYdue&@pYMOh z|LFGY;>qmW(=R0E|8(Y^xhHe^h3)yytTmYe^z8N5tJwVN>%ye$>>zJchH}GDd#ZnY zI$NJltpDw|PlS8Z-+f4ab9!SM!B6y)=>z1-!}m_6-$D@VWcS|mCbIo-a?6KjV)4n) coLYQVrmoyydiAg99e(cpC&@c}6!}m8Zyq5MzxIzOZb^ZxL!?W7tq|SsIZG`^D8NFR#E;H z3~c;m4E!(ouki2YFXQj#pT%FXSui1ie{z|=kp$2TVUEPol8pF*)S}$X;^NGFab{*? z#>oeHgePCt*I^WCGT3Io$ns$`O9Q*YX6^@H^%pfLOq;+Y#>1)2{+vCNZ4&DTR*%h& z0&1+=J*F}#F)>lmq@xgz40PBJ} At^fc4 diff --git a/order/__pycache__/factories.cpython-312.pyc b/order/__pycache__/factories.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5c2bd05bb5e1aac294b9656f8085760f2d8f587f GIT binary patch literal 1747 zcmbVMOK&4Z5bmCt_H$x8&I4Ft2oGsBVPy&Jij@%LvSF7?0^)HQj7Aer=i%6%&@kVr_IoSYk6QTQjEtOz+YLIR;ZaLeMLm2#r0XPh|EA_Q%@x~3mrSAF$$|1dU| zA<(`d$rY&)@;iPE8;hO6_uzDiM?6|5HuhSbHZ)tK=<9X8Vc3T9jXG;2>;xqmc|bh2 zL%akhwcHT!vab~`{h@cHN1mNlyOXdx^*?rJ+SE$_flx~pmByz57trTE6u#H0hWFiS z=!-Utun&aCMRj;O_D1|MSOcd^II*cmY)vCvuchL-kH2SpJKd#X()+AI~I;3SB z0oB;-WSdzDnZ+RE$Ry(pcfBstEf{l}Zi8P5F+PwCkig3jxo#Vfw{~6_fhsTZ&|R{a zOgRe3ab(7E8o)!HgKs*{7cIArM>vi^@+E^wUjL2^Fu3!3_uj4`Tu^Da;To?j_|;Z} zH^ZR9m)&Z``N(a0e#5CO`~F4%tn!MFlvY+0$Ll;OZ?>g@L5M8ineY#iV0Oq!VRDa& zaqz_im?bMEa8`_=LAl6e1k#r5zPrJNK>B40Il*|$>10Vx@GG?&}RT3QgYH~D{atw>p!JA;V$#40o6SMeJcJk!K*P#?+ zbNflqN7pRT{ZLa#|s^1L7`f}NAg==MX`-A8y7>^58zPQZ-l_yPg$A?RiHJOO8WN|@ZF5(+9 znzqW|8m;H4ccO=AUd#aomN0l1%&AT({h8z*lQ(`Lw;q$1&J0GU_HTB}2jzb8cCUE* djKIKI&ZN`(cf0ck^ZkiCy@@-25g1Tu{tfG4YNh}H literal 0 HcmV?d00001 diff --git a/order/__pycache__/tests.cpython-312.pyc b/order/__pycache__/tests.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4e377203f4e68bf79bf63e60d61abcebe9fccbe GIT binary patch literal 207 zcmX@j%ge<81b1D(rz!#I#~=<2FhLog1%Qm{3@HpLj5!Rsj8Tk?43$ip%r8OGnvAzN zLQ;!MoD+*v{WO_wai?S@=B4NBl>o(xn1KpbGJFQ9`(^KJ6%$&VT2vg9n^=;O8sn0m zT$-DjS5h34nv|Fv6CaeAmy(|wACr`ypIuy%Uz8e?UzCzs6azA-Sg)Y+7l%!5eoARh bs$CHW&^$&UE(S3^Ff%eT-eXWGVgqsjS(Gv7Zj<2yc7xvLAi-BYpDl|5J!>iRYIL7s%uvQE3$nrB$DeR?1bg>1^^^@Y2XNO3>8ig89d^6 zfQ71ju{5aEL}YT=5Qc17&Y z<=E9&55+a(#V?l?s8JxCeG5hi@(>jGt;F%CV;#k7QJamU6ETG#VLhDjVkqC!aP>JFxM z4#L-U%VD(;1`H?Z3*T6^npL8CglpJC*ef>z_VlEuxV`lZZf`Dcz_pi4%c~@JR$=3i zs6{8j!3sMuVB<&B6+ggs#e0DpL_$@|tN4URB_b!N>5!1@VsUe^xU@`EzlKi-=PR8K zDksL`BXgVHJ2YJ@dWFp;zg%~*7lkG+S!EM$SRV3SXqJ3`H;m{>X2PF&K7uA?@*%Vs zDwyOT<8h|e2(t8mL@|29w^Z$cwgi;XmOSx6ZORj|Jn=)I_{l5R>arLC>*7#EpQxnBmr*ZCm8+(CXb~8C+(}v O{CJ!n{|l&-^!N|c*bia= literal 0 HcmV?d00001 diff --git a/order/migrations/__pycache__/0003_alter_order_user.cpython-312.pyc b/order/migrations/__pycache__/0003_alter_order_user.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..acff9e7199359f31030d2ca559718ba775fb1179 GIT binary patch literal 1118 zcmZuw%}*0S6rbJgZnsN;S~2KG5G)ZElZMDmjA_G%MgbF$glsmMY&%13-H)=njp+>& z4j#D?PhK_fM|k(N@vzM##)BtsO^O#{j5FI7NXi^$e(!VM{N9^y!@~-o>)@ZXx6cFc ziwXTD_CRNgf@6RH;w+$Z^yDqx7IcAQI>AcVqAuE!E^&Yd&j3ms0wiLwHquXYd7cPe ztS6hCCjDl@rp6K3$3akaD!#@O#jaL7GpM?bPbAw#*z(Jl2>_6LLgz09#{kC_={(|i zfQ4G$dL@EZlD;DL;0f0S6<$xqk(ogs#3O;)Qnj%`8y>3N9@N&d*XY!1baw}J*VlQP zIH7%E>s0KsSK;*0rlciFYNO8;B~ElbggtU=VPWABG_3%8FxJ3^k3EkOLlO*9*Oco( zN-PdA;R9C_DCvx7=$JMpiFgN))$_d-L)IbZ9U**Owm~JM^W#VVl7l zY^=EDhK-%TH*m=;8*s~XkZVJuZTpXHXIs2T07+E&gk-CV8I~Q}_ec1%d8z;X<(YgGj+wiAej*9Hd m`1k477C4UUNPwIE0j7R}xie{$la7=qGZSWJ{s1b(IsOA-(hIu) literal 0 HcmV?d00001 diff --git a/order/models/__pycache__/order.cpython-312.pyc b/order/models/__pycache__/order.cpython-312.pyc index 09ead88aeb009242ddbc045b694f3a86ef5f0510..efbf0d8c00a7b1ebf22580164111b6655b0fcee8 100644 GIT binary patch delta 21 bcmeyy`i+(6G%qg~0}vGbV@un}^NI-oNE`-t delta 21 bcmeyy`i+(6G%qg~0}%A;zDwQ6^NI-oNT>#= diff --git a/order/serializers/__pycache__/order_serializer.cpython-312.pyc b/order/serializers/__pycache__/order_serializer.cpython-312.pyc index cdfa2a8e4c1c48d127db2b531295950cf7a7179b..943505b15f2afb8d5af9e69c9960d8990bfc24e4 100644 GIT binary patch literal 2147 zcmZ`)&2JM&6rcU_N7y(f*a@`dql5-lRZO3WOGE<#fAvCc)0y8)ny} zMoyJOR2c~sP!H)bLL8{l1IJdX)IXp-#0{<8Q8~3e^hQZPR8D;}yS77sk@fuMz32D& zd*kmqJ3A1Z>OYaGH&ujw<(KBsLT3E~V3rU@SaMK7G9`)gvLhE1QxUx4s0Gc`1g|=g zLez{(NJb|R))okLOr-@?@~-CFwryA z#igtd?ADN-Xjx|4UJ+`g{S8Q$5J9GdktxfFC|JVMm-31nn42odw7kCY#{o~G&q_GI z?P<%EP$WDnt&%!~=bq==n>tn(k=fa9QY)(jj)JDE95dpqOO)R(^t>UnI3+f=+@e!v zYQZj+4TZ%nmk2F;#Ah9IH0KkcrF^p4uvU>t1SoI%`X@k^kS_@-kcyPwXcvm}%}zGW z;JaDx2)ZF>uE=@rebc!mUr(xFGcT`%vF4SEG651vNatYUu zn=>3EzHO+YV>AVRm|BAJ*p{%-o|VHvJ7bhwF6Ah}qvJ-D#Vo667l>uC4$CUQ);XNl zE$ed0b^;CMoo5;-iNhjOIpScC>Et7y+SbgRO{cvt&^nkPnig?+CUiTn{2lOK1hR-4 z$#hj?TaQ&EjqNWlpSq{5_8ngBedC%=`#?{5;ZLBKqfwyudtjD0W?T3LL3ps#LYn*> ziw#)xn{7sUUeKoVEJR}^2a)ecpGxy;MIJ$uI|2P#Ma{=H{TQzKEl09tQ~kA6|MHc!)L=FKTQa@Wd8@OY+*jkD!^!F( zeopMZyYJrl`-!6qCmP*{ZoXRYK2+;I^wspY?$>U8_-t+X?Aq|e>W6rB#=YM?yKuUp z4^&Ur^?{l`u%^GZ@b)8B*3$pR6z#~L2*`RzOiKqbdAM<-gC!{Od~1rr4$irBhKh=H zF}gvqab5t7L^$TAkQdMTo5J=(<_$LS(3XjYvaT_{!0rA76>|i(yYM)6EO-NkDSzYm p&Ut-6U}}=|0QLWlc0E9QAE1%H)E+5)bEe*Nu-0?%Zv+?N8|v zs5h5A=&eVUUOf0;2x7I+bfKb%2XE3SLQlR))Z)N=nD^#=zw>3jjIBA|n~@O*Xq~I| zWkHL*0=pJZ`kn^!Ab1yqAz96hYsJG>$MmglYSd@x!AN4YQm;Og7{$*6hpRrV{>}K~ z?9}?OfY1_p7eagAY+V~(g$I;dvc__wHp=_$DoT;^M&)iN`OMxkH+ika%t zpkE;AQ;-lc0ih=KkP9ZXJ6dRTbf52KucDB+_%GM=f^1dLB@vDj%D$Oo`PmyUp|2uf zhLG~XOpcBo?MTgap*J?MYV42pL%TK5$fVmLfLmPuZjr;6$cH4!5ez=$t*rn z4tPjG39zUz(5vUr`U{f|Q9$Uzws-7B_SM{`H@h<5bA#0@TW+x71|QrrD;IaUX5@a^ zno-&X!q7>Xlzlt(P)4m=OIT^h2Tfc?o%)&7yN6BDzTKK`G=;23$dk9$=_M629bHhZ z{SO+(`9I>GeV&Bvy1alVNyBJI#|htc#@G&&zQTzenESyUR(i6$m7m$j&-?@`2GM>4 D=n;vX diff --git a/order/serializers/order_serializer.py b/order/serializers/order_serializer.py index 4b7c5d5..efa3366 100644 --- a/order/serializers/order_serializer.py +++ b/order/serializers/order_serializer.py @@ -1,10 +1,11 @@ from rest_framework import serializers -from product.models import Order +from order.models import Order +from product.models import Product from product.serializers.product_serializer import ProductSerializer class OrderSerializer(serializers.ModelSerializer): - product = ProductSerializer(required=True, many=True) + product = ProductSerializer(read_only=True, many=True) products_id = serializers.PrimaryKeyRelatedField(queryset=Product.objects.all(), write_only=True, many=True) total = serializers.SerializerMethodField() @@ -21,7 +22,7 @@ def create(self, validated_data): product_data = validated_data.pop('products_id') user_data = validated_data.pop('user') - order = Order.objects.create(validated_data) + order = Order.objects.create(**validated_data) for product in product_data: order.product.add(product) diff --git a/order/tests.py b/order/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/order/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/order/tests/__init__.py b/order/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/order/tests/__pycache__/__init__.cpython-312.pyc b/order/tests/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eea059254c7e2d0dfdd7dcba28387c3e0164c746 GIT binary patch literal 169 zcmX@j%ge<81e3nArGe71<6Iz^FR2-9= zSdx(%KEC7JZESmrT literal 0 HcmV?d00001 diff --git a/order/tests/test_viewsets/__init__.py b/order/tests/test_viewsets/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/order/tests/test_viewsets/__pycache__/__init__.cpython-312.pyc b/order/tests/test_viewsets/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..719f2461524d68cde1d5390d1f9f75727119be13 GIT binary patch literal 183 zcmX@j%ge<81fd+?Q$h4&5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!3UjuK2`x@7Dvrrb zEXhcXami0E%}vcKDUL}^N=%N44@%5S$DM>8`ssWMl zWtpkv#i>AEe0*kJW=VX!UP0wA4x8Nkl+v73yCPPgHH<)93}Sp_W@Kb6Vg|ARaw0Nf literal 0 HcmV?d00001 diff --git a/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc b/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..38f5dfa7e8b3891cad058aee574d9735c01e1b60 GIT binary patch literal 3412 zcmbtWO>7&-6`o!0lFL8Iw4{hs;+V3WCYw~URm(xEpE|Dm6UT14atlvaWkPLJUMD4&6JWd(@NTtV@8MBsdRe0Wb83BN`@mm zIZd?qHKHYS;a0>ygR*y-lat?~FeP(tl-Wglk;%N9JU)G9MrZb9k?C$6gh`{U&)c9A zqxxl?G98pUCyTZ|XVK+T#gYx3+c8ZoZLwqrGTM2S=`@^9ou^tuLQ{b{u%b6r@=xVc zJ`i?(2~3sfMBy}|@I28Yw}L4}(70frt$2a$v>3!r4kqDV~5_y z+wc4xNR`-)IgQ)oZw1l{Q5)lS7%zy4CajQ3craKWwmEK741Ee~1Md=IL+t$q>!Kmw z>|tGW*Pe}?mWdpjauc>*dSl))thr@$kzKY8-4#u1k?G%RU__4440NuzK+7fFl}bT4 z(6tMGB;+WKfeP(GA|ZJK2_~m2S{M#c7MO0#GQ4p9;p>y51&kRhm__>yy>P-REt(K{ zR?sgNO9k~pabB}bwQ$k0E-?tYUhu3GY;ZX9sCpS(&h$|7ro*wJg=JTSxmOpibUhNH zA#V_G!(Ie(m2737-7sp|u{GhZ>8;*pHcsC;a`)ipgP#uG-CyhdBaEiDdipm;J{-R} zzA;qm`OTW}x5N&tB##6e@9qVA0fJT~5Cl|dX_ZE}niIQ%&S|_BDRY~`tswAWz*af1 zhdZ>i6|RDwZfUj$2sl_twM>B++UAJe8O~Prgj}-++k2Z*$b~1;#2gH*^8e>tycWfI zUrUQ251QSfm1bYTBxz~Q6aFac(qpV=TTFxa6RpP|W4-TZTTis{(o;XQ`gkuv2`8r> zCcN|?G|J3&V~Cq&Yu@EA58ni^y|h%MbBtnE`BjPOPca;B6acjh>R7gNryDJK=<7!2 zbekfKxXB`eBDGJxxmYyZqz~I_$%1;uWOkD;&&*7#zdC$aJ%82}DhxIi4XdazH&(Ld zZK&s#9q9pB=5H6F7#~-nI$N;j0sj3vs9Mo3GPIu0=P7y!@rl{0cf%{$N6Wc6gQ>(M z0GF%eL04~eY<;YHZ2j0)s_X4@8}jX$d-7;4HMSGsyAx~DwnXCTx|DUK?DcFtH|XRB zH!s%@9d`~LuSviAS5L00tSdL9dj7DJKYYJu_;$b3GqRR=AfZtTv?$Aymy^@(X`V!9^%zP-igo!rEoqLX{+ zlU^rx=I+Sn6Q54h&%WlIeeEBTN}mLev`49T!A-lLr0|_vZpOlAaaFJ} zzrChOD?(cw3lNq=T*BOMX|SpdGT9A0sXVs!?M4k(o^CM=Vx|9wV=LTdJiN=Q2o;@} z!aq&$wlcM>xiNT*DKK;&ET?Ff?njbG@*EIYAYkdZ(OHYan|dX4AtQ4Y1fv-_ zLopEEJMHpda{we)Sg@F1^`1Rf)E3PJ<~{mQ#?Rw|XOR2?iC6u5g6bbuCoh~lK6CN} z#TUnoSr;pM$!7E*NboU0x6va=(5ZA7$qPW-bcyQlmC*dsW|%Ng^U(aV&v?b{>jc%m zzfJY;R=|s}4}ieK-r4uo>YA{%H-CTcfwkCnl^?S%iyv*MQSC&;l4+nVxFjdf)XE_cQ%qqPuT9NxBd2kSM~)_j^dZ<6cMqjbGOX zjyMBHYSIYkv_qCt&Y@E^>GW21-+SqI()FzDWaSO}URJ)J9r;VztJEo3awS!rFPgfl zx(QV^;fre^pHfwXUw?+;-^~jc#U!MINXCHNB%T@1brh?`BUnHTLG&8=D*eP;f4X|= zJ0T*DewRp!uX8(nJ>pS+6)upw{J?hrBHQXLg_A5<^pYRzu15!lFg6s+-#d_-)GEdK zIcsQ<8q9w=GC}qZ&3d2qvd;V;B7RxiP7lm?O?mm~{T4gIb#Q+jj3GR@DPKPr!YuQz zcnmqjIq%vJrE%YBzon;P3_qGo2C^ODIPRY$`3>p+lDzm0+5c}c@g+I>1v&5qdHQ?d P1@7qEXa7r}^Gy8@h)>b% literal 0 HcmV?d00001 diff --git a/order/tests/test_viewsets/test_order_viewset.py b/order/tests/test_viewsets/test_order_viewset.py new file mode 100644 index 0000000..3136ce1 --- /dev/null +++ b/order/tests/test_viewsets/test_order_viewset.py @@ -0,0 +1,65 @@ +import json + +from rest_framework import status +from rest_framework.test import APITestCase, APIClient + +from django.urls import reverse + +from product.factories import CategoryFactory, ProductFactory +from order.factories import UserFactory, OrderFactory +from product.models import Product +from order.models import Order + +class TestOrderView(APITestCase): + + client = APIClient() + + def setUp(self): + self.category = CategoryFactory(title='technology') + self.product = ProductFactory(title='mouse', price=100, category=[self.category]) + self.order = OrderFactory(product=[self.product]) + + def test_order(self): + response = self.client.get( + reverse('order-list', kwargs={'version': 'v1'}) + ) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + + order_data = json.loads(response.content)[0] + self.assertEqual(order_data['product'][0]['title'], self.product.title) + self.assertEqual(order_data['product'][0]['price'], self.product.price) + self.assertEqual(order_data['product'][0]['active'], self.product.active) + self.assertEqual(order_data['product'][0]['category'][0]['title'], self.category.title) + + def test_create_order(self): + user = UserFactory() + product = ProductFactory() + + data ={ + 'products_id': [product.id], + 'user_id': user.id, + } + + response = self.client.post( + reverse('order-list', kwargs={'version': 'v1'}), + data=json.dumps(data), + # data=data, + # content_type='application/json', + format='json' + ) + + print("Response content:", response.content) + + + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + created_order = Order.objects.get(user=user) + + # self.assertEqual(response.status_code, status.HTTP_201_CREATED) + + # # Verifica se o pedido foi criado com sucesso + # created_order = Order.objects.filter(user=user).first() + # self.assertIsNotNone(created_order) + + # # Verifica se o usuário associado ao pedido está correto + # self.assertEqual(created_order.user, user) \ No newline at end of file diff --git a/product/__pycache__/factories.cpython-312.pyc b/product/__pycache__/factories.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c752b6585bc9b4405520e3d413fc6563d7be509a GIT binary patch literal 1872 zcmbVM%WE4)7@vJ=^;Q%+mWxH&nvjUbf?i@MO)pWLmSR&vLSRv|Y<9=0WW74OZmXh# z4msEmh<%di$nUi7ix#jA_} zJYpC%NM;q~m|=XmZC3pqhH2yqY|`qFWQ4w*-o5id@u5SRQ>>Zp7qnPtSlcyPcby`A zVp>JxzFD^$HKX{X(b#gpZCY&ll`3v}VU($pZ??FMZm=+D#Ex-708hy zU?Uf0xXYplF#sO&l|U}m%q_~e;+EYi<+4-VF7c>M9gCHlZn;tC+9xh$COE)Vuv`9$ zdMa50Re2ULUrZeXM(W%L054*TJNKTi@2>Z*AI0A7+#Nk{_uyf#b`-zaS$ic5%Hm%Hz&D4MrV4k~qR(Jw zQn)v0t^aP(Nn5GVpcw1SK<*v}-*oMQ)(d;Bmk8K(uJg)umtmExfX$u~i~)-?dH~QR zZNU**q%E@LwpbvaX9@XEZj*|4bQ&t>wFFyjc}xm{Ji98B7W{Gol09Pi9EaZFl4;w} zy|P2An_RURg)JVY-?$9QOl_`ieQmOm!?oZ}%fYAZZ5+%i`7$iOU6>9qKR%3Y=e!Tl zAup2i!&v%7bZ)qG4eA)r?`gx-TsOI&9Hf@}spW%@e@U&plwjjnBC&a|%2Ne?9WyV_ z_z)0trsWxCip3FTdKZ0V*8tvv{~3c8rWq8ORhPzFmjU28VP%W5Ih2#lhT|F~T1UMKhxMODd}>G%qg~0}xcr=S delta 21 bcmX@kew>}>G%qg~0}w3Gd6&A8XE!qdLC^*= diff --git a/product/serializers/__pycache__/__init__.cpython-312.pyc b/product/serializers/__pycache__/__init__.cpython-312.pyc index 9940e3931d94873ef2618db6379033988ceab14c..f80dc2de41fc1e62197fdf83d55b2b8f08a99885 100644 GIT binary patch delta 20 acmZ3_w4RCkG%qg~0}yz*f8WTh!UzB~a|Ff! delta 20 acmZ3_w4RCkG%qg~0}upNzu(BM!UzC0y9D|G diff --git a/product/serializers/__pycache__/category_serializer.cpython-312.pyc b/product/serializers/__pycache__/category_serializer.cpython-312.pyc index 96ef3792aa31bb1e2e9427eac306fa8339c4725c..9117dbcb9e75074d2596e91b675178530f56aa1d 100644 GIT binary patch delta 20 acmZo-YhvR*&CAQh00cLd|Jca=oe2OoBL+7B delta 20 acmZo-YhvR*&CAQh00bf4?>2IOX955)Ed@;g diff --git a/product/serializers/__pycache__/product_serializer.cpython-312.pyc b/product/serializers/__pycache__/product_serializer.cpython-312.pyc index 3d3972686fa7ff2136b709a0ce236fdf097aab1f..79da246573560b37099ae4f84768dc0d93624b16 100644 GIT binary patch literal 1633 zcmZWpO>7%Q6rR~XJN70isi}<;AVq?*2b@Du4pCKEYE+P-L{SrZSQ)K0JCm^6U9UU4 zY30h1a>yY_2!VtYBrXVX2&4y&9JzC;)gqgbdIAY?D>VoyC*G`gy(M|F-n@D5?aX}d zd(S^lPL>eJ!>=Z`f0PmWO>8nzQ)74=j3Y!4!9EJGiLtOHUkYSX4ir;K_Oh=AnyFzV zq4y9`4iHf(_NKDK^7RDn5n>iQno;;umDCW z%GZOFH3AX-+IYoqqHHhSxscb4cK-f3fR6CL(pI$n5Z+(@hI0CB#sb<4WD zYx|=JQ{a7Eg&_60w(U}%MBkyIDB`JkW2yN8@ELJXBF5%stE)IAtL0x@ENwz-~B4m3x+kQSYnUv!H)%?n}hdc@uU^`LgX z*G6|Y99@%Z}zK3uWB4GJgzPs>c7vtatUk7zq7|dRIj_^eN zaAlxh?CWzqeXg(1_w@O%XMfS(c_u^XnTCMQsf5QhW0HwWSXC%75=<06!O8?d9Ol3c zY}Q$!om*-F2%*sCo5RO~m_dyVyeW3$)TeB8MG$k}<+Voxg3{_4L$9J^*r@F_;4*xF_=SNB79Cw+a&K|PtHsGe>Uh7$<uqmjPO7T|57;iGv_P<)J^qPPA)?>v@S#cDM9BCD1u$oO0QzWFJsIl-w#nTa`>RjEY~V^OX8#bJ{R43nHxyCS*C25cg- ePZ_lCGPr$V;b!ET!F^rA_@adIR|X&lY!3kQmsfZI diff --git a/product/serializers/product_serializer.py b/product/serializers/product_serializer.py index 48e9b80..0e60199 100644 --- a/product/serializers/product_serializer.py +++ b/product/serializers/product_serializer.py @@ -4,8 +4,8 @@ from product.serializers.category_serializer import CategorySerializer class ProductSerializer(serializers.ModelSerializer): - category = CategorySerializer(required=True, many=True) - category_id = serializers.PrimaryKeyRelatedField(queryset=Category.objects.all(), write_only=True, many=True) + category = CategorySerializer(read_only=True, many=True) + categories_id = serializers.PrimaryKeyRelatedField(queryset=Category.objects.all(), write_only=True, many=True) class Meta: model = Product @@ -20,10 +20,10 @@ class Meta: ] def create(self, validated_data): - category_data = validated_data.pop('categories_id') + category_ids = validated_data.pop('categories_id') product = Product.objects.create(**validated_data) - for category in category_data: - product.category.add(category) + for category_id in category_ids: + product.category.add(category_id) return product \ No newline at end of file diff --git a/product/tests.py b/product/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/product/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/product/tests/__init__.py b/product/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/product/tests/__pycache__/__init__.cpython-312.pyc b/product/tests/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..29a49463165663f09edd4a113aa02113bdfdf31c GIT binary patch literal 171 zcmX@j%ge<81o7tIQ$h4&5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!@^ZF{2`x@7Dvrrb zEXhcXami0E%}vcKDUL}^N=%N44@%5S$_;7B(<~7y0e?0 zSV7{zA*iid)I)-V3P(_K2q$j+2YSIG$nF+IrE=+|qJ&;JRDEx~>m?sRyON*Z%)Iwz z=FR*4W`3@!3K95zydE4K3lQ=sEP9s?^$z}N@&taR_d|4qW*t$;> zv;L$%8%PH1wxCJbU^18uB|~;w)WX?FGGgm~ttuN$Mr}QyRVS-?GDuYEGEsvxxZo?# zo2;1*Btm~+Bf(qMy^2Z4bT&Ppq)hm;qGy<{PNqz!o#3qSIfF8{$y))(z>-pqD})L6 zoH;d24YOA40CU^%JoubU3p!y9{F(-|oRCys~$vcgeeW1({N|KyPk~~kS zZ^0Q#3MzM*Bt?}6=~sOq1Jgo6v}$omXE~px>4i_Jnc^HL{1f1ZyIvUpF-OeGm>YS9 z$dx|RJr_6+m0$ENI4c7iCv${MlY}sokLH-(lF}zkrfV8yV-Os^^a;p=Xr@h#T4Ii+ zQ#2tkjA;pzkU)luu>#C;n_S;(I;LeDFy z5&5h#q3T(ACV;GE1w4&vbqYrYvSBdzIzrfK62`!kXCqi$@DnAPrRrpDF0 ze~4Y{wOp;TBK{RC;#IK$j8#8Mu&HxBz5mP>Pj@wMRd0wJcum~68_oOw&vB*K#BKEA zxtbRj@DLn&5phbbO-mc56+pPB^$Clg>bwo0AHSfmF@qtR7$%)zzAZn{O?rwZqLx2p zQ-$Rlqb9@Cv%-o2STOs)np89^TqX@UrK^;M?ctNd!)N5K{rlxlKC*<20aJ;ZuBe6; zKu`i~7#^NC8N-rJ_*e|RB}R>$J^?i4E?ZU=Q!%hQTUuHeo|#pLu##axvZ84&lJdJZ zz|BU6n<0ep6NpQs6sw;*a`njE@vFxlMq=L&-8!{o-rIY0IdW{p$Jd2srKb`JRu!dq zL5k1Eiw$jshPK72VnfhQ=AL3}SE04*e*J;j$Zt}_vEO=Axz>EE zzR=LQ)P48poukDA{e=Vl%hEvU|C_`M4P8rpcTe9rUF;q#bPqm|PBJXjjdA{ujq~+< zdXY0LD9<3_t@)5y0bBkx-OwE4RNr-8|D>ToqNn z8USvQ+&DA58e9yyH{wO#OS6S%d>b)>>&YRmv5?k$;I#qT%?jExuf?ZXL0M+&n!wP^ zG_UVdxy48&Tf!^WBxG7P@_gf7giPxOelMK@;J#|ek|uPM;+5pwfLBfc$UKNwIq!os zHRQCK5BCAgS`2_^=V6A~V8}WQcg~tXn3Y%PN z9CGQDd(Zaw4EOgjELJO^pU=>gX)rtrZ;uJlCKZO)6T=4#+lAKEDMsOKq`J&u;4=Wo z#if^+%^GDR*CxN~RqV3b4wq__K)@XxYrP-aF)KZ+j(wNEk}qv;E^Tfqy}j$k__gu* zFa8P$O`#Pc)P!e+=TQ=j&SvL_m!(#Rl8UkIh1m8rq*U6pxzw=tX@J!2SRo?vlkIsg z+IsV3aYuJyNB6RH&|{aE2y39wF|aHRK55)`qvKjfv9Ybt*tYcHy~eitjmKxJJWxN;4BMe!>K39gM z%l4o+2;w%e!`N)jkQ{7*Cv0HVT_(R&ZTb51O9RgYzZiNJ4T-0?m3X~)sO*IfiA~lf z=U!_cwco~2$K~=uVza7s1{cyxL-tb-pN9CpYlrnx&9IBdt_~{(_l_x#GT6}tosG9+ z2{3%X*n6G~cm>hdVc0VTj9+P(-k>*Ea+pi@2Tx#PE%{To`;LncpFD Date: Wed, 3 Apr 2024 21:03:07 -0300 Subject: [PATCH 08/42] =?UTF-8?q?Ajustando=20pagina=C3=A7=C3=A3o=20do=20dj?= =?UTF-8?q?ango=20rest=20framework?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__pycache__/settings.cpython-312.pyc | Bin 2585 -> 2735 bytes bookstore/settings.py | 6 ++++++ .../__pycache__/order_viewset.cpython-312.pyc | Bin 651 -> 651 bytes .../product_viewset.cpython-312.pyc | Bin 810 -> 810 bytes 4 files changed, 6 insertions(+) diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index f2931e46432d91b24d5cfe09297db9d625c7bece..e05a6b564f3c4fcd4ece860ace5f31a314c6fc5c 100644 GIT binary patch delta 254 zcmbO!vR;(;G%qg~0}y0g;Z1uskyn!O+eG!Zd?`{X(kU`?n4-ihWi{nCOE9)EGIC9x z&$No4uPC*+BtESuF*mh5zbJdN2Qw=(BmZVUHW$YDDm_$5y@JH_%)G>s%=|pPfW-7v zztY^K)FL1YD)^EWXt5^KEeRJ_H^)$)koW*ccTYdZ5Kn)8$1i-jihb9%6I3o$kDeUh3S f$GKVJ0)x;8HU`B&#v6h{A6c1&m>T(tbbv|$b5~0< delta 116 zcmZ24I#Y!AG%qg~0}#wR{xvmlBCjOln~CagSt_M8r8g@vwlOktPF~5hYI8C(3o{!Z zP+677WJ4B_$v*5No2RmgGcx;Wif`uT5M!Kd$Qi|@2~@xc#KlaLr*e9*a|tmu@O_e) Q{DgBe$3+IAB6Xk?0Q5r~P5=M^ diff --git a/bookstore/settings.py b/bookstore/settings.py index 0502d60..478d64f 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -38,6 +38,7 @@ "django.contrib.messages", "django.contrib.staticfiles", "django_extensions", + "rest_framework", "order", "product", ] @@ -124,3 +125,8 @@ # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +REST_FRAMEWORK = { + 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', + 'PAGE_SIZE': 5 +} \ No newline at end of file diff --git a/order/viewsets/__pycache__/order_viewset.cpython-312.pyc b/order/viewsets/__pycache__/order_viewset.cpython-312.pyc index 9a6ec807a28a25923f97fccaa0f571b650927e6b..e46c7e3b1998cd72604bc12bd316fe79ce3292a5 100644 GIT binary patch delta 21 bcmeBX?PldU&CAQh00ajg@uqF$sb>NJIBW%Q delta 21 bcmeBX?PldU&CAQh00a>yzNT*Esb>NJIoSo& diff --git a/product/viewsets/__pycache__/product_viewset.cpython-312.pyc b/product/viewsets/__pycache__/product_viewset.cpython-312.pyc index e9797dad7f267b0e6d46843a5895d26b0d77f4d5..d89985498b57a82f012189258373b56afedec713 100644 GIT binary patch delta 21 bcmZ3*wu+7CG%qg~0}xDn%$v56M~)c)J1_+y delta 21 bcmZ3*wu+7CG%qg~0}y=3{G7UxM~)c)KrsdD From 9d6d473c7746772bd11d2e4976d2a1c9895ac1c6 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Wed, 10 Apr 2024 19:06:57 -0300 Subject: [PATCH 09/42] Implementando django-debug-toolbar --- .../__pycache__/settings.cpython-312.pyc | Bin 2735 -> 2842 bytes bookstore/__pycache__/urls.cpython-312.pyc | Bin 1222 -> 1328 bytes bookstore/settings.py | 6 ++++++ bookstore/urls.py | 2 ++ .../__pycache__/__init__.cpython-312.pyc | Bin 225 -> 225 bytes poetry.lock | 17 ++++++++++++++++- .../category_serializer.cpython-312.pyc | Bin 770 -> 770 bytes .../product_serializer.cpython-312.pyc | Bin 1633 -> 1626 bytes product/serializers/product_serializer.py | 6 +++--- .../__pycache__/__init__.cpython-312.pyc | Bin 231 -> 231 bytes pyproject.toml | 1 + 11 files changed, 28 insertions(+), 4 deletions(-) diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index e05a6b564f3c4fcd4ece860ace5f31a314c6fc5c..6cbeab32297445bb49205be73202ee32549bd3c3 100644 GIT binary patch delta 249 zcmZ24I!lc2G%qg~0}$A9iKoT#P2`hc{4-Jgy-+%1lz57CicE^^9HuCVN;ysW%}R`I zjEvlqS2CRxyv3W6npBz|Uy`4nlayGb$+5YFIhj#SA4OCzH!~$AC$&7WC{@n|q&x(o zdh;2U*^F!gKs&2ECL6MdO!i?H**uj^f{}~U(8yfR00<2yuVIg4l-$hCA(RPADEd0 cm>PIKa4{$bGTsmr`pC*G#MH=FqzBXo0L6hrlK=n! delta 139 zcmbOwwqBI)G%qg~0}y0g;Z1wSJCRR<@!Lf8_dF@mDKc}IqQom@HRU#IFt#x=a!p>( zbdpJveRC&sGUH}h)(MP^{F~RYxiU`v#~#Zlu{nlAoN;m^XC{{(&@@IME*6^nh0}wN pTZpNF?~@b|P7 z()9TF$)(KBQkvYi*nuMX$?@^Gcp(xc`T03XiA9r-FdK7~7UdM*VkyonNuA8dl58&o zbQ;K=#Th{212ZEd<3}cbMwZV?42+_885Hg_=v`#c`^d(?%Gn`3F?~kvbvc8Jat4>h a3@@`7-DKgI+|6RZ&B@Bo)W}@~3IYHLV@d7+ delta 260 zcmdnMb&NCWG%qg~0}!k@{WWz5GXuk85C;Z0pp4IRfQ;!3DGX5zDU2yhIgGhXQA~^= zHggVhE=v?kE^8EPE?X2EBLfpdDoYAWDpMBU#7Ty>tSPKO0k#yj)r=6MRx?3ppeRg^ z9bGP+If}EALz8n8V;9rpZf51lJDHt%{4}|4vB$@!xk<$d2LwAn}2jk&*Eu6F(!%S0x5U#rq6;7a8(v1|v2))/', include('order.urls')), re_path('bookstore/(?P(v1|v2))/', include('product.urls')) diff --git a/order/viewsets/__pycache__/__init__.cpython-312.pyc b/order/viewsets/__pycache__/__init__.cpython-312.pyc index 0f0ec18f01113828b4cd4ea73a02fc10a8982433..9a7f02304b1e1da24823acb55588bdc7922492da 100644 GIT binary patch delta 20 acmaFJ_>ht3G%qg~0}yE37fqYUa}@wP4F$9S delta 20 acmaFJ_>ht3G%qg~0}vd__?$YC=PCd|%LcRn diff --git a/poetry.lock b/poetry.lock index 2829174..ee33744 100644 --- a/poetry.lock +++ b/poetry.lock @@ -45,6 +45,21 @@ tzdata = {version = "*", markers = "sys_platform == \"win32\""} argon2 = ["argon2-cffi (>=19.1.0)"] bcrypt = ["bcrypt"] +[[package]] +name = "django-debug-toolbar" +version = "4.3.0" +description = "A configurable set of panels that display various debug information about the current request/response." +optional = false +python-versions = ">=3.8" +files = [ + {file = "django_debug_toolbar-4.3.0-py3-none-any.whl", hash = "sha256:e09b7dcb8417b743234dfc57c95a7c1d1d87a88844abd13b4c5387f807b31bf6"}, + {file = "django_debug_toolbar-4.3.0.tar.gz", hash = "sha256:0b0dddee5ea29b9cb678593bc0d7a6d76b21d7799cb68e091a2148341a80f3c4"}, +] + +[package.dependencies] +django = ">=3.2.4" +sqlparse = ">=0.2" + [[package]] name = "django-extensions" version = "3.2.3" @@ -242,4 +257,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "666f30d1d7a5685d05ac3522b273bef1005787ee9f01023cdcf3c4863ac7d9db" +content-hash = "aed3988f00805233a5c40b7b8d9fd11b35ba2c4cfa51384d36ca1f3b7470bb07" diff --git a/product/serializers/__pycache__/category_serializer.cpython-312.pyc b/product/serializers/__pycache__/category_serializer.cpython-312.pyc index 9117dbcb9e75074d2596e91b675178530f56aa1d..99bd79e645c4a184188739bc77e3b42a4e1e13eb 100644 GIT binary patch delta 21 bcmZo-YhvR$&CAQh00eChMbkF&d}9ItHfaT; delta 21 bcmZo-YhvR$&CAQh00cLd|47})^Nk4rJg^3x diff --git a/product/serializers/__pycache__/product_serializer.cpython-312.pyc b/product/serializers/__pycache__/product_serializer.cpython-312.pyc index 79da246573560b37099ae4f84768dc0d93624b16..bde867f23b9a84faa7875b7394e16dee3a319838 100644 GIT binary patch delta 140 zcmaFJbBl-fG%qg~0}#|a6iwT*kynsKhBrB}BsD$1s4_k!u_W;pdqGitN@;RQkqA)L zWJeY&PYJc_5?U7}v{u+(may*NeIg_|U4Nqfbs>$5AY`?|4oGyc-;hxK#K6d@-QjVA nNBBCA%taoV>pTh8QCJ{-l}GmjGf-;tUY2Y|M*Yc}Y=!`c^D#02 diff --git a/product/serializers/product_serializer.py b/product/serializers/product_serializer.py index 0e60199..a494f2e 100644 --- a/product/serializers/product_serializer.py +++ b/product/serializers/product_serializer.py @@ -20,10 +20,10 @@ class Meta: ] def create(self, validated_data): - category_ids = validated_data.pop('categories_id') + category_data = validated_data.pop('categories_id') product = Product.objects.create(**validated_data) - for category_id in category_ids: - product.category.add(category_id) + for category in category_data: + product.category.add(category) return product \ No newline at end of file diff --git a/product/viewsets/__pycache__/__init__.cpython-312.pyc b/product/viewsets/__pycache__/__init__.cpython-312.pyc index 2e51c0b94b95ec9eb15fca19e583f44952588991..7eacde127c78dee896aa7f51e8c7f518792c2711 100644 GIT binary patch delta 20 acmaFP_?(gFG%qg~0}wdf7fqYUa~l9Wtp(r! delta 20 acmaFP_?(gFG%qg~0}!OSe@~sra~l9Ye+Eqe diff --git a/pyproject.toml b/pyproject.toml index 38aa87c..e38dd29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ factory-boy = "^3.3.0" django = "^5.0.3" django-rest-framework = "^0.1.0" django-extensions = "^3.2.3" +django-debug-toolbar = "^4.3.0" [build-system] From 12f7a852459c3ad8ef5f683f5aaf5e3deed08663 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 14 Apr 2024 13:54:38 -0300 Subject: [PATCH 10/42] =?UTF-8?q?Implementando=20autentica=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__pycache__/settings.cpython-312.pyc | Bin 2842 -> 2995 bytes bookstore/__pycache__/urls.cpython-312.pyc | Bin 1328 -> 1328 bytes bookstore/settings.py | 16 ++++++++++------ order/__pycache__/admin.cpython-312.pyc | Bin 251 -> 251 bytes order/__pycache__/urls.cpython-312.pyc | Bin 604 -> 604 bytes .../__pycache__/0001_initial.cpython-312.pyc | Bin 1400 -> 1400 bytes .../0002_alter_order_user.cpython-312.pyc | Bin 1134 -> 1134 bytes .../0003_alter_order_user.cpython-312.pyc | Bin 1118 -> 1118 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 208 -> 208 bytes .../models/__pycache__/order.cpython-312.pyc | Bin 758 -> 758 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 234 -> 234 bytes .../order_serializer.cpython-312.pyc | Bin 2147 -> 2147 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 225 -> 225 bytes .../__pycache__/order_viewset.cpython-312.pyc | Bin 651 -> 651 bytes product/__pycache__/admin.cpython-312.pyc | Bin 277 -> 277 bytes product/__pycache__/urls.cpython-312.pyc | Bin 610 -> 610 bytes .../__pycache__/0001_initial.cpython-312.pyc | Bin 1777 -> 1777 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 256 -> 256 bytes .../__pycache__/category.cpython-312.pyc | Bin 951 -> 951 bytes .../__pycache__/product.cpython-312.pyc | Bin 967 -> 967 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 303 -> 303 bytes .../category_serializer.cpython-312.pyc | Bin 770 -> 770 bytes .../product_serializer.cpython-312.pyc | Bin 1626 -> 1626 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 231 -> 231 bytes .../product_viewset.cpython-312.pyc | Bin 810 -> 1079 bytes product/viewsets/category_viewset.py | 9 +++++++++ product/viewsets/product_viewset.py | 7 ++++++- 27 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 product/viewsets/category_viewset.py diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index 6cbeab32297445bb49205be73202ee32549bd3c3..878c2eacefb304325a06065d5ac88bffa09caf20 100644 GIT binary patch delta 335 zcmbOwwppC-G%qg~0}vcIBb6q~Kao#@iHUKd#yg1==@gk1*>t89xjD>H;wkd!j8PJm z3Yv*A)fwz@sm9{1hj9-!DJjmLp)sl zLOh)zvd%t^!NIP2ns#mu)e`z`+=2No$Vt#yAV?Y-v>Q>jiAp(5`OSKa zr`fnT4UNq841myZ@(*@XCQYWv(>YW(Kj)BQl;!dC3vmtdbM%S#3<$o(7vvfo67Lq| z=<6EpALKn*jw_1G0B8{-5EsjBZsOu#lw%e6z|17T)WGwBi$O7v@rIz#M^c!81UG%qg~0}vcKDU~*n=Li5iK?Vu{ delta 20 acmcb>c!81UG%qg~0}ycOzDu3Ra|8f4u?2|$ diff --git a/order/models/__pycache__/order.cpython-312.pyc b/order/models/__pycache__/order.cpython-312.pyc index efbf0d8c00a7b1ebf22580164111b6655b0fcee8..a00174f59b8fd0cc71add066948878c1a892dc86 100644 GIT binary patch delta 20 acmeyy`i+(QG%qg~0}vcKDYcRNH4^|r`vyM% delta 20 acmeyy`i+(QG%qg~0}vGbW8296nh5|wr3MfH diff --git a/order/serializers/__pycache__/__init__.cpython-312.pyc b/order/serializers/__pycache__/__init__.cpython-312.pyc index 099c8fecfe6bddeebd4ebc156bc8f36dc371a031..ac7c6b1b13546e19325d61c74c6f694131e36558 100644 GIT binary patch delta 20 acmaFG_==I|G%qg~0}vcKDU~*n=N;{|w diff --git a/order/serializers/__pycache__/order_serializer.cpython-312.pyc b/order/serializers/__pycache__/order_serializer.cpython-312.pyc index 943505b15f2afb8d5af9e69c9960d8990bfc24e4..fd67f364beb127f8126b6437d3c4a9a5d2930868 100644 GIT binary patch delta 20 acmaDX@K}KRG%qg~0}vcKDYcP1f&&0Rl?9>z delta 20 acmaDX@K}KRG%qg~0}yn4W826b!2tk2sRe-m diff --git a/order/viewsets/__pycache__/__init__.cpython-312.pyc b/order/viewsets/__pycache__/__init__.cpython-312.pyc index 9a7f02304b1e1da24823acb55588bdc7922492da..1ce246db264ad424972ac7b3aa2ca6620fff3160 100644 GIT binary patch delta 19 ZcmaFJ_>htNG%qg~0}vcKDK(M%8UQ%U1=aun delta 19 ZcmaFJ_>htNG%qg~0}yE37oEs`4FENX1x)|| diff --git a/order/viewsets/__pycache__/order_viewset.cpython-312.pyc b/order/viewsets/__pycache__/order_viewset.cpython-312.pyc index e46c7e3b1998cd72604bc12bd316fe79ce3292a5..ca1c3066252e9cc212ed3337eccbe4b29da3a6cd 100644 GIT binary patch delta 20 acmeBX?PldZ&CAQh00f6lN^RtBU;+R#Lj?W+ delta 20 acmeBX?PldZ&CAQh00ajg@owa9U;+R#kp&3= diff --git a/product/__pycache__/admin.cpython-312.pyc b/product/__pycache__/admin.cpython-312.pyc index 18f9eb98803ee0c9d2ace638253b3d5efd8bd832..f0a496dbb8cda4b755c571f6a38416dfd0568be2 100644 GIT binary patch delta 21 bcmbQrG?j_xG%qg~0}vcKDV4U7hm#QiI79^e delta 21 bcmbQrG?j_xG%qg~0}%XFc$d17hm#QiI#2~& diff --git a/product/__pycache__/urls.cpython-312.pyc b/product/__pycache__/urls.cpython-312.pyc index 8e79d6a7943c79f8b68bd7854e493458bc63b1e8..3e9755f131117d68ac716b8df1b90fd445a88ef2 100644 GIT binary patch delta 21 bcmaFF@`#1!G%qg~0}vcKDV4U7CyWUIMKcBH delta 21 bcmaFF@`#1!G%qg~0}w39`<%LwCyWUIM%M;M diff --git a/product/migrations/__pycache__/0001_initial.cpython-312.pyc b/product/migrations/__pycache__/0001_initial.cpython-312.pyc index 6b806de9d9b58597e70997a73bbfb86e3595de73..1deb86e319c5a3c4da2ea9b417ec43ace75e6a58 100644 GIT binary patch delta 21 bcmey!`;nLDG%qg~0}vcKDV4U7=P4TiN&^O~ delta 21 bcmey!`;nLDG%qg~0}#y8eV4kC=P4TiNpc3d diff --git a/product/models/__pycache__/__init__.cpython-312.pyc b/product/models/__pycache__/__init__.cpython-312.pyc index 10d2a89981993c6e04ff34dcc78e4b165af7d3fc..97951aac1ce8f3e67cf596826b5a7e40935d9c28 100644 GIT binary patch delta 20 acmZo*YGC3y&CAQh00f6lN~KNY`2qkiwFR62 delta 20 acmZo*YGC3y&CAQh00fTi-%}^@d;tJ1Zv}M# diff --git a/product/models/__pycache__/category.cpython-312.pyc b/product/models/__pycache__/category.cpython-312.pyc index d32cae66178ae0d384e34ec7ca1bc3964486a963..2a75446ae8aad6d5c6a5acf1374e4ab4520aef05 100644 GIT binary patch delta 20 acmdnazMY->G%qg~0}vcKDYcP%4Kn~aYz2n^ delta 20 acmdnazMY->G%qg~0}zBR;M~Z)h8X}gCIsLB diff --git a/product/models/__pycache__/product.cpython-312.pyc b/product/models/__pycache__/product.cpython-312.pyc index dbd9ab55daa7c0a0cd7b36f562ed749505de922c..55da1ea3def141f22456a10e404e41884ea8e7a3 100644 GIT binary patch delta 20 acmX@kew>~AG%qg~0}vcKDYcP%4>JHe>;<;~ delta 20 acmX@kew>~AG%qg~0}xcr=iJD>hZz7kqXjeo diff --git a/product/serializers/__pycache__/__init__.cpython-312.pyc b/product/serializers/__pycache__/__init__.cpython-312.pyc index f80dc2de41fc1e62197fdf83d55b2b8f08a99885..c7c87f404751e70ee74db958fae5219ceeac005c 100644 GIT binary patch delta 21 bcmZ3_w4RCQG%qg~0}vcKDV4U7N0|`-JctEK delta 21 bcmZ3_w4RCQG%qg~0}yz*e^1@Wqs#~ZI%5Sa diff --git a/product/serializers/__pycache__/category_serializer.cpython-312.pyc b/product/serializers/__pycache__/category_serializer.cpython-312.pyc index 99bd79e645c4a184188739bc77e3b42a4e1e13eb..7f6f0faa00d66ff3894d8e6d794a576005f3ec25 100644 GIT binary patch delta 20 acmZo-YhvR*&CAQh00f6lN^Ru+&IAB4{{>|L delta 20 acmZo-YhvR*&CAQh00eChMK^MPX955)(gi#K diff --git a/product/serializers/__pycache__/product_serializer.cpython-312.pyc b/product/serializers/__pycache__/product_serializer.cpython-312.pyc index bde867f23b9a84faa7875b7394e16dee3a319838..fe7c7eb2eb297883b455e5d4d2a2ed45171de9a8 100644 GIT binary patch delta 20 acmcb`bBl-jG%qg~0}vcKDYcQ?pA7&$n+1IU delta 20 acmcb`bBl-jG%qg~0}#|a6y3<}&jtWJCd-3GVMq1;*zIpS#c{A^u{os7|>R)QLD(F$S&Trje zgZg4m=+!=i5Mm4o3Pi(M%o0mj2^YLvTd|!u!YMhA-NX}K$?dq3R7Dkm!D9%WK7=me zN6Xv*AZA{Be&vUuK8|LerXj`8Bid_G=Cje67AX~_w>uBI*(>T~Q9H<@v@<&OFi=r@ zx~T1Q>*}8xg@fMJYs?(2$H9t*eIO7Rf?#A3-)6!lXB&k}o~VS_2T>h-mFVX8@g3Ik z@3?|9xx<=0uD#OMFj@$vl5Do)Kq*qvG2+Qxl1XF|ca8+l2=j_$6vWXRk`qDB>+*Y$ zC-fxe444-$!5Gv<4Sg6c-zaWADVCb+1#b)+esS({!54;SR||gnfTP`<_>J|MKb!a1 zg^eXiD%;$WK|*_}+*zBBD~}s#{I~Hq`rl^iyD|;C?QAVE|3pbQ|HQ7mFzF^)7Y#eg w|J%E(_jO~sCzrK=`YW6GX(8emu788p7;YUpfS1Pb=ofRa`S#@@=&3y855nT5-T(jq delta 362 zcmX|6Jxc>I7=GU*_kr{dMX}-{iU%I3bZ`)nPJ)XcgCZCNDNTff9MxQl=zKrGazj^F z?JD>qTpXp?NgUjS>f&V5qVMp$Px5?_Jo@);_!IRoULIyoH?$VQwIbHRFEP^ zw45lCQcj1QDwaCjK_IXVg5@9_iCt=20JwYQ#@>geG4@Kk4I$N0A}2^SRbbYQOU zK!;}Ok_GP%Y#_684lm`UXErrp=tLu@HSNV-u|el1!gJjat$K4cwJ*&yD<0_bzD Date: Wed, 17 Apr 2024 22:05:41 -0300 Subject: [PATCH 11/42] =?UTF-8?q?Implementando=20token=20de=20autentica?= =?UTF-8?q?=C3=A7=C3=A3o=20e=20retomando=20testes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__pycache__/settings.cpython-312.pyc | Bin 2995 -> 3068 bytes bookstore/__pycache__/urls.cpython-312.pyc | Bin 1328 -> 1477 bytes bookstore/settings.py | 4 +- bookstore/urls.py | 4 +- db.sqlite3 | Bin 192512 -> 200704 bytes order/__pycache__/factories.cpython-312.pyc | Bin 1747 -> 1747 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 169 -> 169 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 183 -> 183 bytes .../test_order_viewset.cpython-312.pyc | Bin 3412 -> 3437 bytes .../tests/test_viewsets/test_order_viewset.py | 35 +++++------------- product/__pycache__/factories.cpython-312.pyc | Bin 1872 -> 1865 bytes product/factories.py | 2 +- .../__pycache__/__init__.cpython-312.pyc | Bin 171 -> 171 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 186 -> 186 bytes .../test_product_viewset.cpython-312.pyc | Bin 3252 -> 3166 bytes .../product_viewset.cpython-312.pyc | Bin 1079 -> 1122 bytes product/viewsets/product_viewset.py | 4 +- 17 files changed, 19 insertions(+), 30 deletions(-) diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index 878c2eacefb304325a06065d5ac88bffa09caf20..a05475ab4fa1a77eb6aba927500ac29ae19b4d30 100644 GIT binary patch delta 157 zcmdli{zshmG%qg~0}!k;Qb;S@$ji+rmd=nOvxqT8b`Eotc#2#)W0XXtyr#ltJ;pXh zMxM!AnQll`Nff0Pm&B(PCFZ7<=NDz`C6<TDm`IY2@m#28owJ}@&0Fg5ZN=>y#Z E01Z(r%m4rY delta 128 zcmew(zFD02G%qg~0}vcIBb6q)k(ZlMEJY?oHk~O&ZVq#lc#3>FW0XXtf~MkTJ;pXh zM()X5nQm-e&b)wS@te38q8okxhNf$x*dWCia1$`3fKZ*bUt eU}aWk`^e4?lK3FPz$);8nMr`Dk*7!>Xe9tF<|B## diff --git a/bookstore/__pycache__/urls.cpython-312.pyc b/bookstore/__pycache__/urls.cpython-312.pyc index a1768d52a5324e2d3388f8b43ff329d9deb6cb2f..a2f5f1ab5d042f993997eefbe7f41a370a22276b 100644 GIT binary patch delta 332 zcmdnMb(EX;G%qg~0}$95E2MQzzG6}8E*;ZCzT{-=EWzLmSn`2aI^61#))ZDC$)3uXB`~o_y`C+VIZFtn z5EWzzpz=Yy)l3jEpmw$tc90<{9IF{2Vp!xj(dE)vqPQxVG`SKRfCh1e2Kgu?=Wo_w zT*Nf_F|!|&CimnR7O%;tS@Kjt?g5!woB(v1|v2))/', include('order.urls')), - re_path('bookstore/(?P(v1|v2))/', include('product.urls')) + re_path('bookstore/(?P(v1|v2))/', include('product.urls')), + path('api-token-auth/', obtain_auth_token, name='api_token_auth'), ] diff --git a/db.sqlite3 b/db.sqlite3 index a644e7f52a4252e16a6cb514b1f8bf99aee89eea..c4e3cf4566fbe4520c56b126d9581e3db3fc8bbd 100644 GIT binary patch delta 1678 zcma)6PfXip6!(Xn1ltKOl+hGgEeQ~k;Dq>J?2wI?6fyytC@`W;l^}JA2~mNhG+Db| z08OfE3D_SLyhf$X3klx@zil{rc8(hn*L=XH8b z?XVDTE}@l*i^co}eTC31k;05PSz1gmi8tSIlWkho&h}MG`B;&ZF(^AqP!* zo2#nR+0}fhU}s1-UA`5O5nJAgaP1uouAc=T0e`^v@C3evli;g3`Bn%YqugFpt9QRt zwvBST8Ujpt`qW)AL|-f0hQ^%CdrXEIVm!EeJM|K@1G~*)=VbY2d>i6Z3Ka zW4u9TUs_GoOm(rl{5b9lGxe&fh&@3jrq{&O3#wxFw9Ir>iB9-1$n9rpTB?Yu41=Qb z+4!7=4B0o!w#hN4qu0^qAnbqIpV+tUx9yu1uSd48wNr>gjXeyxC=@~eZ5n6#>m?bx zweKYg1rb|QVK{?M3VBgo4+2LhkGX+1Xs zYa4FlAT|aGy4#`Bbiz?Me<8CVrY|jOVpQqDdmmptlJrJa8eJ`2lqM4S@i&vPl&oh9 zJ%y`hr!T(6C6`mN0xwRMlt@Y~oR$)$(g>%H4NqL2NEObGEF`Cj^MlJ;aZxW_(o3>X z_c|2GE^E1^{`vfJZCn%&&&MStE~xzyuf$?vbq)~xP2k&xMgI!WLUz-2EO*zbNix*3 zTedwKbAlhda2(nJfCjQ<7q897Exd(9hz%K*Gi;w>gH_7}4C^;+uVHVF9LK5PC4H6~Zo-BHZ3X2Jr}k1FnOCt*IZ;m-qdaA;L*MCa|<^ z$9=ob7MQQ;e{8>5Z&?1ajMAJfM?SV7Y8wyc=j54#Mfl zVAATE;>zE#C%TQPH~*9t8`y-wkry~$Jx*xA@p$c;tLOOE=toWW#&4`s%?R!h_zvKu z`~s$5L)2`776g%(6_pqCD6iwAbwSf(vZ!TLRTeVQ`GEl;lhHI4qxR2oA}D3YYsy@_c<0M$XAs^tGkMxPT^b@&_^SzvDm6e~W)F{{sGM z{viHz{%)Wt7W|Wg>^Cv1a4nn6?%)X&2;87HoLWKQVxH(FB1_6IdLWRrqx$vtIzIyUVv(_x|+SsKA_md*FG-4F{Bg4&r6?VBlxwJH&f{CzZQ^YYXRB_UCMqSU<3OaB8z> zvgB`e6!2!zYz%W`7jFy%61uvKO`#=;Nja%`spawU`9&$IMGz9qpYA%7Y2$X!sZ86w MCI)abYQS6x00;SG7XSbN diff --git a/order/__pycache__/factories.cpython-312.pyc b/order/__pycache__/factories.cpython-312.pyc index 5c2bd05bb5e1aac294b9656f8085760f2d8f587f..7462700106f08f19b4018e2a5e10ac2761ca572c 100644 GIT binary patch delta 20 acmcc2dzqK}G%qg~0}vcKDYcRN1RDT8rv>T& delta 20 acmcc2dzqK}G%qg~0}#w-VBg4nf(-yTodoLu diff --git a/order/tests/__pycache__/__init__.cpython-312.pyc b/order/tests/__pycache__/__init__.cpython-312.pyc index eea059254c7e2d0dfdd7dcba28387c3e0164c746..a854db1aaa889fc8e9479db0ae0eec248b3a38ee 100644 GIT binary patch delta 19 ZcmZ3Y1sDJT diff --git a/order/tests/test_viewsets/__pycache__/__init__.cpython-312.pyc b/order/tests/test_viewsets/__pycache__/__init__.cpython-312.pyc index 719f2461524d68cde1d5390d1f9f75727119be13..333e8b32799c317bb5ac5478278159ede75a6a62 100644 GIT binary patch delta 20 acmdnaxSf&bG%qg~0}vcKDU~*nXEgvgas|Ht delta 20 acmdnaxSf&bG%qg~0}zCAd{3Rovl;+3J_T(6 diff --git a/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc b/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc index 38f5dfa7e8b3891cad058aee574d9735c01e1b60..a1fe00220f11263040a7abeddc6b6a740663e4cc 100644 GIT binary patch delta 915 zcmb7BO-~b16rDHUotBoNr8q4RCNoAY(m&+i5jB8G=kVL18Gy*=FKz>NE6-F zX#B{HLEISE5EH}3xMEqt0w-cx8(jDUOfcwD<2)Lb5L|c{=e>K+z3;r6vlI9daBnp< zNR%B9<~n9C39sE4$&J@^!@Pnu9Zw|n!d2Z|e~6wU*?+VQr$m@G41g?5&?N~r1b>@qDbY9MmNK#- zSjvTRc)M@2uM(TIVv{@K)PHw~mU6K?v>n}yR>p2xV>friY4S$zUlqwx#>%6Xa=Bcv zl0z8hODHA6UD5Ae zMRlUc*k(z@EYtvq^$vP|4`{T;XlxR#ajUkeB$gPBUlUfDdRAoZN!ix&Ldelfn?Cr& z^}xKNoldops*KjeKPub;r8?lFqkm?xF_FuqlQRi3navEQjBG}wYpj+q6E)XNHe>1; zbJ|?U=_;zRc|*sl2Rm#*OxD4w4K+^7&*zL9oz!rcOKz z1gQ)WAa>$21p45u6p=$mt%sjdOJv1vxI^uF0{4q0cDJeHeN(6;?0US97Vj-qTf1Jw zR$|Yh)t2CL;Yr~u#{{K)ifMGhsI$XYm7A-|sXc-6h4(4eCzZrK7l2cDl3(HgfdOD# j=bAHUKj7hpagdbUHmF{#!no_3ryC7FzWtrDj|1`-+Zyw+ delta 870 zcmaJ;O-vI(6yEL5Zg;osmeL>CZTTq_r4UTyrzlYMz(M)PG@J;~&?TV>Z8N(BC9Qh1 zi5HuR0gZ`p2BX9aobag8L^jmaG$d-GH%%bm$%`{o6Pp<4@Xed=eeat$^SMS5ei zi44uGgRmsG5SXG{OEuAW<&1Xj_gkE zOcugpMtCgGj}v`Oiy?=%qlSFtWtAacd)4_a{5o71oH7Qd-t*Jw7Vo7WqepxjNSopS zeWqO?P2+$TJWPg3qdnejiVG+wIPrsq1;wh{aJ#1~E}Aj(ta#+Rcs1>yff@gDkvhm z*mfH>V{On>1hJ?dEpl^7xDeHs9oJPYl}u=A{cJL!s|md)NEgAProx~D3b+FD7>cI( z7;Gc~NF_BLawI|gifn9gA*B`B6r4}!u!ZnV1kMm3k1AGNjYP(#+tD*o_60Bzvo`q^uS4%S|J!nrc+@TKa%Dqe$98}itS2kqLha6QCcrx&C zV72cS?%9<__5BV99k$>;F#iEVwOLtpaf}8@~>Se zG&g}2k> EFUXGRX8-^I diff --git a/order/tests/test_viewsets/test_order_viewset.py b/order/tests/test_viewsets/test_order_viewset.py index 3136ce1..40c7c47 100644 --- a/order/tests/test_viewsets/test_order_viewset.py +++ b/order/tests/test_viewsets/test_order_viewset.py @@ -10,7 +10,7 @@ from product.models import Product from order.models import Order -class TestOrderView(APITestCase): +class TestOrderViewSet(APITestCase): client = APIClient() @@ -26,40 +26,25 @@ def test_order(self): self.assertEqual(response.status_code, status.HTTP_200_OK) - order_data = json.loads(response.content)[0] - self.assertEqual(order_data['product'][0]['title'], self.product.title) - self.assertEqual(order_data['product'][0]['price'], self.product.price) - self.assertEqual(order_data['product'][0]['active'], self.product.active) - self.assertEqual(order_data['product'][0]['category'][0]['title'], self.category.title) + order_data = json.loads(response.content) + self.assertEqual(order_data['results'][0]['product'][0]['title'], self.product.title) + self.assertEqual(order_data['results'][0]['product'][0]['price'], self.product.price) + self.assertEqual(order_data['results'][0]['product'][0]['active'], self.product.active) + self.assertEqual(order_data['results'][0]['product'][0]['category'][0]['title'], self.category.title) def test_create_order(self): user = UserFactory() product = ProductFactory() - - data ={ + data = json.dumps({ 'products_id': [product.id], 'user_id': user.id, - } + }) response = self.client.post( reverse('order-list', kwargs={'version': 'v1'}), - data=json.dumps(data), - # data=data, - # content_type='application/json', - format='json' + data=data, + content_type='application/json', ) - print("Response content:", response.content) - - self.assertEqual(response.status_code, status.HTTP_201_CREATED) created_order = Order.objects.get(user=user) - - # self.assertEqual(response.status_code, status.HTTP_201_CREATED) - - # # Verifica se o pedido foi criado com sucesso - # created_order = Order.objects.filter(user=user).first() - # self.assertIsNotNone(created_order) - - # # Verifica se o usuário associado ao pedido está correto - # self.assertEqual(created_order.user, user) \ No newline at end of file diff --git a/product/__pycache__/factories.cpython-312.pyc b/product/__pycache__/factories.cpython-312.pyc index c752b6585bc9b4405520e3d413fc6563d7be509a..8b774ba83718fd9bb750e482e05091e659245476 100644 GIT binary patch delta 128 zcmcb>cao3yG%qg~0}w2AQ%L*0k#{W%Cr5H(Nosn2QRU>LEE-}(vOvjVRv@7O0!0Eq zR*~#v4pwt1oe3N_1VpCuPUO8VpmBF0qu{>jJ!INBUx)0RVH6!4QG^{tj89~ at@D|gflc-U6C10} delta 142 zcmX@fcY%-hG%qg~0}#ww%$fFgBkx)kZm#6SlGOD4qRiCd$%k1qq;GLR1uBbKfeIBs zphy77DpH=z$Z9U7H-Y1ZfXHFYvf3p!<=TkymeW5Ni#i>g4mR;VjBP k^^^ZIiB7g>bL7_h%*?Pfp~L=8#vPUp=#WM*QR!E;rT> hd<>ktlOJ$hV-%abo%8}hxsz?l|8317GFQfnf delta 310 zcmca7u|<;iG%qg~0}#xc!mZ^C9dKvB_C1YAz*GFsUpV7z;sX$s^b>Rtn=9p4E&HUM))vLzeL51`bVr#??#^ zF-8Wcm?)#tw&c`h zRGpl}xs&n6WEn1L4mq{?*)y|e#7?&7aufT)$H2*Vflq0H$8{Bxiz+5pI81MF@J#OF ay2dCzIg$Gvzb>Q24C${7K&nU#XdVEqVLRFY diff --git a/product/viewsets/__pycache__/product_viewset.cpython-312.pyc b/product/viewsets/__pycache__/product_viewset.cpython-312.pyc index 689ca862e01e8eb07f620d747876d9271384789c..0abb20bdd6286b95b45ae4c3b211d0bb9b610406 100644 GIT binary patch delta 469 zcmdna@rZ->G%qg~0}z;)D5RxMbIb6BiQQV9SObqS}DQqnaDeS3?tC>M2F)&2&RB~u?z63Ef8E^6U=BK3Qgk`3d z2d9>3GEbbV!+uLRBtJVfZ{lu0L#P&p&uT!`(-~43q8L*cqL@;dQ(013)0v~#QrXiP zqc~DIqqtHSTNt9aCtENUF>*{^&3KfNXL2Ev9#aw9i#S0N0>!CCnTa`>RjEY~i6TLu@JfavAs|&G03x_y1P72&tO_Jr7;eZJ zUoiE!;1zp8Htqt8)D0=k3zAwFSj29KYg}Lv`OLz|stPfIn+>SmPm_1D6|+0YMRm*y zVqh2X6%^&ClqQ$x<$^+?xQJu&7G|9&keeVDN`hE$NBrWj0jev_Nwq7I2TCvkG1w&^ qm>C%v?=l$NXUMq7ka3s6>?<1sqw-w_moH3gjH(l2zA^wQurUC>ly30= delta 424 zcmX|6Jxc>Y5Z$@&d}$O(Oh_VVf}VsZh&GB?2x_5CKw(iN#gv%2+IC|p!0z%w9*}_y z(UNTiD*=}*)z+{UaM=pkVH|er$xP%%(?eg}uR}k2+%SlBYLe?RY3YLdRCI@XYXVnU zjPeW~5kVLXgaslJsU~2VC^f(;(QwFs4#Hut3=~xF4PGJQ-3uk}MM&K#%-WxA5^9@{ zV>arSRjcAS#Gx7&;tru^#WHURod`6}zPpIdutcXh@Dl^z24|5$2la9r{^p^dJ@Tb= zFRlBjRbNW Date: Mon, 29 Apr 2024 21:59:07 -0300 Subject: [PATCH 12/42] Criando Dockerfile e configurando e rodando imagem docker --- Dockerfile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ poetry.lock | 71 ++++++++++++++++++++++------------------------------- 2 files changed, 97 insertions(+), 42 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe104c6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,68 @@ +# `python-base` sets up all our shared environment variables +FROM python:3.12.0-slim as python-base +# FROM python:3.8.1-slim as python-base + + # python +ENV PYTHONUNBUFFERED=1 \ + # prevents python creating .pyc files + PYTHONDONTWRITEBYTECODE=1 \ + \ + # pip + PIP_NO_CACHE_DIR=off \ + PIP_DISABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 \ + \ + # poetry + # https://python-poetry.org/docs/configuration/#using-environment-variables + POETRY_VERSION=1.8.2 \ + # make poetry install to this location + POETRY_HOME="/opt/poetry" \ + # make poetry create the virtual environment in the project's root + # it gets named `.venv` + POETRY_VIRTUALENVS_IN_PROJECT=true \ + # do not ask any interactive question + POETRY_NO_INTERACTION=1 \ + \ + # paths + # this is where our requirements + virtual environment will live + PYSETUP_PATH="/opt/pysetup" \ + VENV_PATH="/opt/pysetup/.venv" + + +# prepend poetry and venv to path +ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" + +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + # deps for installing poetry + curl \ + # deps for building python deps + build-essential + +# install poetry - respects $POETRY_VERSION & $POETRY_HOME +# RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python +# RUN pip install poetry poetry init +RUN curl -sSL https://install.python-poetry.org | python3 - + +# install postgres dependencies inside of Docker +RUN apt-get update \ + && apt-get -y install libpq-dev gcc \ + && pip install psycopg2 + +# copy project requirement files here to ensure they will be cached. +WORKDIR $PYSETUP_PATH +COPY poetry.lock pyproject.toml ./ + +# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally +RUN poetry install --no-dev + +# quicker install as runtime deps are already installed +RUN poetry install + +WORKDIR /app + +COPY . /app/ + +EXPOSE 8000 + +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/poetry.lock b/poetry.lock index ee33744..a28de75 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,13 +2,13 @@ [[package]] name = "asgiref" -version = "3.7.2" +version = "3.8.1" description = "ASGI specs, helper code, and adapters" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "asgiref-3.7.2-py3-none-any.whl", hash = "sha256:89b2ef2247e3b562a16eef663bc0e2e703ec6468e2fa8a5cd61cd449786d4f6e"}, - {file = "asgiref-3.7.2.tar.gz", hash = "sha256:9e0ce3aa93a819ba5b45120216b23878cf6e8525eb3848653452b4192b92afed"}, + {file = "asgiref-3.8.1-py3-none-any.whl", hash = "sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47"}, + {file = "asgiref-3.8.1.tar.gz", hash = "sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590"}, ] [package.extras] @@ -27,13 +27,13 @@ files = [ [[package]] name = "django" -version = "5.0.3" +version = "5.0.4" description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." optional = false python-versions = ">=3.10" files = [ - {file = "Django-5.0.3-py3-none-any.whl", hash = "sha256:5c7d748ad113a81b2d44750ccc41edc14e933f56581683db548c9257e078cc83"}, - {file = "Django-5.0.3.tar.gz", hash = "sha256:5fb37580dcf4a262f9258c1f4373819aacca906431f505e4688e37f3a99195df"}, + {file = "Django-5.0.4-py3-none-any.whl", hash = "sha256:916423499d75d62da7aa038d19aef23d23498d8df229775eb0a6309ee1013775"}, + {file = "Django-5.0.4.tar.gz", hash = "sha256:4bd01a8c830bb77a8a3b0e7d8b25b887e536ad17a81ba2dce5476135c73312bd"}, ] [package.dependencies] @@ -89,18 +89,17 @@ djangorestframework = "*" [[package]] name = "djangorestframework" -version = "3.14.0" +version = "3.15.1" description = "Web APIs for Django, made easy." optional = false python-versions = ">=3.6" files = [ - {file = "djangorestframework-3.14.0-py3-none-any.whl", hash = "sha256:eb63f58c9f218e1a7d064d17a70751f528ed4e1d35547fdade9aaf4cd103fd08"}, - {file = "djangorestframework-3.14.0.tar.gz", hash = "sha256:579a333e6256b09489cbe0a067e66abe55c6595d8926be6b99423786334350c8"}, + {file = "djangorestframework-3.15.1-py3-none-any.whl", hash = "sha256:3ccc0475bce968608cf30d07fb17d8e52d1d7fc8bfe779c905463200750cbca6"}, + {file = "djangorestframework-3.15.1.tar.gz", hash = "sha256:f88fad74183dfc7144b2756d0d2ac716ea5b4c7c9840995ac3bfd8ec034333c1"}, ] [package.dependencies] django = ">=3.0" -pytz = "*" [[package]] name = "factory-boy" @@ -122,13 +121,13 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"] [[package]] name = "faker" -version = "24.0.0" +version = "25.0.0" description = "Faker is a Python package that generates fake data for you." optional = false python-versions = ">=3.8" files = [ - {file = "Faker-24.0.0-py3-none-any.whl", hash = "sha256:2456d674f40bd51eb3acbf85221277027822e529a90cc826453d9a25dff932b1"}, - {file = "Faker-24.0.0.tar.gz", hash = "sha256:ea6f784c40730de0f77067e49e78cdd590efb00bec3d33f577492262206c17fc"}, + {file = "Faker-25.0.0-py3-none-any.whl", hash = "sha256:e23a2b74888885c3d23a9237bacb823041291c03d609a39acb9ebe6c123f3986"}, + {file = "Faker-25.0.0.tar.gz", hash = "sha256:87ef41e24b39a5be66ecd874af86f77eebd26782a2681200e86c5326340a95d3"}, ] [package.dependencies] @@ -147,24 +146,24 @@ files = [ [[package]] name = "packaging" -version = "23.2" +version = "24.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.7" files = [ - {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, - {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, + {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, + {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, ] [[package]] name = "pluggy" -version = "1.4.0" +version = "1.5.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" files = [ - {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, - {file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"}, + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, ] [package.extras] @@ -173,23 +172,23 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pytest" -version = "8.0.2" +version = "8.2.0" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.0.2-py3-none-any.whl", hash = "sha256:edfaaef32ce5172d5466b5127b42e0d6d35ebbe4453f0e3505d96afd93f6b096"}, - {file = "pytest-8.0.2.tar.gz", hash = "sha256:d4051d623a2e0b7e51960ba963193b09ce6daeb9759a451844a21e4ddedfc1bd"}, + {file = "pytest-8.2.0-py3-none-any.whl", hash = "sha256:1733f0620f6cda4095bbf0d9ff8022486e91892245bb9e7d5542c018f612f233"}, + {file = "pytest-8.2.0.tar.gz", hash = "sha256:d507d4482197eac0ba2bae2e9babf0672eb333017bcedaa5fb1a3d42c1174b3f"}, ] [package.dependencies] colorama = {version = "*", markers = "sys_platform == \"win32\""} iniconfig = "*" packaging = "*" -pluggy = ">=1.3.0,<2.0" +pluggy = ">=1.5,<2.0" [package.extras] -testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "python-dateutil" @@ -205,17 +204,6 @@ files = [ [package.dependencies] six = ">=1.5" -[[package]] -name = "pytz" -version = "2024.1" -description = "World timezone definitions, modern and historical" -optional = false -python-versions = "*" -files = [ - {file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"}, - {file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"}, -] - [[package]] name = "six" version = "1.16.0" @@ -229,19 +217,18 @@ files = [ [[package]] name = "sqlparse" -version = "0.4.4" +version = "0.5.0" description = "A non-validating SQL parser." optional = false -python-versions = ">=3.5" +python-versions = ">=3.8" files = [ - {file = "sqlparse-0.4.4-py3-none-any.whl", hash = "sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3"}, - {file = "sqlparse-0.4.4.tar.gz", hash = "sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c"}, + {file = "sqlparse-0.5.0-py3-none-any.whl", hash = "sha256:c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663"}, + {file = "sqlparse-0.5.0.tar.gz", hash = "sha256:714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93"}, ] [package.extras] -dev = ["build", "flake8"] +dev = ["build", "hatch"] doc = ["sphinx"] -test = ["pytest", "pytest-cov"] [[package]] name = "tzdata" From 5f6ae81a24374a81a04ef70bf58c65c179ec1a85 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Mon, 6 May 2024 22:02:05 -0300 Subject: [PATCH 13/42] Configurando credenciais e tipo de banco de dados no settings.py --- bookstore/settings.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/bookstore/settings.py b/bookstore/settings.py index 6fb478e..ac1c159 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -10,6 +10,7 @@ https://docs.djangoproject.com/en/5.0/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -82,8 +83,12 @@ DATABASES = { "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", + "ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"), + "NAME": os.environ.get("SQL_DATABASE", BASE_DIR / "db.sqlite3"), + "USER": os.environ.get("SQL_USER", "user"), + "PASSWORD": os.environ.get("SQL_PASSWORD", "password"), + "HOST": os.environ.get("SQL_HOST", "localhost"), + "PORT": os.environ.get("SQL_PORT", "5432"), } } @@ -141,4 +146,13 @@ INTERNAL_IPS = [ '127.0.0.1', -] \ No newline at end of file +] + +SECRET_KEY = os.environ.get("SECRET_KEY") + +DEBUG = int(os.environ.get("DEBUG", default=0)) + +# 'DJANGO_ALLOWED_HOSTS' should be a single string os hosts with a space between each. +# For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]' + +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") \ No newline at end of file From 205fdacd374a98e02d0408f8a1f39c78d6eb0686 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Tue, 7 May 2024 08:30:27 -0300 Subject: [PATCH 14/42] Adicionando as dependencias essenciais para o Postgres no Dockerfile do projeto --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fe104c6..202919c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,8 @@ RUN apt-get update \ # install poetry - respects $POETRY_VERSION & $POETRY_HOME # RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python # RUN pip install poetry poetry init -RUN curl -sSL https://install.python-poetry.org | python3 - +# RUN curl -sSL https://install.python-poetry.org | python3 - +RUN curl -sSL https://raw.githubusercontent.com.sdispater/poetry/get-poetry.py | python # install postgres dependencies inside of Docker RUN apt-get update \ From 9a7bad710c887ae6880d0e6561bd4abc694aaca6 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Tue, 7 May 2024 08:42:50 -0300 Subject: [PATCH 15/42] =?UTF-8?q?Cria=C3=A7=C3=A3o=20e=20configura=C3=A7?= =?UTF-8?q?=C3=A3o=20do=20docker-compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..678408c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3.9' + +services: + web: + build: . + command: python manage.py runserver 0.0.0.0:8000 + volumes: + - . :/usr/src/app + ports: + - 8000:8000 + depends_on: + - db + db: + image: postgres:13.0-alpine + volumes: + - postgres_data:/var/lib/postgresql/data + environment: + - POSTGRES_USER-dev + - POSTGRES_PASSWORD=dev + - POSTGRES_DB=bookstore_db \ No newline at end of file From 309a1c833023a567a36d2534e76dc335df1f04cf Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Tue, 7 May 2024 08:52:37 -0300 Subject: [PATCH 16/42] Criando env.dev para sincronizar com docker-compose --- docker-compose.yml | 6 ++++-- env.dev | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 env.dev diff --git a/docker-compose.yml b/docker-compose.yml index 678408c..d8ac50d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.9' services: - web: + backend: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: @@ -17,4 +17,6 @@ services: environment: - POSTGRES_USER-dev - POSTGRES_PASSWORD=dev - - POSTGRES_DB=bookstore_db \ No newline at end of file + - POSTGRES_DB=bookstore_db +volumes: + postgres_data: \ No newline at end of file diff --git a/env.dev b/env.dev new file mode 100644 index 0000000..fca16a0 --- /dev/null +++ b/env.dev @@ -0,0 +1,9 @@ +DEBUG=1 +SECRET_KEY=foo +DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] +SQL_ENGINE=django.db.backends.postgresql +SQL_DATABASE=bookstore_db +SQL_USER=dev +SQL_PASSWORD=dev +SQL_HOST=db +SQL_PORT=5432 \ No newline at end of file From f231361296a6ed6956c481f20761cc559f9cb166 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Wed, 8 May 2024 19:57:02 -0300 Subject: [PATCH 17/42] =?UTF-8?q?Corrigindo=20importa=C3=A7=C3=A3o=20do=20?= =?UTF-8?q?Poetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 202919c..c1403ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,6 +45,9 @@ RUN apt-get update \ # RUN curl -sSL https://install.python-poetry.org | python3 - RUN curl -sSL https://raw.githubusercontent.com.sdispater/poetry/get-poetry.py | python +RUN curl -sSL https://install.python-poetry.org | python3 - + + # install postgres dependencies inside of Docker RUN apt-get update \ && apt-get -y install libpq-dev gcc \ From 302d09ef4efd04b42757dbb482fca1742b6473d6 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Wed, 8 May 2024 19:57:46 -0300 Subject: [PATCH 18/42] =?UTF-8?q?Atualizando=20depend=C3=AAncias=20no=20re?= =?UTF-8?q?quirements.txt=20e=20adicionando=20README.me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.me | 18 ++++++++++++++++++ requirements.txt | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 README.me diff --git a/README.me b/README.me new file mode 100644 index 0000000..e733b6b --- /dev/null +++ b/README.me @@ -0,0 +1,18 @@ +# Scripts do Projeto: + +Git clone ... + +## Criando Ambiente Virtual: +python -m venv env +env/scripts/activate + + + +## Instalação das dependências do Projeto: +pip install -r requirements.txt + +## Build Docker: +* Abrir o Docker e digitar no terminal +docker run +docker-compose up --build + diff --git a/requirements.txt b/requirements.txt index 8755b31..e8b7cda 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,46 @@ asgiref==3.7.2 +build==1.2.1 +CacheControl==0.14.0 +certifi==2024.2.2 +charset-normalizer==3.3.2 +cleo==2.1.0 colorama==0.4.6 +crashtest==0.4.1 +distlib==0.3.8 Django==5.0.3 +dulwich==0.21.7 factory-boy==3.3.0 Faker==24.0.0 +fastjsonschema==2.19.1 +filelock==3.14.0 +idna==3.7 iniconfig==2.0.0 +installer==0.7.0 +jaraco.classes==3.4.0 +keyring==24.3.1 +more-itertools==10.2.0 +msgpack==1.0.8 packaging==23.2 +pexpect==4.9.0 +pkginfo==1.10.0 +platformdirs==4.2.1 pluggy==1.4.0 +poetry==1.8.3 +poetry-core==1.9.0 +poetry-plugin-export==1.7.1 +ptyprocess==0.7.0 +pyproject_hooks==1.1.0 pytest==8.0.2 python-dateutil==2.9.0.post0 +pywin32-ctypes==0.2.2 +rapidfuzz==3.9.0 +requests==2.31.0 +requests-toolbelt==1.0.0 +shellingham==1.5.4 six==1.16.0 sqlparse==0.4.4 +tomlkit==0.12.5 +trove-classifiers==2024.4.10 tzdata==2024.1 +urllib3==2.2.1 +virtualenv==20.26.1 From 68026999a45b36fd0c60050893a86d29dada245e Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Wed, 8 May 2024 20:00:23 -0300 Subject: [PATCH 19/42] Corrigindo caminho do volumes em docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d8ac50d..e4c8e92 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - - . :/usr/src/app + - .:/usr/src/app ports: - 8000:8000 depends_on: From c03e56a5c2131c5fcf7ea9d220130a471c914ba5 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Wed, 8 May 2024 21:14:34 -0300 Subject: [PATCH 20/42] =?UTF-8?q?Corrignido=20credenciais=20de=20conex?= =?UTF-8?q?=C3=A3o=20com=20o=20banco=20de=20dados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e4c8e92..b9aeba8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,8 @@ services: - .:/usr/src/app ports: - 8000:8000 + env_file: + - ./env.dev depends_on: - db db: @@ -15,7 +17,7 @@ services: volumes: - postgres_data:/var/lib/postgresql/data environment: - - POSTGRES_USER-dev + - POSTGRES_USER=dev - POSTGRES_PASSWORD=dev - POSTGRES_DB=bookstore_db volumes: From 1674b7e6d345057dcc607964fa9568e224ed2d23 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Wed, 8 May 2024 21:16:08 -0300 Subject: [PATCH 21/42] Removendo env dos ingorados paragarantir o salvamento de env.dev --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ae2e4d0..3b59196 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -env + .env /env \ No newline at end of file From 63cb6c8fc9a25212d4ceb138386f56e5a01da9e4 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Wed, 8 May 2024 21:17:16 -0300 Subject: [PATCH 22/42] =?UTF-8?q?Ajustando=20a=20instala=C3=A7=C3=A3o=20de?= =?UTF-8?q?=20psycopg2=20para=20corrigir=20os=20erros=20ao=20rodar=20o=20d?= =?UTF-8?q?ocker-compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bookstore/settings.py | 2 +- poetry.lock | 97 +++++++++++++++++++++++++++++++++++++++---- pyproject.toml | 1 + 3 files changed, 91 insertions(+), 9 deletions(-) diff --git a/bookstore/settings.py b/bookstore/settings.py index ac1c159..53f8cab 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -145,7 +145,7 @@ } INTERNAL_IPS = [ - '127.0.0.1', + "127.0.0.1", ] SECRET_KEY = os.environ.get("SECRET_KEY") diff --git a/poetry.lock b/poetry.lock index a28de75..3b62c35 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "asgiref" @@ -27,13 +27,13 @@ files = [ [[package]] name = "django" -version = "5.0.4" +version = "5.0.6" description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." optional = false python-versions = ">=3.10" files = [ - {file = "Django-5.0.4-py3-none-any.whl", hash = "sha256:916423499d75d62da7aa038d19aef23d23498d8df229775eb0a6309ee1013775"}, - {file = "Django-5.0.4.tar.gz", hash = "sha256:4bd01a8c830bb77a8a3b0e7d8b25b887e536ad17a81ba2dce5476135c73312bd"}, + {file = "Django-5.0.6-py3-none-any.whl", hash = "sha256:8363ac062bb4ef7c3f12d078f6fa5d154031d129a15170a1066412af49d30905"}, + {file = "Django-5.0.6.tar.gz", hash = "sha256:ff1b61005004e476e0aeea47c7f79b85864c70124030e95146315396f1e7951f"}, ] [package.dependencies] @@ -121,13 +121,13 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"] [[package]] name = "faker" -version = "25.0.0" +version = "25.1.0" description = "Faker is a Python package that generates fake data for you." optional = false python-versions = ">=3.8" files = [ - {file = "Faker-25.0.0-py3-none-any.whl", hash = "sha256:e23a2b74888885c3d23a9237bacb823041291c03d609a39acb9ebe6c123f3986"}, - {file = "Faker-25.0.0.tar.gz", hash = "sha256:87ef41e24b39a5be66ecd874af86f77eebd26782a2681200e86c5326340a95d3"}, + {file = "Faker-25.1.0-py3-none-any.whl", hash = "sha256:24e28dce0b89683bb9e017e042b971c8c4909cff551b6d46f1e207674c7c2526"}, + {file = "Faker-25.1.0.tar.gz", hash = "sha256:2107618cf306bb188dcfea3e5cfd94aa92d65c7293a2437c1e96a99c83274755"}, ] [package.dependencies] @@ -170,6 +170,87 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "psycopg2-binary" +version = "2.9.9" +description = "psycopg2 - Python-PostgreSQL Database Adapter" +optional = false +python-versions = ">=3.7" +files = [ + {file = "psycopg2-binary-2.9.9.tar.gz", hash = "sha256:7f01846810177d829c7692f1f5ada8096762d9172af1b1a28d4ab5b77c923c1c"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c2470da5418b76232f02a2fcd2229537bb2d5a7096674ce61859c3229f2eb202"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c6af2a6d4b7ee9615cbb162b0738f6e1fd1f5c3eda7e5da17861eacf4c717ea7"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:75723c3c0fbbf34350b46a3199eb50638ab22a0228f93fb472ef4d9becc2382b"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:83791a65b51ad6ee6cf0845634859d69a038ea9b03d7b26e703f94c7e93dbcf9"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0ef4854e82c09e84cc63084a9e4ccd6d9b154f1dbdd283efb92ecd0b5e2b8c84"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed1184ab8f113e8d660ce49a56390ca181f2981066acc27cf637d5c1e10ce46e"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d2997c458c690ec2bc6b0b7ecbafd02b029b7b4283078d3b32a852a7ce3ddd98"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:b58b4710c7f4161b5e9dcbe73bb7c62d65670a87df7bcce9e1faaad43e715245"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:0c009475ee389757e6e34611d75f6e4f05f0cf5ebb76c6037508318e1a1e0d7e"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8dbf6d1bc73f1d04ec1734bae3b4fb0ee3cb2a493d35ede9badbeb901fb40f6f"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-win32.whl", hash = "sha256:3f78fd71c4f43a13d342be74ebbc0666fe1f555b8837eb113cb7416856c79682"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-win_amd64.whl", hash = "sha256:876801744b0dee379e4e3c38b76fc89f88834bb15bf92ee07d94acd06ec890a0"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ee825e70b1a209475622f7f7b776785bd68f34af6e7a46e2e42f27b659b5bc26"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1ea665f8ce695bcc37a90ee52de7a7980be5161375d42a0b6c6abedbf0d81f0f"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:143072318f793f53819048fdfe30c321890af0c3ec7cb1dfc9cc87aa88241de2"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c332c8d69fb64979ebf76613c66b985414927a40f8defa16cf1bc028b7b0a7b0"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f7fc5a5acafb7d6ccca13bfa8c90f8c51f13d8fb87d95656d3950f0158d3ce53"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:977646e05232579d2e7b9c59e21dbe5261f403a88417f6a6512e70d3f8a046be"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:b6356793b84728d9d50ead16ab43c187673831e9d4019013f1402c41b1db9b27"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bc7bb56d04601d443f24094e9e31ae6deec9ccb23581f75343feebaf30423359"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:77853062a2c45be16fd6b8d6de2a99278ee1d985a7bd8b103e97e41c034006d2"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:78151aa3ec21dccd5cdef6c74c3e73386dcdfaf19bced944169697d7ac7482fc"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-win32.whl", hash = "sha256:dc4926288b2a3e9fd7b50dc6a1909a13bbdadfc67d93f3374d984e56f885579d"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:b76bedd166805480ab069612119ea636f5ab8f8771e640ae103e05a4aae3e417"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:8532fd6e6e2dc57bcb3bc90b079c60de896d2128c5d9d6f24a63875a95a088cf"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b0605eaed3eb239e87df0d5e3c6489daae3f7388d455d0c0b4df899519c6a38d"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f8544b092a29a6ddd72f3556a9fcf249ec412e10ad28be6a0c0d948924f2212"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2d423c8d8a3c82d08fe8af900ad5b613ce3632a1249fd6a223941d0735fce493"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2e5afae772c00980525f6d6ecf7cbca55676296b580c0e6abb407f15f3706996"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e6f98446430fdf41bd36d4faa6cb409f5140c1c2cf58ce0bbdaf16af7d3f119"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c77e3d1862452565875eb31bdb45ac62502feabbd53429fdc39a1cc341d681ba"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:cb16c65dcb648d0a43a2521f2f0a2300f40639f6f8c1ecbc662141e4e3e1ee07"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:911dda9c487075abd54e644ccdf5e5c16773470a6a5d3826fda76699410066fb"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:57fede879f08d23c85140a360c6a77709113efd1c993923c59fde17aa27599fe"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-win32.whl", hash = "sha256:64cf30263844fa208851ebb13b0732ce674d8ec6a0c86a4e160495d299ba3c93"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:81ff62668af011f9a48787564ab7eded4e9fb17a4a6a74af5ffa6a457400d2ab"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2293b001e319ab0d869d660a704942c9e2cce19745262a8aba2115ef41a0a42a"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:03ef7df18daf2c4c07e2695e8cfd5ee7f748a1d54d802330985a78d2a5a6dca9"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a602ea5aff39bb9fac6308e9c9d82b9a35c2bf288e184a816002c9fae930b77"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8359bf4791968c5a78c56103702000105501adb557f3cf772b2c207284273984"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:275ff571376626195ab95a746e6a04c7df8ea34638b99fc11160de91f2fef503"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:f9b5571d33660d5009a8b3c25dc1db560206e2d2f89d3df1cb32d72c0d117d52"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:420f9bbf47a02616e8554e825208cb947969451978dceb77f95ad09c37791dae"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:4154ad09dac630a0f13f37b583eae260c6aa885d67dfbccb5b02c33f31a6d420"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:a148c5d507bb9b4f2030a2025c545fccb0e1ef317393eaba42e7eabd28eb6041"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-win32.whl", hash = "sha256:68fc1f1ba168724771e38bee37d940d2865cb0f562380a1fb1ffb428b75cb692"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-win_amd64.whl", hash = "sha256:281309265596e388ef483250db3640e5f414168c5a67e9c665cafce9492eda2f"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:60989127da422b74a04345096c10d416c2b41bd7bf2a380eb541059e4e999980"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:246b123cc54bb5361588acc54218c8c9fb73068bf227a4a531d8ed56fa3ca7d6"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:34eccd14566f8fe14b2b95bb13b11572f7c7d5c36da61caf414d23b91fcc5d94"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18d0ef97766055fec15b5de2c06dd8e7654705ce3e5e5eed3b6651a1d2a9a152"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d3f82c171b4ccd83bbaf35aa05e44e690113bd4f3b7b6cc54d2219b132f3ae55"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ead20f7913a9c1e894aebe47cccf9dc834e1618b7aa96155d2091a626e59c972"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ca49a8119c6cbd77375ae303b0cfd8c11f011abbbd64601167ecca18a87e7cdd"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:323ba25b92454adb36fa425dc5cf6f8f19f78948cbad2e7bc6cdf7b0d7982e59"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:1236ed0952fbd919c100bc839eaa4a39ebc397ed1c08a97fc45fee2a595aa1b3"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:729177eaf0aefca0994ce4cffe96ad3c75e377c7b6f4efa59ebf003b6d398716"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-win32.whl", hash = "sha256:804d99b24ad523a1fe18cc707bf741670332f7c7412e9d49cb5eab67e886b9b5"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-win_amd64.whl", hash = "sha256:a6cdcc3ede532f4a4b96000b6362099591ab4a3e913d70bcbac2b56c872446f7"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:72dffbd8b4194858d0941062a9766f8297e8868e1dd07a7b36212aaa90f49472"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:30dcc86377618a4c8f3b72418df92e77be4254d8f89f14b8e8f57d6d43603c0f"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:31a34c508c003a4347d389a9e6fcc2307cc2150eb516462a7a17512130de109e"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:15208be1c50b99203fe88d15695f22a5bed95ab3f84354c494bcb1d08557df67"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1873aade94b74715be2246321c8650cabf5a0d098a95bab81145ffffa4c13876"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a58c98a7e9c021f357348867f537017057c2ed7f77337fd914d0bedb35dace7"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4686818798f9194d03c9129a4d9a702d9e113a89cb03bffe08c6cf799e053291"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:ebdc36bea43063116f0486869652cb2ed7032dbc59fbcb4445c4862b5c1ecf7f"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:ca08decd2697fdea0aea364b370b1249d47336aec935f87b8bbfd7da5b2ee9c1"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ac05fb791acf5e1a3e39402641827780fe44d27e72567a000412c648a85ba860"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-win32.whl", hash = "sha256:9dba73be7305b399924709b91682299794887cbbd88e38226ed9f6712eabee90"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-win_amd64.whl", hash = "sha256:f7ae5d65ccfbebdfa761585228eb4d0df3a8b15cfb53bd953e713e09fbb12957"}, +] + [[package]] name = "pytest" version = "8.2.0" @@ -244,4 +325,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "aed3988f00805233a5c40b7b8d9fd11b35ba2c4cfa51384d36ca1f3b7470bb07" +content-hash = "09c58830797380621c281940d37daf67cdfb5ff47d5c6fa3a1b90898d74665a0" diff --git a/pyproject.toml b/pyproject.toml index e38dd29..ff297a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,7 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.12" pytest = "^8.0.2" +psycopg2-binary = "*" factory-boy = "^3.3.0" django = "^5.0.3" django-rest-framework = "^0.1.0" From c3898da4539917be09e70d8c8496ec1cd78cc2f5 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Thu, 9 May 2024 18:17:04 -0300 Subject: [PATCH 23/42] =?UTF-8?q?Atualizando=20depens=C3=AAncias=20do=20re?= =?UTF-8?q?quirements.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index e8b7cda..8f52593 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,6 +28,7 @@ pluggy==1.4.0 poetry==1.8.3 poetry-core==1.9.0 poetry-plugin-export==1.7.1 +psycopg2==2.9.9 ptyprocess==0.7.0 pyproject_hooks==1.1.0 pytest==8.0.2 From af121382fe6492e917e17c3b7b8e26ef83b41405 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Thu, 9 May 2024 19:04:25 -0300 Subject: [PATCH 24/42] Configurando arquivo Makefile --- Makefile | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b5ae0cd --- /dev/null +++ b/Makefile @@ -0,0 +1,122 @@ +# Set this to ~use it everywhere in the project setup +PYTHON_VERSION ?= 3.8.10 +# the directories containing the library modules this repo builds +LIBRARY_DIRS = mylibrary +# build artifacts organized in this Makefile +BUILD_DIR ?= build + +# PyTest options +PYTEST_HTML_OPTIONS = --html=$(BUILD_DIR)/report.html --self-contained-html +PYTEST_TAP_OPTIONS = --tap-combined --tap-outdir $(BUILD_DIR) +PYTEST_COVERAGE_OPTIONS = --cov=$(LIBRARY_DIRS) +PYTEST_OPTIONS ?= $(PYTEST_HTML_OPTIONS) $(PYTEST_TAP_OPTIONS) $(PYTEST_COVERAGE_OPTIONS) + +# MyPy typechecking options +MYPY_OPTS ?= --python-version $(basename $(PYTHON_VERSION)) --show-column-numbers --pretty --html-report $(BUILD_DIR)/mypy +# Python installation artifacts +PYTHON_VERSION_FILE=.python-version +ifeq ($(shell which pyenv),) +# pyenv isn't installed, guess the eventual path FWIW +PYENV_VERSION_DIR ?= $(HOME)/.pyenv/versions/$(PYTHON_VERSION) +else +# pyenv is installed +PYENV_VERSION_DIR ?= $(shell pyenv root)/versions/$(PYTHON_VERSION) +endif +PIP ?= pip3 + +POETRY_OPTS ?= +POETRY ?= poetry $(POETRY_OPTS) +RUN_PYPKG_BIN = $(POETRY) run + +COLOR_ORANGE = \033[33m +COLOR_RESET = \033[0m + +##@ Utility + +.PHONY: help +help: ## Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +.PHONY: version-python +version-python: ## Echos the version of Python in use + @echo $(PYTHON_VERSION) + +##@ Testing + +.PHONY: test +test: ## Runs tests + $(RUN_PYPKG_BIN) pytest \ + $(PYTEST_OPTIONS) \ + tests/*.py + +##@ Building and Publishing + +.PHONY: build +build: ## Runs a build + $(POETRY) build + +.PHONY: publish +publish: ## Publish a build to the configured repo + $(POETRY) publish $(POETRY_PUBLISH_OPTIONS_SET_BY_CI_ENV) + +.PHONY: deps-py-update +deps-py-update: pyproject.toml ## Update Poetry deps, e.g. after adding a new one manually + $(POETRY) update + +##@ Setup +# dynamic-ish detection of Python installation directory with pyenv +$(PYENV_VERSION_DIR): + pyenv install --skip-existing $(PYTHON_VERSION) +$(PYTHON_VERSION_FILE): $(PYENV_VERSION_DIR) + pyenv local $(PYTHON_VERSION) + +.PHONY: deps +deps: deps-brew deps-py ## Installs all dependencies + +.PHONY: deps-brew +deps-brew: Brewfile ## Installs development dependencies from Homebrew + brew bundle --file=Brewfile + @echo "$(COLOR_ORANGE)Ensure that pyenv is setup in your shell.$(COLOR_RESET)" + @echo "$(COLOR_ORANGE)It should have something like 'eval \$$(pyenv init -)'$(COLOR_RESET)" + +.PHONY: deps-py +deps-py: $(PYTHON_VERSION_FILE) ## Installs Python development and runtime dependencies + $(PIP) install --upgrade \ + --index-url $(PYPI_PROXY) \ + pip + $(PIP) install --upgrade \ + --index-url $(PYPI_PROXY) \ + poetry + $(POETRY) install + +##@ Code Quality + +.PHONY: check +check: check-py ## Runs linters and other important tools + +.PHONY: check-py +check-py: check-py-flake8 check-py-black check-py-mypy ## Checks only Python files + +.PHONY: check-py-flake8 +check-py-flake8: ## Runs flake8 linter + $(RUN_PYPKG_BIN) flake8 . + +.PHONY: check-py-black +check-py-black: ## Runs black in check mode (no changes) + $(RUN_PYPKG_BIN) black --check --line-length 118 --fast . + +.PHONY: check-py-mypy +check-py-mypy: ## Runs mypy + $(RUN_PYPKG_BIN) mypy $(MYPY_OPTS) $(LIBRARY_DIRS) + +.PHONY: format-py +format-py: ## Runs black, makes changes where necessary + $(RUN_PYPKG_BIN) black . + +.PHONY: format-autopep8 +format-autopep8: + $(RUN_PYPKG_BIN) autopep8 --in-place --recursive . + +.PHONY: format-isort +format-isort: + $(RUN_PYPKG_BIN) isort --recursive . \ No newline at end of file From 9de85b066d4547085ae0a0efe8d02d5caf0d8d3a Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sat, 11 May 2024 15:40:43 -0300 Subject: [PATCH 25/42] Alterando nome no docker-compose para web --- Makefile | 4 +- bookstore/settings.py | 16 +++--- bookstore/urls.py | 8 +-- docker-compose.yml | 11 +++- order/admin.py | 2 +- order/factories.py | 15 ++--- order/models/__init__.py | 2 +- order/models/order.py | 3 +- order/serializers/__init__.py | 2 +- order/serializers/order_serializer.py | 25 +++++---- .../tests/test_viewsets/test_order_viewset.py | 56 +++++++++++-------- order/urls.py | 7 +-- order/viewsets/__init__.py | 1 - order/viewsets/order_viewset.py | 3 +- poetry.lock | 51 ++++++++++++++++- product/admin.py | 2 +- product/factories.py | 21 ++++--- product/models/__init__.py | 2 +- product/models/category.py | 5 +- product/models/product.py | 4 +- product/serializers/__init__.py | 2 +- product/serializers/category_serializer.py | 11 ++-- product/serializers/product_serializer.py | 31 +++++----- .../tests_viewsets/test_product_viewset.py | 49 ++++++++-------- product/urls.py | 7 +-- product/viewsets/__init__.py | 3 +- product/viewsets/category_viewset.py | 6 +- product/viewsets/product_viewset.py | 20 +++++-- pyproject.toml | 1 + 29 files changed, 229 insertions(+), 141 deletions(-) diff --git a/Makefile b/Makefile index b5ae0cd..8f40f40 100644 --- a/Makefile +++ b/Makefile @@ -85,8 +85,8 @@ deps-py: $(PYTHON_VERSION_FILE) ## Installs Python development and runtime depen --index-url $(PYPI_PROXY) \ pip $(PIP) install --upgrade \ - --index-url $(PYPI_PROXY) \ - poetry + --index-url $(PYPI_PROXY) \ + poetry $(POETRY) install ##@ Code Quality diff --git a/bookstore/settings.py b/bookstore/settings.py index 53f8cab..1cec9c8 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -88,7 +88,7 @@ "USER": os.environ.get("SQL_USER", "user"), "PASSWORD": os.environ.get("SQL_PASSWORD", "password"), "HOST": os.environ.get("SQL_HOST", "localhost"), - "PORT": os.environ.get("SQL_PORT", "5432"), + "PORT": os.environ.get("SQL_PORT", "5432"), } } @@ -135,12 +135,12 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" REST_FRAMEWORK = { - 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', - 'PAGE_SIZE': 5, - 'DEFAULT_AUTHENTICATION_CLASSES': [ - 'rest_framework.authentication.BasicAuthentication', - 'rest_framework.authentication.SessionAuthentication', - 'rest_framework.authentication.TokenAuthentication', + "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination", + "PAGE_SIZE": 5, + "DEFAULT_AUTHENTICATION_CLASSES": [ + "rest_framework.authentication.BasicAuthentication", + "rest_framework.authentication.SessionAuthentication", + "rest_framework.authentication.TokenAuthentication", ], } @@ -155,4 +155,4 @@ # 'DJANGO_ALLOWED_HOSTS' should be a single string os hosts with a space between each. # For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]' -ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") \ No newline at end of file +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") diff --git a/bookstore/urls.py b/bookstore/urls.py index f26ba4a..3be4bfd 100644 --- a/bookstore/urls.py +++ b/bookstore/urls.py @@ -21,9 +21,9 @@ from rest_framework.authtoken.views import obtain_auth_token urlpatterns = [ - path('__debug__', include(debug_toolbar.urls)), + path("__debug__", include(debug_toolbar.urls)), path("admin/", admin.site.urls), - re_path('bookstore/(?P(v1|v2))/', include('order.urls')), - re_path('bookstore/(?P(v1|v2))/', include('product.urls')), - path('api-token-auth/', obtain_auth_token, name='api_token_auth'), + re_path("bookstore/(?P(v1|v2))/", include("order.urls")), + re_path("bookstore/(?P(v1|v2))/", include("product.urls")), + path("api-token-auth/", obtain_auth_token, name="api_token_auth"), ] diff --git a/docker-compose.yml b/docker-compose.yml index b9aeba8..66640b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.9' services: - backend: + web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: @@ -10,6 +10,8 @@ services: - 8000:8000 env_file: - ./env.dev + networks: + - backend depends_on: - db db: @@ -20,5 +22,12 @@ services: - POSTGRES_USER=dev - POSTGRES_PASSWORD=dev - POSTGRES_DB=bookstore_db + networks: + - backend + +networks: + backend: + driver: bridge + volumes: postgres_data: \ No newline at end of file diff --git a/order/admin.py b/order/admin.py index 777e5da..6a9d37e 100644 --- a/order/admin.py +++ b/order/admin.py @@ -1,4 +1,4 @@ from django.contrib import admin # Register your models here. -from .models import Order \ No newline at end of file +from .models import Order diff --git a/order/factories.py b/order/factories.py index 0fb792e..d8e4d92 100644 --- a/order/factories.py +++ b/order/factories.py @@ -5,16 +5,18 @@ from order.models import Order + class UserFactory(factory.django.DjangoModelFactory): - email = factory.Faker('email') - username = factory.Faker('user_name') - + email = factory.Faker("email") + username = factory.Faker("user_name") + class Meta: model = User - + + class OrderFactory(factory.django.DjangoModelFactory): user = factory.SubFactory(UserFactory) - + @factory.post_generation def product(self, create, extracted, **kwargs): if not create: @@ -22,7 +24,6 @@ def product(self, create, extracted, **kwargs): if extracted: for product in extracted: self.product.add(product) - + class Meta: model = Order - \ No newline at end of file diff --git a/order/models/__init__.py b/order/models/__init__.py index 0065b08..a611692 100644 --- a/order/models/__init__.py +++ b/order/models/__init__.py @@ -1 +1 @@ -from .order import Order \ No newline at end of file +from .order import Order diff --git a/order/models/order.py b/order/models/order.py index 85f777e..f616ca0 100644 --- a/order/models/order.py +++ b/order/models/order.py @@ -2,6 +2,7 @@ from product.models.product import Product from django.contrib.auth.models import User + class Order(models.Model): product = models.ManyToManyField(Product, blank=False) - user = models.ForeignKey(User, on_delete=models.CASCADE) \ No newline at end of file + user = models.ForeignKey(User, on_delete=models.CASCADE) diff --git a/order/serializers/__init__.py b/order/serializers/__init__.py index 522d7a7..e7396e1 100644 --- a/order/serializers/__init__.py +++ b/order/serializers/__init__.py @@ -1 +1 @@ -from .order_serializer import OrderSerializer \ No newline at end of file +from .order_serializer import OrderSerializer diff --git a/order/serializers/order_serializer.py b/order/serializers/order_serializer.py index efa3366..9620b4f 100644 --- a/order/serializers/order_serializer.py +++ b/order/serializers/order_serializer.py @@ -4,26 +4,29 @@ from product.models import Product from product.serializers.product_serializer import ProductSerializer + class OrderSerializer(serializers.ModelSerializer): product = ProductSerializer(read_only=True, many=True) - products_id = serializers.PrimaryKeyRelatedField(queryset=Product.objects.all(), write_only=True, many=True) + products_id = serializers.PrimaryKeyRelatedField( + queryset=Product.objects.all(), write_only=True, many=True + ) total = serializers.SerializerMethodField() - + def get_total(self, instance): total = sum([product.price for product in instance.product.all()]) return total - + class Meta: model = Order - fields = ['product', 'total', 'user', 'products_id'] - extra_kwargs = {'product': {'required': False}} - + fields = ["product", "total", "user", "products_id"] + extra_kwargs = {"product": {"required": False}} + def create(self, validated_data): - product_data = validated_data.pop('products_id') - user_data = validated_data.pop('user') - + product_data = validated_data.pop("products_id") + user_data = validated_data.pop("user") + order = Order.objects.create(**validated_data) for product in product_data: order.product.add(product) - - return order \ No newline at end of file + + return order diff --git a/order/tests/test_viewsets/test_order_viewset.py b/order/tests/test_viewsets/test_order_viewset.py index 40c7c47..d8d3e2c 100644 --- a/order/tests/test_viewsets/test_order_viewset.py +++ b/order/tests/test_viewsets/test_order_viewset.py @@ -10,41 +10,53 @@ from product.models import Product from order.models import Order + class TestOrderViewSet(APITestCase): - + client = APIClient() - + def setUp(self): - self.category = CategoryFactory(title='technology') - self.product = ProductFactory(title='mouse', price=100, category=[self.category]) + self.category = CategoryFactory(title="technology") + self.product = ProductFactory( + title="mouse", price=100, category=[self.category] + ) self.order = OrderFactory(product=[self.product]) - + def test_order(self): - response = self.client.get( - reverse('order-list', kwargs={'version': 'v1'}) - ) - + response = self.client.get(reverse("order-list", kwargs={"version": "v1"})) + self.assertEqual(response.status_code, status.HTTP_200_OK) - + order_data = json.loads(response.content) - self.assertEqual(order_data['results'][0]['product'][0]['title'], self.product.title) - self.assertEqual(order_data['results'][0]['product'][0]['price'], self.product.price) - self.assertEqual(order_data['results'][0]['product'][0]['active'], self.product.active) - self.assertEqual(order_data['results'][0]['product'][0]['category'][0]['title'], self.category.title) - + self.assertEqual( + order_data["results"][0]["product"][0]["title"], self.product.title + ) + self.assertEqual( + order_data["results"][0]["product"][0]["price"], self.product.price + ) + self.assertEqual( + order_data["results"][0]["product"][0]["active"], self.product.active + ) + self.assertEqual( + order_data["results"][0]["product"][0]["category"][0]["title"], + self.category.title, + ) + def test_create_order(self): user = UserFactory() product = ProductFactory() - data = json.dumps({ - 'products_id': [product.id], - 'user_id': user.id, - }) + data = json.dumps( + { + "products_id": [product.id], + "user_id": user.id, + } + ) response = self.client.post( - reverse('order-list', kwargs={'version': 'v1'}), + reverse("order-list", kwargs={"version": "v1"}), data=data, - content_type='application/json', + content_type="application/json", ) - + self.assertEqual(response.status_code, status.HTTP_201_CREATED) created_order = Order.objects.get(user=user) diff --git a/order/urls.py b/order/urls.py index 044db6d..20a55d4 100644 --- a/order/urls.py +++ b/order/urls.py @@ -1,12 +1,11 @@ - from django.urls import path, include from rest_framework import routers from order import viewsets router = routers.SimpleRouter() -router.register(r'order', viewsets.OrderViewSet, basename='order') +router.register(r"order", viewsets.OrderViewSet, basename="order") urlpatterns = [ - path('', include(router.urls)), -] \ No newline at end of file + path("", include(router.urls)), +] diff --git a/order/viewsets/__init__.py b/order/viewsets/__init__.py index 9a8e2a2..0b4e286 100644 --- a/order/viewsets/__init__.py +++ b/order/viewsets/__init__.py @@ -1,2 +1 @@ from .order_viewset import OrderViewSet - diff --git a/order/viewsets/order_viewset.py b/order/viewsets/order_viewset.py index de8771c..5a92cd6 100644 --- a/order/viewsets/order_viewset.py +++ b/order/viewsets/order_viewset.py @@ -3,7 +3,8 @@ from order.models import Order from order.serializers import OrderSerializer + class OrderViewSet(ModelViewSet): serializer_class = OrderSerializer - queryset = Order.objects.all() \ No newline at end of file + queryset = Order.objects.all() diff --git a/poetry.lock b/poetry.lock index 3b62c35..df0ccec 100644 --- a/poetry.lock +++ b/poetry.lock @@ -133,6 +133,22 @@ files = [ [package.dependencies] python-dateutil = ">=2.4" +[[package]] +name = "flake8" +version = "7.0.0" +description = "the modular source code checker: pep8 pyflakes and co" +optional = false +python-versions = ">=3.8.1" +files = [ + {file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"}, + {file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"}, +] + +[package.dependencies] +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.11.0,<2.12.0" +pyflakes = ">=3.2.0,<3.3.0" + [[package]] name = "iniconfig" version = "2.0.0" @@ -144,6 +160,17 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + [[package]] name = "packaging" version = "24.0" @@ -251,6 +278,28 @@ files = [ {file = "psycopg2_binary-2.9.9-cp39-cp39-win_amd64.whl", hash = "sha256:f7ae5d65ccfbebdfa761585228eb4d0df3a8b15cfb53bd953e713e09fbb12957"}, ] +[[package]] +name = "pycodestyle" +version = "2.11.1" +description = "Python style guide checker" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, + {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, +] + +[[package]] +name = "pyflakes" +version = "3.2.0" +description = "passive checker of Python programs" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, +] + [[package]] name = "pytest" version = "8.2.0" @@ -325,4 +374,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "09c58830797380621c281940d37daf67cdfb5ff47d5c6fa3a1b90898d74665a0" +content-hash = "4e6e0fdefbb923f51712ef536efdc91fb2d5aa948e2d3aa4f41d79bdb27a4104" diff --git a/product/admin.py b/product/admin.py index ab5d3b4..398d249 100644 --- a/product/admin.py +++ b/product/admin.py @@ -1,4 +1,4 @@ from django.contrib import admin # Register your models here. -from .models import Product, Category \ No newline at end of file +from .models import Product, Category diff --git a/product/factories.py b/product/factories.py index e6f8d0f..031b956 100644 --- a/product/factories.py +++ b/product/factories.py @@ -1,27 +1,30 @@ import factory from product.models import Product, Category + + class CategoryFactory(factory.django.DjangoModelFactory): - title = factory.Faker('pystr') - slug = factory.Faker('pystr') - description = factory.Faker('pystr') + title = factory.Faker("pystr") + slug = factory.Faker("pystr") + description = factory.Faker("pystr") active = factory.Iterator([True, False]) - + class Meta: model = Category + class ProductFactory(factory.django.DjangoModelFactory): - price = factory.Faker('pyint') - title = factory.Faker('pystr') - + price = factory.Faker("pyint") + title = factory.Faker("pystr") + @factory.post_generation def category(self, create, extracted, **kwargs): if not create: return - + if extracted: for category in extracted: self.category.add(category) - + class Meta: model = Product diff --git a/product/models/__init__.py b/product/models/__init__.py index e8cb39c..4114c9c 100644 --- a/product/models/__init__.py +++ b/product/models/__init__.py @@ -1,2 +1,2 @@ from .category import Category -from .product import Product \ No newline at end of file +from .product import Product diff --git a/product/models/category.py b/product/models/category.py index d4dfc45..fe10920 100644 --- a/product/models/category.py +++ b/product/models/category.py @@ -1,10 +1,11 @@ from django.db import models + class Category(models.Model): title = models.CharField(max_length=100) slug = models.SlugField(unique=True) description = models.CharField(max_length=200, blank=True, null=True) active = models.BooleanField(default=True) - + def __unicode__(self): - return self.title \ No newline at end of file + return self.title diff --git a/product/models/product.py b/product/models/product.py index 1a6a80d..e624508 100644 --- a/product/models/product.py +++ b/product/models/product.py @@ -1,11 +1,11 @@ - from django.db import models from product.models.category import Category + class Product(models.Model): title = models.CharField(max_length=100) description = models.TextField(max_length=500, blank=True, null=True) price = models.PositiveIntegerField(null=True) active = models.BooleanField(default=True) - category = models.ManyToManyField(Category, blank=True) \ No newline at end of file + category = models.ManyToManyField(Category, blank=True) diff --git a/product/serializers/__init__.py b/product/serializers/__init__.py index 1236164..dd0bfa2 100644 --- a/product/serializers/__init__.py +++ b/product/serializers/__init__.py @@ -1,2 +1,2 @@ from .product_serializer import ProductSerializer -from .category_serializer import CategorySerializer \ No newline at end of file +from .category_serializer import CategorySerializer diff --git a/product/serializers/category_serializer.py b/product/serializers/category_serializer.py index de2dc99..cfe2ff8 100644 --- a/product/serializers/category_serializer.py +++ b/product/serializers/category_serializer.py @@ -2,12 +2,13 @@ from product.models.category import Category + class CategorySerializer(serializers.ModelSerializer): class Meta: model = Category fields = [ - 'title', - 'slug', - 'description', - 'active', - ] \ No newline at end of file + "title", + "slug", + "description", + "active", + ] diff --git a/product/serializers/product_serializer.py b/product/serializers/product_serializer.py index a494f2e..4a5d5d7 100644 --- a/product/serializers/product_serializer.py +++ b/product/serializers/product_serializer.py @@ -3,27 +3,30 @@ from product.models.product import Product, Category from product.serializers.category_serializer import CategorySerializer + class ProductSerializer(serializers.ModelSerializer): category = CategorySerializer(read_only=True, many=True) - categories_id = serializers.PrimaryKeyRelatedField(queryset=Category.objects.all(), write_only=True, many=True) - + categories_id = serializers.PrimaryKeyRelatedField( + queryset=Category.objects.all(), write_only=True, many=True + ) + class Meta: model = Product fields = [ - 'id', - 'title', - 'description', - 'price', - 'active', - 'category', - 'categories_id', + "id", + "title", + "description", + "price", + "active", + "category", + "categories_id", ] - + def create(self, validated_data): - category_data = validated_data.pop('categories_id') - + category_data = validated_data.pop("categories_id") + product = Product.objects.create(**validated_data) for category in category_data: product.category.add(category) - - return product \ No newline at end of file + + return product diff --git a/product/tests/tests_viewsets/test_product_viewset.py b/product/tests/tests_viewsets/test_product_viewset.py index f8cec1f..e486ebc 100644 --- a/product/tests/tests_viewsets/test_product_viewset.py +++ b/product/tests/tests_viewsets/test_product_viewset.py @@ -1,4 +1,4 @@ -from product.factories import CategoryFactory, ProductFactory +from product.factories import CategoryFactory, ProductFactory from order.factories import UserFactory from product.models import Product, category from rest_framework.test import APITestCase, APIClient @@ -7,49 +7,44 @@ import json - class TestProductViewSet(APITestCase): client = APIClient() - + def setUp(self): self.user = UserFactory() - + self.product = ProductFactory( - title='pro controller', + title="pro controller", price=200.00, ) + def test_get_all_product(self): - response = self.client.get( - reverse('product-list', kwargs={'version': 'v1'}) - ) - + response = self.client.get(reverse("product-list", kwargs={"version": "v1"})) + self.assertEqual(response.status_code, status.HTTP_200_OK) product_data = json.loads(response.content) - - self.assertEqual(product_data[0]['title'], self.product.title) - self.assertEqual(product_data[0]['price'], self.product.price) - self.assertEqual(product_data[0]['active'], self.product.active) - + + self.assertEqual(product_data[0]["title"], self.product.title) + self.assertEqual(product_data[0]["price"], self.product.price) + self.assertEqual(product_data[0]["active"], self.product.active) + def test_create_product(self): category = CategoryFactory() - data = json.dumps({ - 'title': 'notebook', - 'price': 800.00, - 'categories_id': [ category.id ] - }) + data = json.dumps( + {"title": "notebook", "price": 800.00, "categories_id": [category.id]} + ) - print("Data sent1:", data) response = self.client.post( - reverse('product-list', kwargs={'version': 'v1'}), + reverse("product-list", kwargs={"version": "v1"}), data=data, - content_type='application/json' + content_type="application/json", # content_type='json' ) - + self.assertEqual(response.status_code, status.HTTP_201_CREATED) - - created_product = Product.objects.get(title='notebook') - - self.assertEqual(created_product.title, 'notebook') + + created_product = Product.objects.get(title="notebook") + + self.assertEqual(created_product.title, "notebook") self.assertEqual(created_product.price, 800.00) diff --git a/product/urls.py b/product/urls.py index 3610b7b..d4484f7 100644 --- a/product/urls.py +++ b/product/urls.py @@ -1,12 +1,11 @@ - from django.urls import path, include from rest_framework import routers from product import viewsets router = routers.SimpleRouter() -router.register(r'product', viewsets.ProductViewSet, basename='product') +router.register(r"product", viewsets.ProductViewSet, basename="product") urlpatterns = [ - path('', include(router.urls)), -] \ No newline at end of file + path("", include(router.urls)), +] diff --git a/product/viewsets/__init__.py b/product/viewsets/__init__.py index d292b0e..ab3446c 100644 --- a/product/viewsets/__init__.py +++ b/product/viewsets/__init__.py @@ -1,2 +1 @@ - -from .product_viewset import ProductViewSet \ No newline at end of file +from .product_viewset import ProductViewSet diff --git a/product/viewsets/category_viewset.py b/product/viewsets/category_viewset.py index 43241ca..dcac73a 100644 --- a/product/viewsets/category_viewset.py +++ b/product/viewsets/category_viewset.py @@ -2,8 +2,10 @@ from product.models import Category from product.serializers.category_serializer import CategorySerializer + + class CategoryViewSet(ModelViewSet): serializer_class = CategorySerializer - + def get_queryset(self): - return Category.objects.all() \ No newline at end of file + return Category.objects.all() diff --git a/product/viewsets/product_viewset.py b/product/viewsets/product_viewset.py index 41df1db..218cc96 100644 --- a/product/viewsets/product_viewset.py +++ b/product/viewsets/product_viewset.py @@ -1,14 +1,24 @@ from rest_framework.viewsets import ModelViewSet -from rest_framework.authentication import SessionAuthentication,BasicAuthentication, TokenAuthentication +from rest_framework.authentication import ( + SessionAuthentication, + BasicAuthentication, + TokenAuthentication, +) from rest_framework.permissions import IsAuthenticated from product.models import Product -from product.serializers.product_serializer import ProductSerializer +from product.serializers.product_serializer import ProductSerializer + + class ProductViewSet(ModelViewSet): - authentication_classes = [SessionAuthentication, BasicAuthentication, TokenAuthentication] + authentication_classes = [ + SessionAuthentication, + BasicAuthentication, + TokenAuthentication, + ] permission_classes = [IsAuthenticated] serializer_class = ProductSerializer - + def get_queryset(self): - return Product.objects.all() \ No newline at end of file + return Product.objects.all() diff --git a/pyproject.toml b/pyproject.toml index ff297a2..c2207b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ django = "^5.0.3" django-rest-framework = "^0.1.0" django-extensions = "^3.2.3" django-debug-toolbar = "^4.3.0" +flake8 = "^7.0.0" [build-system] From 0985be632928341d6dcd87ae294ba33eb86760e0 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 12 May 2024 15:14:06 -0300 Subject: [PATCH 26/42] feat: add github-actions demo --- .github/workflows/github-actions-demo.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/github-actions-demo.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 0000000..deddd0b --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,17 @@ +name: GitHub Actions Demo +on: [push] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file From 6ca601a87e982f7d73c1809188ed7d19ccf40218 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 12 May 2024 15:42:01 -0300 Subject: [PATCH 27/42] =?UTF-8?q?Removendo=20autentica=C3=A7=C3=B5es=20des?= =?UTF-8?q?necess=C3=A1rias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product/viewsets/product_viewset.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/product/viewsets/product_viewset.py b/product/viewsets/product_viewset.py index 218cc96..505d1e1 100644 --- a/product/viewsets/product_viewset.py +++ b/product/viewsets/product_viewset.py @@ -1,9 +1,4 @@ from rest_framework.viewsets import ModelViewSet -from rest_framework.authentication import ( - SessionAuthentication, - BasicAuthentication, - TokenAuthentication, -) from rest_framework.permissions import IsAuthenticated @@ -12,11 +7,6 @@ class ProductViewSet(ModelViewSet): - authentication_classes = [ - SessionAuthentication, - BasicAuthentication, - TokenAuthentication, - ] permission_classes = [IsAuthenticated] serializer_class = ProductSerializer From 51f4f957c1361ecf3085364a959c038b9b262507 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 12 May 2024 15:42:29 -0300 Subject: [PATCH 28/42] =?UTF-8?q?Atualizando=20credenciais=20e=20renomeand?= =?UTF-8?q?o=20vari=C3=A1veis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 28 +++++++++++----------------- env.dev | 6 +++--- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 66640b1..1309f30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,33 +1,27 @@ version: '3.9' services: + db: + image: postgres:13.0-alpine + ports: + - 5432:5432 + volumes: + - postgres_data:/var/lib/postgresql/data/ + environment: + - POSTGRES_USER=bookstore_dev + - POSTGRES_PASSWORD=bookstore_dev + - POSTGRES_DB=bookstore_dev_db web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - - .:/usr/src/app + - . :/usr/src/app/ ports: - 8000:8000 env_file: - ./env.dev - networks: - - backend depends_on: - db - db: - image: postgres:13.0-alpine - volumes: - - postgres_data:/var/lib/postgresql/data - environment: - - POSTGRES_USER=dev - - POSTGRES_PASSWORD=dev - - POSTGRES_DB=bookstore_db - networks: - - backend - -networks: - backend: - driver: bridge volumes: postgres_data: \ No newline at end of file diff --git a/env.dev b/env.dev index fca16a0..491c2f0 100644 --- a/env.dev +++ b/env.dev @@ -2,8 +2,8 @@ DEBUG=1 SECRET_KEY=foo DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] SQL_ENGINE=django.db.backends.postgresql -SQL_DATABASE=bookstore_db -SQL_USER=dev -SQL_PASSWORD=dev +SQL_DATABASE=bookstore_dev_db +SQL_USER=bookstore_dev +SQL_PASSWORD=bookstore_dev SQL_HOST=db SQL_PORT=5432 \ No newline at end of file From cdd98afc12a7a97134e8f8bc53c3a1289e25bcc7 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Tue, 14 May 2024 19:17:33 -0300 Subject: [PATCH 29/42] Revisando test_viewsets --- .../__pycache__/__init__.cpython-312.pyc | Bin 167 -> 167 bytes .../__pycache__/settings.cpython-312.pyc | Bin 3068 -> 3752 bytes bookstore/__pycache__/urls.cpython-312.pyc | Bin 1477 -> 1477 bytes bookstore/__pycache__/wsgi.cpython-312.pyc | Bin 659 -> 659 bytes bookstore/settings.py | 39 +++++++++--------- db.sqlite3 | Bin 200704 -> 200704 bytes docker-compose.yml | 2 +- order/__pycache__/__init__.cpython-312.pyc | Bin 163 -> 163 bytes order/__pycache__/admin.cpython-312.pyc | Bin 251 -> 251 bytes order/__pycache__/apps.cpython-312.pyc | Bin 467 -> 467 bytes order/__pycache__/factories.cpython-312.pyc | Bin 1747 -> 1747 bytes order/__pycache__/urls.cpython-312.pyc | Bin 604 -> 604 bytes .../__pycache__/0001_initial.cpython-312.pyc | Bin 1400 -> 1400 bytes .../0002_alter_order_user.cpython-312.pyc | Bin 1134 -> 1134 bytes .../0003_alter_order_user.cpython-312.pyc | Bin 1118 -> 1118 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 174 -> 174 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 208 -> 208 bytes .../models/__pycache__/order.cpython-312.pyc | Bin 758 -> 758 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 234 -> 234 bytes .../order_serializer.cpython-312.pyc | Bin 2147 -> 2150 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 169 -> 169 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 183 -> 183 bytes ...order_viewset.cpython-312-pytest-8.0.2.pyc | Bin 0 -> 3565 bytes .../test_order_viewset.cpython-312.pyc | Bin 3437 -> 3452 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 225 -> 225 bytes .../__pycache__/order_viewset.cpython-312.pyc | Bin 651 -> 651 bytes product/__pycache__/__init__.cpython-312.pyc | Bin 165 -> 165 bytes product/__pycache__/admin.cpython-312.pyc | Bin 277 -> 277 bytes product/__pycache__/apps.cpython-312.pyc | Bin 473 -> 473 bytes product/__pycache__/factories.cpython-312.pyc | Bin 1865 -> 1939 bytes product/__pycache__/urls.cpython-312.pyc | Bin 610 -> 610 bytes product/factories.py | 1 + .../__pycache__/0001_initial.cpython-312.pyc | Bin 1777 -> 1777 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 176 -> 176 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 256 -> 256 bytes .../__pycache__/category.cpython-312.pyc | Bin 951 -> 951 bytes .../__pycache__/product.cpython-312.pyc | Bin 967 -> 967 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 303 -> 303 bytes .../category_serializer.cpython-312.pyc | Bin 770 -> 770 bytes .../product_serializer.cpython-312.pyc | Bin 1626 -> 1627 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 171 -> 171 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 186 -> 186 bytes ...oduct_viewset.cpython-312-pytest-8.0.2.pyc | Bin 0 -> 3271 bytes .../test_product_viewset.cpython-312.pyc | Bin 3166 -> 4069 bytes .../tests_viewsets/test_product_viewset.py | 19 ++++++--- .../__pycache__/__init__.cpython-312.pyc | Bin 231 -> 231 bytes .../product_viewset.cpython-312.pyc | Bin 1122 -> 974 bytes product/viewsets/product_viewset.py | 2 +- 48 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312-pytest-8.0.2.pyc create mode 100644 product/tests/tests_viewsets/__pycache__/test_product_viewset.cpython-312-pytest-8.0.2.pyc diff --git a/bookstore/__pycache__/__init__.cpython-312.pyc b/bookstore/__pycache__/__init__.cpython-312.pyc index 3bf304576581b3e57ab35ef2309fe13118840155..b6a423e1159d937e8c081d059ef3d21b0de897da 100644 GIT binary patch delta 20 acmZ3^xSWyaG%qg~0}$N#Yn?WcXEp#hl?DC) delta 20 acmZ3^xSWyaG%qg~0}#w`d6hbmXEp#e$_1|g diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index a05475ab4fa1a77eb6aba927500ac29ae19b4d30..196472f42e80e6d130e222544f39becc3da18e50 100644 GIT binary patch delta 1411 zcmbVM&1)M+6rb5$ee7zb$g*O~vQ;OolUhzBHFg|_mYPVls#Z~C*HS3#MM!!pdG)pK zuGA!gM(QnrLJ)h94?YCvVn`1KAKL$+5K?q83oV5}q0oce^jK(TrK)ylq0|HO-kUe? z_j?~Z?C+ENzVx?tJBP?pzm61s8$;-YaTu+^4LQ90fDHJjFv;$<|3sxA+mqu`d0KPp|+ZSc?cudstwJHWST(MX-V4Wq~8owudDQ{4P_( z0uOe<4h|8QW{#OhR%v!*wMGU)a0Z-DN&Uw9FW4~3kT51%z}2)NbPDV^wA`nForQ^0 zpeDidPt=M25jq~riT4dm=Vo|ABq5ys%W;DXnMabN{E z*=Na~fH#Cmm=ip30WOly^yVIh`CVF=0)O!q7QEzHO#hF8F981X(x{}-V-jZWQU1$X z5QAwcxEQ>yb#a0wmi7~tT11Bwu@F+ldR?j&)e!fy(O}Y#b!H=5-)csnl&uxzfK*e( zd_xffg@y8scbAuP`Q`KKmRPtFxOV4KbuLi!m(}fDwo+db)I`ZpglU|8zI{3vB$3ES(7LDAF`LW_4 zBlr7sOC|$yK9kWYS=A!!4Q+>w*)3x2Q%R9)I$ad&+7E2pY9%Q$i7Rhu7r7Xx(-Il! z93jxEoG|+yF^r#x`h>_njWIr=ILy5CAk2M_JlYFxp8D0TP1#~CcXy$)&<%Eik7u5T zZuVS>L#M0Db-1phScGGJ+)3*M|+S}$nj~t#h*XPj0@^j?sTeU-* mZ?4TB@rdOgL>|Q-#vdggCU;i$!w-@@KG?H{J~t_0(&?W_mp;e< delta 673 zcmY*WO-~b16n$?#+v&_OEtDxp0Yj^{CT*pXKmrLE8a`6X0*uL9*jVm#QYf~}6oGE2 zzu_&^gpFO9VBB=$e{iEa)3`8kLm2P>Bv2=#~Tn%>Y7R zoN^UR1|SF_<_f}KABXxFu3%dr1`KCN5KIzcfrIP~L4<^1gbc$dTwwuYZ4A*1lN^vg_X5Jt}7Il z?&ch$^U)W@SnmAvuVb~480pHzBGk5vMOq3hhQ;OFoqH=?Z7HAMxSv}tu5N5@ZPFKk zRr({aM%UFGeXf$RTkN3TU%OKbJsx9x&M8><9zl47hO`^HCn3Mq5p7RRsh9 delta 20 acmX@geUzK~G%qg~0}$95D{SQ6#R>p5ECiN{G%qg~0}$N#Yn`@{r=1A^JY@y! delta 21 bcmbQtI+>N{G%qg~0}w28d6l}6r=1A^IlBd` diff --git a/bookstore/settings.py b/bookstore/settings.py index 1cec9c8..edf8831 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -1,13 +1,13 @@ """ Django settings for bookstore project. -Generated by 'django-admin startproject' using Django 5.0.3. +Generated by 'django-admin startproject' using Django 3.2.8. For more information on this file, see -https://docs.djangoproject.com/en/5.0/topics/settings/ +https://docs.djangoproject.com/en/3.2/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/5.0/ref/settings/ +https://docs.djangoproject.com/en/3.2/ref/settings/ """ import os @@ -18,15 +18,15 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-ytvw$u%b^9xle0&yw3*%=$s2zz@spz94k*%*88xr50s$dggo#e" +SECRET_KEY = "django-insecure-f*k@=53bc5!shef1-6w+m$-g)kspbaljz%8k4(j7iuc-u2_dyd" # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +# DEBUG = True -ALLOWED_HOSTS = [] +# ALLOWED_HOSTS = [] # Application definition @@ -39,9 +39,9 @@ "django.contrib.messages", "django.contrib.staticfiles", "django_extensions", - "rest_framework", "order", "product", + "rest_framework", "debug_toolbar", "rest_framework.authtoken", ] @@ -79,7 +79,7 @@ # Database -# https://docs.djangoproject.com/en/5.0/ref/settings/#databases +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { "default": { @@ -92,9 +92,8 @@ } } - # Password validation -# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -113,7 +112,7 @@ # Internationalization -# https://docs.djangoproject.com/en/5.0/topics/i18n/ +# https://docs.djangoproject.com/en/3.2/topics/i18n/ LANGUAGE_CODE = "en-us" @@ -121,19 +120,22 @@ USE_I18N = True +USE_L10N = True + USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/5.0/howto/static-files/ +# https://docs.djangoproject.com/en/3.2/howto/static-files/ -STATIC_URL = "static/" +STATIC_URL = "/static/" # Default primary key field type -# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + REST_FRAMEWORK = { "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination", "PAGE_SIZE": 5, @@ -148,11 +150,10 @@ "127.0.0.1", ] -SECRET_KEY = os.environ.get("SECRET_KEY") +# SECRET_KEY = os.environ.get("SECRET_KEY") DEBUG = int(os.environ.get("DEBUG", default=0)) -# 'DJANGO_ALLOWED_HOSTS' should be a single string os hosts with a space between each. +# 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each. # For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]' - -ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") +# ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index c4e3cf4566fbe4520c56b126d9581e3db3fc8bbd..92faf2162c477e80b6cfcd9962193397e898dfcf 100644 GIT binary patch delta 123 zcmZozz|*jRXM!|i(nJ|&#-xo2OZb_kIBO@f3m7wT)^2tbaO8A%m11R(cXv!IEy*a! z&rZ!VFfcHQPs}MvEs6*83ySh9D&zADN;32Fij546Omq!Qbq$RajEt;|EUZjS^~^2J Y4NQzSACa^cW0Yz#Xft43X2A3S0QaRNo&W#< delta 48 zcmZozz|*jRXM!|i;zSu|#>9;YOZb^3Igd*!zebve7fC4yX(Rx7llo}G5`gN1c3$v E0Kr!rQ2+n{ delta 102 zcmcc2dzqK_G%qg~0}vcKDV26>BX2wtBhTbqrVK`o&DWR~GcpQIu4385C^cD^wVIKC z@=DfU1}vrK?VE@XUB$oLBbP~Zz652M%w^XYaI?XC-(Tog9>$^aB75(F9y E00)&F7ytkO diff --git a/order/__pycache__/urls.cpython-312.pyc b/order/__pycache__/urls.cpython-312.pyc index a3aeef2b83658e4495f8cb06b19d0382a07334a9..12fdf8a475794888a3eb555c5a4aa1f280c1b6c9 100644 GIT binary patch delta 26 gcmcb^a)*WcG%qg~0}zBo+iv9k&&YUxGB;Bo0Ab1pHUIzs delta 26 gcmcb^a)*WcG%qg~0}vcKDYcRNKO^Jw$=pnV0BaQo^#A|> diff --git a/order/migrations/__pycache__/0001_initial.cpython-312.pyc b/order/migrations/__pycache__/0001_initial.cpython-312.pyc index 6f1b0bf3efd58f30f998d065d01f07373877b8af..09e564ad75af6e5cc23e45355c53a0d7f079a2c3 100644 GIT binary patch delta 20 acmeyt^@EH1G%qg~0}#0Wv);&^%L)KNdIhTh delta 20 acmeyt^@EH1G%qg~0}vcKDYcP1mlXg*0tM0l diff --git a/order/migrations/__pycache__/0002_alter_order_user.cpython-312.pyc b/order/migrations/__pycache__/0002_alter_order_user.cpython-312.pyc index 7ad733534558d7204635cf37bea66a06f38e5e0d..5ae9aae75909eafc98463e2bb250ead93d00b4f5 100644 GIT binary patch delta 20 acmaFI@s5N0G%qg~0}#0Wv);&^%mM&Ep#_Kl delta 20 acmaFI@s5N0G%qg~0}vcKDYcP1nFRnrDFv?p diff --git a/order/migrations/__pycache__/0003_alter_order_user.cpython-312.pyc b/order/migrations/__pycache__/0003_alter_order_user.cpython-312.pyc index 20f5fc7b667b8600f864beb11b84db04e68bd354..c4771470ef6fa67eb52df2940af607ac966ce0fa 100644 GIT binary patch delta 20 acmcb|agT%hG%qg~0}#0Wv);%Z%mM&CAq7|f delta 20 acmcb|agT%hG%qg~0}vcKDYcP1m<0ensRe%k diff --git a/order/migrations/__pycache__/__init__.cpython-312.pyc b/order/migrations/__pycache__/__init__.cpython-312.pyc index 9e6156fdfbee01804131627250ef1b22cb5a04f3..01387716dacb55c0e7dbaf50b4e598f521adc4a2 100644 GIT binary patch delta 20 acmZ3-xQ>zMG%qg~0}$N#Yn?WcXAuB7rUnxL delta 20 acmZ3-xQ>zMG%qg~0}v<&yh)wNvj_k)`UPD8 diff --git a/order/models/__pycache__/__init__.cpython-312.pyc b/order/models/__pycache__/__init__.cpython-312.pyc index 7e5d4106a82279b4d0f9c880c9b6d4080b130029..de95e3152013a5c5c4feee1ed60a09e001aa7037 100644 GIT binary patch delta 21 bcmcb>c!81kG%qg~0}zBo+onlQc!81kG%qg~0}vcKDU~KMk@qkFL0kqS diff --git a/order/models/__pycache__/order.cpython-312.pyc b/order/models/__pycache__/order.cpython-312.pyc index a00174f59b8fd0cc71add066948878c1a892dc86..586b1d48ed8fdb5aebb45b33a92b8cf40b934f72 100644 GIT binary patch delta 49 zcmeyy`i+(MG%qg~0}zBo+olO_359=PLt{StJZp0{|&u B3n>5q delta 49 zcmeyy`i+(MG%qg~0}vcKDV4^%k(ZH)k##aZ(`6ABCPv#1w|<{apRWu+W|1&Z4FEzj B3)uhw diff --git a/order/serializers/__pycache__/__init__.cpython-312.pyc b/order/serializers/__pycache__/__init__.cpython-312.pyc index ac7c6b1b13546e19325d61c74c6f694131e36558..add5d28acb988ead60d227d0504031c06f6380c1 100644 GIT binary patch delta 21 bcmaFG_==JDG%qg~0}zBo+otJFk@qeDMcM|2 diff --git a/order/serializers/__pycache__/order_serializer.cpython-312.pyc b/order/serializers/__pycache__/order_serializer.cpython-312.pyc index fd67f364beb127f8126b6437d3c4a9a5d2930868..b81cbd5a7e3e529273a0c361a3cb9aba98d2566c 100644 GIT binary patch delta 113 zcmaDX@JxXBG%qg~0}zBo+ooA;d4JJEMzA!Thvo&~sU}NCbo1Dh}T#QYEQFKD~buq(> OVuoKCfSe*_pa}qsuO0XR delta 110 zcmaDR@K}KNG%qg~0}vcKDV651k=KHmk!Q0Tvo<56z~&;Bt&EJKlQr1>v#|qJ6o*gN zWtWlNk-k5FXa04&z>9W)m+gWtB&1x(&c7m5(BOT8M|W~2`*SfCF-Fk|+1JGkFNzs{ LWdL%Dl!4j-E>t2S diff --git a/order/tests/__pycache__/__init__.cpython-312.pyc b/order/tests/__pycache__/__init__.cpython-312.pyc index a854db1aaa889fc8e9479db0ae0eec248b3a38ee..00655d5b33e9d73f372769fff8e72a3cba911058 100644 GIT binary patch delta 19 ZcmZ3rlRK3D*Sg94{$gCcKg?QkApC2R*aepdt%hMVo=9`O{vL}Ys}cRdAd|~;p6w5qqg2CyKNcm zyyh4*TvpCfy(6Ki_I6-Jwp0#I6;Qq{YO`~|yE;lSlzEdAW7PaLdBI_5}zNH_w4R^w2ftxGF}xYq$(GaI&g&ErA%?=7^gL zSF61txA_Iz7^$w&IT8OKPQ>eC7IgF|qp>Z#ggj^sbeROPidUvN3kZGrYKhJ` zh{8_8bRCKpF(_!n0gAcvqX5Sh(8G$)r~GJ{VYeTdF6(j$)_~+8kG7KXrEJ*N|Xy5jQ(80W@7BtLYt!W4Fc@Pux23ha*el zA7}q^^5M(pSN2?Zlzw$V`czU{QpS@q?`B%r{a$we@|D)egf}v=BK`0mgV{y(mU>5O z1Ae>k!wiFJSnx&U0=D3OjTBCKPV>lFjkkf!z$ZJqYUDd!4s- zJ^~QZ0Yx}$dsLGlxB1-!MFeAA05}#yfS8Nu(dAh93eV$9jaAV#=7jBl)9t|CvrE+N z0917w0I5FTO2bs?!&c3?s<_ne8pr>t+RB zc7TBqtVYllu%3LSU5=XDtQ+`>qnUh)V#^Uc^?BfYQEymv$LGQRUX+Ep?F2|bzl}Th zAz_u@+phcr+T?{(6VsKolmTsC1PS^H3;{iagtZa}k;5*{PnM|x9f%&3 zwS!;-^$sH_`94iLC|QW_ju_&YfAd&&zAD{ryu5z zt|()xeS@pn@2RGWjL@+D2Hl`KQkd|A^h=!H$>6-`5=4OS?2cq|VT?++~?!EWa+VP;sQXb;XJ z!9NG%eVzO*IrR1$*G_*Sh~m*Ndiq6q<2!xg;Xnzu<+HwYu~9MIO3m?=m+MWfBW1OE z6JuWpfFCYWff`q7#f9d+Glh>zFeigDOI3+dc7u8V&Ry*ih2M77rk8`ulK$#s0X3)q z2Vp1iY*}KLn02W=p&mrk0AmT< zuLS$sQ+Q2-pq)St0gnapsWcv>;W#}5bJ*ZIc%RlI9LGJzsQxdJ!U<#m literal 0 HcmV?d00001 diff --git a/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc b/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc index a1fe00220f11263040a7abeddc6b6a740663e4cc..6cf350f198769146da2a5bc848c202d4edd57d58 100644 GIT binary patch delta 456 zcmaDW^+$^LG%qg~0}zBo+oo;Y$ZNoCDg@*eTLXy(hC34KD{`(#Sa-1W@ZJ$uy&)vI zKzIYocHWJ=E9$>6Gf8j(C3wEDF^DN`&Sk#EtRo51YRL%FdP7)zy7ffs>Gl)tmzb}x zIUsq$<$^=t73HAI!oeLJ4>))xSFoGa-{29OP z$9hM|{+OLH*KPeT+WG@6En8<~ol3OpLmd?YI@>9w?|U z=UT`$qvnRR{CxA7<{w#^dHFswvkCx%@dMxF8t#4ae4qf701_<>4|&D9qZ`~lv9PjQ hec}^h<@&54xH*c4nNfhvfYEe9^;ZTURU{2m3jpP-mH7Yw delta 441 zcmew(^;U}aG%qg~0}%A2E2Q~uj$ofucNjL=`s|G2db~6a(qfV+85CAuK-KdZP7o`-%2{(p;Yzm<6~ySUzw~?&032zzYgBNg&a}@Q_!mJG#N`6ALq|)h8}) e);z|~Qv91Ud6*dmSX3EJCscoB08&NLK*azw)SPet diff --git a/order/viewsets/__pycache__/__init__.cpython-312.pyc b/order/viewsets/__pycache__/__init__.cpython-312.pyc index 1ce246db264ad424972ac7b3aa2ca6620fff3160..5d98afe0ed71c4935e2681aa435146de97ba5670 100644 GIT binary patch delta 21 bcmaFJ_>htJG%qg~0}zBo+oowwhtJG%qg~0}vcKDV3%@k@pG!L}3PL diff --git a/order/viewsets/__pycache__/order_viewset.cpython-312.pyc b/order/viewsets/__pycache__/order_viewset.cpython-312.pyc index ca1c3066252e9cc212ed3337eccbe4b29da3a6cd..8fa93d6a15295c5df2b7c06409c43c1f2daa6738 100644 GIT binary patch delta 45 xcmeBX?PldY&CAQh00d#twrM{$^6p|}WS@M3akBs$Go$hZo39K&sz?AR4*&&z3ZMW0 delta 45 xcmeBX?PldY&CAQh00f6lN~L|-$h(V?k!|t`#?1mO%#6wtY`!u8sUiWOJOCSz3s3+6 diff --git a/product/__pycache__/__init__.cpython-312.pyc b/product/__pycache__/__init__.cpython-312.pyc index b6765e97adc345b5834e93da0c0f4b3fac061ea6..c10d7632f1d10cbdabc2037fdb006e586994724f 100644 GIT binary patch delta 20 acmZ3=xRjCSG%qg~0}$N#Yn?WcXC?qRM+Nu* delta 20 acmZ3=xRjCSG%qg~0}z-7yh)wNGZO$a83j}T diff --git a/product/__pycache__/admin.cpython-312.pyc b/product/__pycache__/admin.cpython-312.pyc index f0a496dbb8cda4b755c571f6a38416dfd0568be2..784abddc0752278d4f00a66079810898a1eded60 100644 GIT binary patch delta 22 ccmbQrG?j_>G%qg~0}zBo+ool1G%qg~0}vcKDV3JKk(YxJ06vceWB>pF diff --git a/product/__pycache__/apps.cpython-312.pyc b/product/__pycache__/apps.cpython-312.pyc index e28f29b63f06c9bf12a70db73f11aee37e81de85..20f93da3a46116397b5551c33522148ade0aed62 100644 GIT binary patch delta 21 bcmcb~e3O~yG%qg~0}$N#Yn`@{=PV-tN0bJ+ delta 21 bcmcb~e3O~yG%qg~0}z-6yh+{2bCwYRLCOXe diff --git a/product/__pycache__/factories.cpython-312.pyc b/product/__pycache__/factories.cpython-312.pyc index 8b774ba83718fd9bb750e482e05091e659245476..2663c483b9c097a208c911f70903fbd68fae9d99 100644 GIT binary patch delta 276 zcmX@fH<_RBG%qg~0}$Mr;*_SsypgYyiIHdW45n5_w#jnLRg4=Z&tx`J<^icd1*z<- z86hH3983(U%o77d1X7sbVw|bWSt64I8HFdavM4ZePgZ03&L}!rj&+Ny98gy=JCJB$ zxFI0k$y&q@WETkn2|rDq$?sVeByaKhBvw^AmXs7_CY6??7O{a8$O4JU{A}Wrm_;Vr zvvINs0QtpXll|Dl1o>4u%CGaQT;x|-5PzB9w83L?GTU56?a7Sn5(aGSjFJ=5r{_(~ nyDnyaQOx`c15n_L2tT95gz)Kc6XULnnq3q%`^o?m06PQ#HmN=e delta 289 zcmbQtf0B>yG%qg~0}w2AQ%L*Gw2`lqiIHpa45n5_mdSF=Rg688XEK{j)?pOkXIjk& zQpdm$#g@vP#Wy*SQFyW@ivlC(WG|NQjDnM$Shqw-0i}!CfkX?#4FT~^)*^l&yGRg7 z_-S$#f$S;b1`#|ULI^|%1BqL#1x1<3sYN0nHh)2WaY=l7YF=tlVo7FxUXd(Nbn<^D zQ5BHkMIeF~h>Kl-1ke^9$qx5^-%j5d>X&(x8eAu@Wt;1%1(X80wb&d;d|+l|WW3G5 z_nblJ3llq|6!;><$0#u&e0to(xa*>37e&p!G5`g@E(ZX$ C14L{9 diff --git a/product/__pycache__/urls.cpython-312.pyc b/product/__pycache__/urls.cpython-312.pyc index 3e9755f131117d68ac716b8df1b90fd445a88ef2..72149fd33e3935200607d6e153c4d3f21df0dd92 100644 GIT binary patch delta 26 gcmaFF@`#1|G%qg~0}zBo+iv7$Wn#QPS&%6Z09!u>PXGV_ delta 26 gcmaFF@`#1|G%qg~0}vcKDYcQCm5K5BWI?7t0Az{>4gdfE diff --git a/product/factories.py b/product/factories.py index 031b956..8a6ebef 100644 --- a/product/factories.py +++ b/product/factories.py @@ -15,6 +15,7 @@ class Meta: class ProductFactory(factory.django.DjangoModelFactory): price = factory.Faker("pyint") + category = factory.LazyAttribute(CategoryFactory) title = factory.Faker("pystr") @factory.post_generation diff --git a/product/migrations/__pycache__/0001_initial.cpython-312.pyc b/product/migrations/__pycache__/0001_initial.cpython-312.pyc index 1deb86e319c5a3c4da2ea9b417ec43ace75e6a58..0c23f8bac28508b584a90204fecd406e2012f3ff 100644 GIT binary patch delta 20 acmey!`;nLXG%qg~0}#0Wv);)4j12%m&juX; delta 20 acmey!`;nLXG%qg~0}vcKDYcRN85;mYR|Z4? diff --git a/product/migrations/__pycache__/__init__.cpython-312.pyc b/product/migrations/__pycache__/__init__.cpython-312.pyc index 68f1ef71bd9a0f3d468d3db1d30353e2d5749293..d8cd97661f4b88732857beeee7c1461f4e301229 100644 GIT binary patch delta 20 acmdnMxPg)9G%qg~0}$N#Yn?WcX9)l~^adFK delta 20 acmdnMxPg)9G%qg~0}z-7yh)wNvjhM%#szf% diff --git a/product/models/__pycache__/__init__.cpython-312.pyc b/product/models/__pycache__/__init__.cpython-312.pyc index 97951aac1ce8f3e67cf596826b5a7e40935d9c28..d788b80cd9daa262720b09e5b7ee3624a9bd797f 100644 GIT binary patch delta 21 bcmZo*YGC3$&CAQh00d#twrO?~c|QXHFggV! delta 21 bcmZo*YGC3$&CAQh00f6lN~PIMG%qg~0}zBo+iv8xV`Ai*?8UT%k!A9GrY$0D?2J+!W&JgsHD4Kk%pxJ6 FIsjqX4G{nU delta 53 zcmdnazMY->G%qg~0}vcKDYcQ?j){?TvKP}5M&`-ynYM_quro?^l=ati)_i3EGK++O F>HvM{4a5Kd diff --git a/product/models/__pycache__/product.cpython-312.pyc b/product/models/__pycache__/product.cpython-312.pyc index 55da1ea3def141f22456a10e404e41884ea8e7a3..fb9b858f84e7b7b68bd34512c91a3fbcaf3b8ca0 100644 GIT binary patch delta 50 zcmX@kew>~6G%qg~0}z~_?3C8Ek#|0`^j!v-rwlq@*jO2DI@0=cI&;1<0GUNnKt%wA CjSi0h delta 50 zcmX@kew>~6G%qg~0}vcKDV5f-k#|0`^iu|zrwlq@SXdctI@0=cI&;1<0GUNnKt%wB CIu4Wo diff --git a/product/serializers/__pycache__/__init__.cpython-312.pyc b/product/serializers/__pycache__/__init__.cpython-312.pyc index c7c87f404751e70ee74db958fae5219ceeac005c..06b2c2e977982ec2f9b02bc50ffe49dea3ba04ab 100644 GIT binary patch delta 22 ccmZ3_w4RCgG%qg~0}zBo+ook~06fJ6`~Uy| delta 22 ccmZ3_w4RCgG%qg~0}vcKDV3JCkynWk07C)=u>b%7 diff --git a/product/serializers/__pycache__/category_serializer.cpython-312.pyc b/product/serializers/__pycache__/category_serializer.cpython-312.pyc index 7f6f0faa00d66ff3894d8e6d794a576005f3ec25..98734ab4c01d2c57c56da50d3f9ef71f6ca373df 100644 GIT binary patch delta 57 zcmZo-YhvR)&CAQh00d#twrMsSc|R~RvQPfU7{JIj*`H~y7#jy8*9__Fk|q}=O};V! JIYq)iwE&TU4Q~Jd delta 57 zcmZo-YhvR)&CAQh00f6lN~KwB zA>g7zz;%a^iw+@|9l|aor(eh`x*}5C;QO6rauw@oF&1$~@fqCLC5$gh7=L8|a*AYt F`T+?>A^QLT diff --git a/product/tests/__pycache__/__init__.cpython-312.pyc b/product/tests/__pycache__/__init__.cpython-312.pyc index cec44f84082cdce0b2da6c5f83823d1968b84722..e813dd51749e90032d156fe495b0d6fba26ae23b 100644 GIT binary patch delta 19 ZcmZ3@xSEmsG%qg~0}#0Wv!2Mk001wX1q}cI delta 19 ZcmZ3@xSEmsG%qg~0}vcKDK(LM0RS-l1vCHv diff --git a/product/tests/tests_viewsets/__pycache__/__init__.cpython-312.pyc b/product/tests/tests_viewsets/__pycache__/__init__.cpython-312.pyc index 02608113786c973c1e53fe17e261cf5139ed9b98..aa0b8d851d0bfed97d0161ae145bbb7f32d68b41 100644 GIT binary patch delta 19 ZcmdnRxQmhdG%qg~0}#0Wv!2Mk9sn`N1v&r# delta 19 ZcmdnRxQmhdG%qg~0}vcKDK(LMJpeN(1z`XH diff --git a/product/tests/tests_viewsets/__pycache__/test_product_viewset.cpython-312-pytest-8.0.2.pyc b/product/tests/tests_viewsets/__pycache__/test_product_viewset.cpython-312-pytest-8.0.2.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5961e9082eff4e4df8a5429072a3357409a7b0a2 GIT binary patch literal 3271 zcma)8O>7&-6`o!0lFJ{7l1N*k+*Y)lCLtVA@lW$-C;pKo$7!M(j$9P9fW?|SR!Q%2 z+1Zs05i;O|4+@f^F>;Ut1V|1!IIs@NDd^2X4+)TqSu3DAwc!BCC6~g8+>1|rZ@9~i zY1z#H`)1zEdv9mnyzjmFrl%)CpzZ(Q=(#VWgnW-o&{Ti0`92I*h)GPzA|*-mvK=YQ z60wz%D&dN3MeSHAW@{x)@DVF+CrSx1R;;9*Dy8h6Qjg$OtJhAK(so~|Pw-Kz-ySFp zh;huy*x6E6j3sMZX`4)r6H~iP%s5S7kFq)la?*?bNLD})Lkm1LRF$aR0Iq?poWQc_JBXw-}VjV&q#l@H(_{oVYr zLNB~cy|UyhVW+@{r{0_bvO>JhT3~sJ=$$z)xG}gXQ(lc+_jd*|zUK&8Bn4%<(OYLu zzUEO?WDnKvw+Z08KU?3k1# z#q#SjGbi=E&p)sK;rCpry6`L2atzbuF$5*RhT-LfKVulug$T=_w#KMicWRKOf^F-j z;TbMQXFi{2cxOC|u+m{ex?x!Xk{Zu!ft#%aw}A=w??5h*jm+T6fhz}A4qZ9)>5JE1 zyYceZ=FOvTukV_)O%VgF99lR~nx@ z+Zx^59Nl|saNlw&l>gNy#)l)<2AjD(Yx}=A`1!%szRBjk$#rdNqhs$(~yRe%+g$?i5MnURkoA-KGF zAYm#?au{p?jt;m334l2!t*#b=+f>b{8H2Q<1$LHXGrpP#is8iwSncmp2X-m4RRZuj zfPONJy$%?wTfnD^;n>woX*JpLfby61^cnTKRRJZ) z1>=ZPD31z4ji-E=>fT}l+lN_LJ?P(>_=6H{NQdPHjfyJ}9&IH4^V#wy(~tYop(_lSnJGtC`t#JC%8V`r3&#@8<4<>#0{a z`nPT5cHfJU>{FXW%_f$$d%Yyy^JrR`YK~8>YsY^W-udzPhvTi`vF7mD+8Z~A$8HTD zT26^jqykksPKA8rO8aX4q8Mc|zB1c-L4sPU$)(?)C~p zEQ{M?m=)QxNPY+8Ga}50bjuLJf*`(KjHAosUp?F3J#%U5Cnc&Te(KZI6VhfjtG?9M zLWRO0*UrvYEU!{?dFpU|QSWd$y}pQ-Rcsd$2*4tv7g)uEr)g&jAExcO1SpHUH5l*r zYgzG}cn(9bx8o8s8c#b6iqOxN#PbfHgZQQ^f(xkSiqI3W#WPTAJpCL4CtYyZ`6B*= z;iE;kg(uCbQJZs$^9-~^7&-6`mz`$>pC!iIOGCX(`E0oUJR#vfIRoe-v5%ZD3iI>7rm1ENJdpA+_YP zvnv@Sq@pN%kbxA5kb_*HKy&Cph6O}9#V!ii%_RYP(LxF+Y$YT>ed*1J+>1_qZ-2O! zO&e}|>HvK6-prdfZ{|II^Y(ACSeQWD`OB$mzvT(}2MTWE9A^91z$_ApNQ^>?Ool1? zGCl@npW-jF8P?+c3Retd0v69I!6KjGEuK?C#c(EEjASB~98jXgSSDuiL8YnKoN2ar zUWsSoK5~vop&LXB%i%kId;d&Jg%=|KL_zSG%_CV|o>Xb&Y&NGuXEu#dRhrJ}jw~={ zjM6MA1fCsTX6`sU!rno5 zUT<+Z$tU@j**iX42Az;QQy~I33irlN!~IvA%2e&nsU@ANiXziVTPyz#+&-u0bwxJ0 zGR@~?AxzPN8OT{7pm<2yj0BxCgX-0SoYOU!r!s^d7GpRm-kcePJuvpTsU|DeH1xcC zM;>{50&_r{C}#B!824KzUZ0}lp zf8qUFyI`~nOZsP(+m+RJVXgfwm<&Jccy*(-ccZoQG3W0L&$GXaZi5-JD|Ik5R_gp2 zLIJ6R3RWvPp>bvG3-#3TMjMB}P){RI(@Tjt23EafdP%-nrqJYBak(lm%YHY>7)--P z78`i{L=v(RCk67%a?njg*WR2D>?Pd2ynfbKX!9hO)AzVsq0{BO-nGpTeXl!Oc*W(s z9&95TJk{zR`JdyFU*eOnMhaOpj1)AxpE3htq4(J_&$pMd9(jTF{r|J|=nJgB_9E*5 z8L`pZjM;>cA&N*#*`mA?urRwDW?Iju(_`ZBmGt>b;}Z10V`4?ZDA?G{J-SWwivalY3ZE%IaASVXqq+#dI~>5U)gV zUd$?r3sKbr4FIW;BJQTagm7oY2HX4T4^zoM^?@m$>VpW`^r6~c5=)(IkwLK96WOj|5u9VjpT{D`u*8^ zv$dgdV`%&v{xa=?i)oCtAO4?Xt%sm)2{Gr>>uA{sAtgXsz_&V1!qqr!l92*`sN?vY zUq=wIniQP%@4}}>_+Cd;cNLT{KX7@8mqJn)@IB(%ne|K2<(OL&&ar@cDOcO;XW2&h zsn_wd@ItK9>sa-&Z>YpBH`Q^TdyY?B;dReLmy_xxl=T8OIty3$k*n?X66f9sLjXOS zM=3r?6yG0;Mohk>>M~X~PQ`We9l`G*jTy_?^>bd<#Jp6EoCZ|s)&Ph@!;q;l)6zd@Gd_v$! z5OvO4p+`~aFc7oZE+ZuuEj6q%5m8-CO;}KAYq?6**PaKdyY=wKH25_7j}dj{=w11K z{$AcVa&DDRt@Gy}CVJNr`{()1=EO(Uo7Igy-Aivg_~lpc{q?;E7meunw%-?ry6`bi zLQV6=mtLKjczaOY|^%-4#D?eN9>Ram?ns4?nIaN#c8_E8a@H&6Y17LSF z@D2Z_1)`%uz~n^{pL9_)!=hM(a$P|_DvJ1c+A|c9gZ>1`Fp%5CT5LUW6pLt!VE8r6 zp&R6TmgmCXw?()#v)$Ff9kta_Q)o3?oZ_JWn)QJQd2Xi~3)5z^O5u@yVhXEFGX;;W zE?%SH=5>`$^=GH`53H|@e(+aTH2X^gKWOk{!yUxLGZRlO#pIz_LfaoT5vh;2=&il~BG6f;{tdfEP@Dh& literal 3166 zcmb7GO>ERg6drr+UGGmeKbw$E(l#MbU@aMLi@)mEZ_U4&lVDhhD0x7q$fLb{a&ba_Oa_gkCuHJ+HkcA<)*6-@Ng> z_dN6Fec#MaRaGGZ&-Xtzk9P+M`5im%BRb03G$`{#B`T+rESKc6e3Iv|&+ERdkQ8j) zr;AyC(w_|^19o4~rED-6%!ZO7yD#eDY$O@6b-!MfjV7bE9?+|k)jSy{s&t8{K`prG zEB`lHGZRRJ{=iOxXVv|RrA-)gW=Kg{(6H!9YN%5w%jqXL7Cvoi)a~*t;21C|<+wta zaNo(}qnc^;E2hSR(COFH+N1^E0jf=F)YL%ro0eitnIoz4M9PwPI%|7CnI{@aawH`^=5fUP+!(Ten`8che`$)4=oa2Oz057h3Z3x6Xu_|M3 zjogpqtSM~$|WF=+R`;9 z=4d*lB?O8wnJ@(jq&OKC09VW|WJ54DecZ&~w>{PR4~}7$&9SUveX5NO7^$f&8lc{9U8(5!n)tBa$1UK)C&dyxmARhi-m zrpDF07Gl?VJy)yDh=0M1cvWlyW7UrmZ0cQ4ugz@nbXW6c^)GP)FNqs>qj~Lrjw`(+ zZnGE9)x5ZXhv3N5h*N4EdfK#D0O6iCCK*57eG@=`_MAc|Op0itm~@KyW`3ZX^t6_U zGJndZ3g(;8EQ-6w!iou4um(SyQgjwBlZKo!RE>u1;bWttC*_{Kd*u(`XF|q=Ux~V* zs3r>_C;>JUH_!VS#gb0=Xbin2s+l=s5@^buwyY|aVq$f+wY5>)GggnVl3_x!qU$b_ z@;f)d&1QxT5W@Tp#6?nyHO?Qpa%ld@l_RT>*w-UBjxSqxcK5DC4zKz6`p}&8NFu?i zq7*Mk@r8J?siV-;u{2%m>ML~htw`^#Hnz;?ujH@qDz^6&+I#Lc?wgDJCPf_kSFS5p zTW>TLn!1{lkU*!}p|P6ian;od0a& z{CPgTz*!ZPXOQqVJjkqoE&qnk(4F8^-?u&wVOG$!QH5FFt2jVN1>vp*V73G?W}Jz7O*O)emRz{3L-O`U?_t%x#3Z{rEnz! z!VBgkWM13g23?hNSH>alY_=95)3%AN_GtQ}Y`6vL#gKd>_=BG7N zPOJIw06?eB1juzCq_|#+OhR$Jv;{=IM#<&$G&lhvbRksXj1&-WEaG5Qwq|m0Ik5kc zsHIpwbQ=gJs#DpV$@sKtAE$t7TsRYQhFRtb+J?4UQP{jtddnt=k%Yt~S)Np~nk=)B zEN9_@qoW>?Wn}R32t_>GJ4lfp=`Iv+fVfHQFgEW}gt0AfLrtuuOXQcTEuVjKap6XvVw zrd=y`F|Zh%5SBbnVMXT*dbSgHoZ?l(UIPoO8D(<9=$xY9WuI5k^$vD5+BIBW&)evV zTxzfJsnlD}&^z=fe8WqQiIw-r$8p>Pa`-;k`GD+sK;FDhTJMvszmo71X%BZ`q2+G^ HjUDG7exs~A diff --git a/product/tests/tests_viewsets/test_product_viewset.py b/product/tests/tests_viewsets/test_product_viewset.py index e486ebc..3fce81e 100644 --- a/product/tests/tests_viewsets/test_product_viewset.py +++ b/product/tests/tests_viewsets/test_product_viewset.py @@ -1,6 +1,7 @@ from product.factories import CategoryFactory, ProductFactory from order.factories import UserFactory -from product.models import Product, category +from rest_framework.authtoken.models import Token +from product.models import Product from rest_framework.test import APITestCase, APIClient from django.urls import reverse from rest_framework import status @@ -8,10 +9,11 @@ class TestProductViewSet(APITestCase): - client = APIClient() def setUp(self): + self.client = APIClient() self.user = UserFactory() + self.token = Token.objects.create(user=self.user) self.product = ProductFactory( title="pro controller", @@ -19,22 +21,29 @@ def setUp(self): ) def test_get_all_product(self): + token = Token.objects.get(user__username=self.user.username) + self.client.credentials( + HTTP_AUTHORIZATION="Token " + token.key) response = self.client.get(reverse("product-list", kwargs={"version": "v1"})) self.assertEqual(response.status_code, status.HTTP_200_OK) product_data = json.loads(response.content) - self.assertEqual(product_data[0]["title"], self.product.title) - self.assertEqual(product_data[0]["price"], self.product.price) - self.assertEqual(product_data[0]["active"], self.product.active) + self.assertEqual(product_data["results"][0]["title"], self.product.title) + self.assertEqual(product_data["results"][0]["price"], self.product.price) + self.assertEqual(product_data["results"][0]["active"], self.product.active) def test_create_product(self): + token = Token.objects.get(user__username=self.user.username) + self.client.credentials(HTTP_AUTHORIZATION="Token " + token.key) + category = CategoryFactory() data = json.dumps( {"title": "notebook", "price": 800.00, "categories_id": [category.id]} ) print("Data sent1:", data) + response = self.client.post( reverse("product-list", kwargs={"version": "v1"}), data=data, diff --git a/product/viewsets/__pycache__/__init__.cpython-312.pyc b/product/viewsets/__pycache__/__init__.cpython-312.pyc index 9f51a459406740012f33f6619dbfc2a0bd5e8087..bd4047dd92d894ea9e91e8072d799fcc3a590469 100644 GIT binary patch delta 28 hcmaFP_?(gZG%qg~0}zBo+fL-Z!f}s5yNC_Q1psb*2C@JE delta 28 hcmaFP_?(gZG%qg~0}vcKDK(M%3db`B?IJcH7XW!p2XO!Z diff --git a/product/viewsets/__pycache__/product_viewset.cpython-312.pyc b/product/viewsets/__pycache__/product_viewset.cpython-312.pyc index 0abb20bdd6286b95b45ae4c3b211d0bb9b610406..a4007ca51690afd48758a5816543e23aa5098f22 100644 GIT binary patch delta 584 zcmZ8dO=}cE5UrY?uLQFbgY2pV)F?3{i3Acni4yPw1s7q(Llamg+Z{7YPbPHF5|V@K zVK0K9VTAkzb$^N=8*QAOsBl3GTr+%dmT-Sw&Apfec(Wm0kt@J zfz;*>bs2VmdU*}6jGJBN4OjD*c=tim)BHbU*!?rH2BB3gteAzibhN7Q(zPaUWU3&M z5QU#g#$|nNC-39?`O8}H3XX&F+xF{rKbScPW)6dE{b1oBSopvWgQcFoG&HNKp`X98 z!gevW#bpvJ6{nl^hKQ8nO1fH5Oe!wpNW{B(`lui$b^0U7v)akPfd3c9G*M*@9XPre z_AcD$+2y0kT+co?w9#2UZ87RN7!sAlABn`c=%J}JrF}r5-QrAFvRv@M z#gpFn8w`Jnml6+>M&iMfHlmnOK`?BSDt*a-vyQ!w$f*lA>h=I3Hi&vW17(e#$Tf zYnkwb Date: Sun, 19 May 2024 19:45:15 -0300 Subject: [PATCH 30/42] Configurando build para github actions --- .github/workflows/build.yml | 35 ++++++++++++++++++ .github/workflows/github-actions-demo.yml | 2 +- .../__pycache__/settings.cpython-312.pyc | Bin 3752 -> 4012 bytes bookstore/settings.py | 8 ++-- docker-compose.yml | 2 +- requirements.txt | 8 ++++ 6 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4dfaf32 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,35 @@ +on: [push] + +jobs: + build: + strategy: + fail-fast: false + matrix: + python-version: [3.8, 3.9] + poetry-version: [1.1.4] + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install poetry ${{ matrix.poetry-version }} + run: | + python -m ensurepip + python -m pip install --upgrade pip + python -m pip install poetry==${{ matrix.poetry-version }} + - name: View poetry --help + run: poetry --help + + - name: Install dependencies + shell: bash + run: python -m poetry install + + - name: Test + run: | + poetry run python manage.py test \ No newline at end of file diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index deddd0b..2af4ce3 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -8,7 +8,7 @@ jobs: - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - name: Check out repository code - uses: actions/checkout@v4 + uses: actions/checkout@v2 - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - run: echo "🖥️ The workflow is now ready to test your code on the runner." - name: List files in the repository diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index 196472f42e80e6d130e222544f39becc3da18e50..9366d0b57cac8867059f21163423e6ee530ca620 100644 GIT binary patch delta 751 zcmZ1>yGEY(G%qg~0}%Y*>7MpxBCjNq9P>ntlAsjUD9&_-D6Vvd6t+c-QQSb99Z2(} za76K@0A*5GQ$TXuix@K*Q+VdEq%%hGrSL}ar|_jRW+{LSL?d_Ax%Cr~DetCC4mfAbEeRz}8<&9*G3m^O2;+p(B%1-m*2 zxrW4hyGGt(b#ZkHb=PDp;sa{9CF0`c=;!Vq@95*>AMWZB@8KUD68wu%K~sKmD7S-T zkqS^zkt#?fFN%`M3%NhD-(oE;$jL03Jd-Di%N?i&6hg%hC;#QK<@>MFE=~!IuRb8+nUdfz|;4s7;3K delta 495 zcmZ1@ze1MxG%qg~0}vE%cS`#*kynzbhiRfliB~#93hN@qC{7^F2Bf)C*rT{pIDkCP z6fPjiy@)ZBF@6wO8 z<_u05CMMN-ffSh(S)h|;Qsls-JeX9-WK3s?5=>Ey5=v2u5>DZa5&>dSAQnqejuKB% ziIPZBO;H1SSbY&=ipCt~D9IE}pqHhX7*eHic^EYSK)e(!sT9UF+N+r$QmYvubd*db zlcvsQFXmRp%@J;j($yme(RHrFBnTN-L=N4D6t8D8>^V%|f64}hh=f%kSk%xhkXL3Hj7<(gYkt0wZ E09(6K%m4rY diff --git a/bookstore/settings.py b/bookstore/settings.py index edf8831..859ec10 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -24,9 +24,9 @@ SECRET_KEY = "django-insecure-f*k@=53bc5!shef1-6w+m$-g)kspbaljz%8k4(j7iuc-u2_dyd" # SECURITY WARNING: don't run with debug turned on in production! -# DEBUG = True +DEBUG = True -# ALLOWED_HOSTS = [] +ALLOWED_HOSTS = [] # Application definition @@ -150,10 +150,10 @@ "127.0.0.1", ] -# SECRET_KEY = os.environ.get("SECRET_KEY") +SECRET_KEY = os.environ.get("SECRET_KEY") DEBUG = int(os.environ.get("DEBUG", default=0)) # 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each. # For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]' -# ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") \ No newline at end of file +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 82b27c8..6945003 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - - .:/usr/src/app/ + - app_data:/usr/src/app/ ports: - 8000:8000 env_file: diff --git a/requirements.txt b/requirements.txt index 8f52593..dc60196 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,16 +8,22 @@ colorama==0.4.6 crashtest==0.4.1 distlib==0.3.8 Django==5.0.3 +django-debug-toolbar==4.3.0 +django-extensions==3.2.3 +django-rest-framework==0.1.0 +djangorestframework==3.15.1 dulwich==0.21.7 factory-boy==3.3.0 Faker==24.0.0 fastjsonschema==2.19.1 filelock==3.14.0 +flake8==7.0.0 idna==3.7 iniconfig==2.0.0 installer==0.7.0 jaraco.classes==3.4.0 keyring==24.3.1 +mccabe==0.7.0 more-itertools==10.2.0 msgpack==1.0.8 packaging==23.2 @@ -30,6 +36,8 @@ poetry-core==1.9.0 poetry-plugin-export==1.7.1 psycopg2==2.9.9 ptyprocess==0.7.0 +pycodestyle==2.11.1 +pyflakes==3.2.0 pyproject_hooks==1.1.0 pytest==8.0.2 python-dateutil==2.9.0.post0 From d525c71a87a5e8182aafb638ffce64449eb44222 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:15:03 -0300 Subject: [PATCH 31/42] Ajustando build para github actions --- .github/workflows/build.yml | 8 +++++--- .../__pycache__/settings.cpython-312.pyc | Bin 4012 -> 4012 bytes bookstore/settings.py | 2 +- docker-compose.yml | 3 ++- .../tests_viewsets/test_product_viewset.py | 9 ++++----- product/viewsets/product_viewset.py | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4dfaf32..e276b29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,15 @@ +name: Python application + on: [push] -jobs: +jobs: build: strategy: fail-fast: false matrix: python-version: [3.8, 3.9] poetry-version: [1.1.4] - + runs-on: ubuntu-latest steps: @@ -17,7 +19,7 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - + - name: Install poetry ${{ matrix.poetry-version }} run: | python -m ensurepip diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index 9366d0b57cac8867059f21163423e6ee530ca620..5db735e5c84c69bb61daa03fb6150d2a1276973a 100644 GIT binary patch delta 22 ccmZ1@zeb+-G%qg~0}$A@dZoSF$UC1O07X9rUjP6A delta 22 ccmZ1@zeb+-G%qg~0}%Y*>7MpxBkz2E08NqyPyhe` diff --git a/bookstore/settings.py b/bookstore/settings.py index 859ec10..c746d5e 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -156,4 +156,4 @@ # 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each. # For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]' -ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") \ No newline at end of file +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") diff --git a/docker-compose.yml b/docker-compose.yml index 6945003..b1dbbcc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,4 +24,5 @@ services: - db volumes: - postgres_data: \ No newline at end of file + postgres_data: + app_data: \ No newline at end of file diff --git a/product/tests/tests_viewsets/test_product_viewset.py b/product/tests/tests_viewsets/test_product_viewset.py index 3fce81e..a943941 100644 --- a/product/tests/tests_viewsets/test_product_viewset.py +++ b/product/tests/tests_viewsets/test_product_viewset.py @@ -13,7 +13,7 @@ class TestProductViewSet(APITestCase): def setUp(self): self.client = APIClient() self.user = UserFactory() - self.token = Token.objects.create(user=self.user) + self.token = Token.objects.create(user=self.user) self.product = ProductFactory( title="pro controller", @@ -21,9 +21,8 @@ def setUp(self): ) def test_get_all_product(self): - token = Token.objects.get(user__username=self.user.username) - self.client.credentials( - HTTP_AUTHORIZATION="Token " + token.key) + token = Token.objects.get(user__username=self.user.username) + self.client.credentials(HTTP_AUTHORIZATION="Token " + token.key) response = self.client.get(reverse("product-list", kwargs={"version": "v1"})) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -43,7 +42,7 @@ def test_create_product(self): ) print("Data sent1:", data) - + response = self.client.post( reverse("product-list", kwargs={"version": "v1"}), data=data, diff --git a/product/viewsets/product_viewset.py b/product/viewsets/product_viewset.py index 3da4e56..7d62539 100644 --- a/product/viewsets/product_viewset.py +++ b/product/viewsets/product_viewset.py @@ -11,4 +11,4 @@ class ProductViewSet(ModelViewSet): serializer_class = ProductSerializer def get_queryset(self): - return Product.objects.all().order_by('id') + return Product.objects.all().order_by("id") From a3ec9827ad317cf4c7c1e0cf7784fd89e460c1ea Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:18:25 -0300 Subject: [PATCH 32/42] =?UTF-8?q?=20Github=20Actions=20-=20Atualizando=20p?= =?UTF-8?q?oetry=20para=20corrigir=20importa=C3=A7=C3=A3o\?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index df0ccec..512fcff 100644 --- a/poetry.lock +++ b/poetry.lock @@ -121,13 +121,13 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"] [[package]] name = "faker" -version = "25.1.0" +version = "25.2.0" description = "Faker is a Python package that generates fake data for you." optional = false python-versions = ">=3.8" files = [ - {file = "Faker-25.1.0-py3-none-any.whl", hash = "sha256:24e28dce0b89683bb9e017e042b971c8c4909cff551b6d46f1e207674c7c2526"}, - {file = "Faker-25.1.0.tar.gz", hash = "sha256:2107618cf306bb188dcfea3e5cfd94aa92d65c7293a2437c1e96a99c83274755"}, + {file = "Faker-25.2.0-py3-none-any.whl", hash = "sha256:cfe97c4857c4c36ee32ea4aaabef884895992e209bae4cbd26807cf3e05c6918"}, + {file = "Faker-25.2.0.tar.gz", hash = "sha256:45b84f47ff1ef86e3d1a8d11583ca871ecf6730fad0660edadc02576583a2423"}, ] [package.dependencies] @@ -302,13 +302,13 @@ files = [ [[package]] name = "pytest" -version = "8.2.0" +version = "8.2.1" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.2.0-py3-none-any.whl", hash = "sha256:1733f0620f6cda4095bbf0d9ff8022486e91892245bb9e7d5542c018f612f233"}, - {file = "pytest-8.2.0.tar.gz", hash = "sha256:d507d4482197eac0ba2bae2e9babf0672eb333017bcedaa5fb1a3d42c1174b3f"}, + {file = "pytest-8.2.1-py3-none-any.whl", hash = "sha256:faccc5d332b8c3719f40283d0d44aa5cf101cec36f88cde9ed8f2bc0538612b1"}, + {file = "pytest-8.2.1.tar.gz", hash = "sha256:5046e5b46d8e4cac199c373041f26be56fdb81eb4e67dc11d4e10811fc3408fd"}, ] [package.dependencies] From 1a4c9f4d113d187e1ea3aa71089d841171082e89 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:21:39 -0300 Subject: [PATCH 33/42] =?UTF-8?q?Github=20Actions=20-=20Teste=20de=20alter?= =?UTF-8?q?a=C3=A7=C3=A3o=20de=20vers=C3=A3o=20do=20poetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e276b29..cd272c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,7 @@ jobs: - name: Install poetry ${{ matrix.poetry-version }} run: | + curl -sSL https://install.python-poetry.org | python3 - python -m ensurepip python -m pip install --upgrade pip python -m pip install poetry==${{ matrix.poetry-version }} From 9266ee0a261aab29d3b9200b23579168fdc6a980 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:24:11 -0300 Subject: [PATCH 34/42] =?UTF-8?q?Github=20Actions=20-=20Teste=20de=20alter?= =?UTF-8?q?a=C3=A7=C3=A3o=20de=20vers=C3=A3o=20do=20poetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd272c5..3adad89 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,12 +23,15 @@ jobs: - name: Install poetry ${{ matrix.poetry-version }} run: | curl -sSL https://install.python-poetry.org | python3 - - python -m ensurepip - python -m pip install --upgrade pip - python -m pip install poetry==${{ matrix.poetry-version }} + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: View poetry --help run: poetry --help + - name: Clear Poetry Cache + run: poetry cache clear --all pypi + - name: Install dependencies shell: bash run: python -m poetry install From b0827da65303c9942db0ea832896d926bf69d516 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:25:32 -0300 Subject: [PATCH 35/42] =?UTF-8?q?Github=20Actions=20-=20Teste=20de=20alter?= =?UTF-8?q?a=C3=A7=C3=A3o=20de=20vers=C3=A3o=20do=20poetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3adad89..0cfe571 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,9 +29,6 @@ jobs: - name: View poetry --help run: poetry --help - - name: Clear Poetry Cache - run: poetry cache clear --all pypi - - name: Install dependencies shell: bash run: python -m poetry install From 809702236a897f434e99c5bb98b03a7f2f425235 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:28:04 -0300 Subject: [PATCH 36/42] =?UTF-8?q?Github=20Actions=20-=20Teste=20de=20alter?= =?UTF-8?q?a=C3=A7=C3=A3o=20de=20vers=C3=A3o=20do=20poetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cfe571..5ef76aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,8 +30,7 @@ jobs: run: poetry --help - name: Install dependencies - shell: bash - run: python -m poetry install + run: poetry install - name: Test run: | From 2606d6dff2e16fc9fddf5c9e87223fb14deed201 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:30:01 -0300 Subject: [PATCH 37/42] =?UTF-8?q?Github=20Actions=20-=20Teste=20de=20alter?= =?UTF-8?q?a=C3=A7=C3=A3o=20de=20vers=C3=A3o=20do=20poetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c2207b9..dfecbb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = ["matheus-dev-fullstack "] readme = "README.md" [tool.poetry.dependencies] -python = "^3.12" +python = "^3.8" pytest = "^8.0.2" psycopg2-binary = "*" factory-boy = "^3.3.0" From e6858b8ea24bef1f48423f4c0ee24743ba742aac Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:36:00 -0300 Subject: [PATCH 38/42] =?UTF-8?q?Github=20Actions=20-=20Alterando=20vers?= =?UTF-8?q?=C3=A3o=20das=20dependencias=20no=20pyproject.toml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 327 ++++++++++++++++++++++++++++++++++++++----------- pyproject.toml | 27 ++-- 2 files changed, 272 insertions(+), 82 deletions(-) diff --git a/poetry.lock b/poetry.lock index 512fcff..9a59f72 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,18 +2,96 @@ [[package]] name = "asgiref" -version = "3.8.1" +version = "3.7.2" description = "ASGI specs, helper code, and adapters" optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "asgiref-3.8.1-py3-none-any.whl", hash = "sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47"}, - {file = "asgiref-3.8.1.tar.gz", hash = "sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590"}, + {file = "asgiref-3.7.2-py3-none-any.whl", hash = "sha256:89b2ef2247e3b562a16eef663bc0e2e703ec6468e2fa8a5cd61cd449786d4f6e"}, + {file = "asgiref-3.7.2.tar.gz", hash = "sha256:9e0ce3aa93a819ba5b45120216b23878cf6e8525eb3848653452b4192b92afed"}, ] +[package.dependencies] +typing-extensions = {version = ">=4", markers = "python_version < \"3.11\""} + [package.extras] tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] +[[package]] +name = "atomicwrites" +version = "1.4.1" +description = "Atomic file writes." +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, +] + +[[package]] +name = "attrs" +version = "23.2.0" +description = "Classes Without Boilerplate" +optional = false +python-versions = ">=3.7" +files = [ + {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, + {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, +] + +[package.dependencies] +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} + +[package.extras] +cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] +dev = ["attrs[tests]", "pre-commit"] +docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] +tests = ["attrs[tests-no-zope]", "zope-interface"] +tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] +tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] + +[[package]] +name = "autopep8" +version = "1.7.0" +description = "A tool that automatically formats Python code to conform to the PEP 8 style guide" +optional = false +python-versions = "*" +files = [ + {file = "autopep8-1.7.0-py2.py3-none-any.whl", hash = "sha256:6f09e90a2be784317e84dc1add17ebfc7abe3924239957a37e5040e27d812087"}, + {file = "autopep8-1.7.0.tar.gz", hash = "sha256:ca9b1a83e53a7fad65d731dc7a2a2d50aa48f43850407c59f6a1a306c4201142"}, +] + +[package.dependencies] +pycodestyle = ">=2.9.1" +toml = "*" + +[[package]] +name = "backports-zoneinfo" +version = "0.2.1" +description = "Backport of the standard library zoneinfo module" +optional = false +python-versions = ">=3.6" +files = [ + {file = "backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:da6013fd84a690242c310d77ddb8441a559e9cb3d3d59ebac9aca1a57b2e18bc"}, + {file = "backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:89a48c0d158a3cc3f654da4c2de1ceba85263fafb861b98b59040a5086259722"}, + {file = "backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:1c5742112073a563c81f786e77514969acb58649bcdf6cdf0b4ed31a348d4546"}, + {file = "backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl", hash = "sha256:e8236383a20872c0cdf5a62b554b27538db7fa1bbec52429d8d106effbaeca08"}, + {file = "backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl", hash = "sha256:8439c030a11780786a2002261569bdf362264f605dfa4d65090b64b05c9f79a7"}, + {file = "backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:f04e857b59d9d1ccc39ce2da1021d196e47234873820cbeaad210724b1ee28ac"}, + {file = "backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf"}, + {file = "backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5c144945a7752ca544b4b78c8c41544cdfaf9786f25fe5ffb10e838e19a27570"}, + {file = "backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl", hash = "sha256:e55b384612d93be96506932a786bbcde5a2db7a9e6a4bb4bffe8b733f5b9036b"}, + {file = "backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a76b38c52400b762e48131494ba26be363491ac4f9a04c1b7e92483d169f6582"}, + {file = "backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:8961c0f32cd0336fb8e8ead11a1f8cd99ec07145ec2931122faaac1c8f7fd987"}, + {file = "backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e81b76cace8eda1fca50e345242ba977f9be6ae3945af8d46326d776b4cf78d1"}, + {file = "backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9"}, + {file = "backports.zoneinfo-0.2.1-cp38-cp38-win32.whl", hash = "sha256:1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328"}, + {file = "backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl", hash = "sha256:4a0f800587060bf8880f954dbef70de6c11bbe59c673c3d818921f042f9954a6"}, + {file = "backports.zoneinfo-0.2.1.tar.gz", hash = "sha256:fadbfe37f74051d024037f223b8e001611eac868b5c5b06144ef4d8b799862f2"}, +] + +[package.extras] +tzdata = ["tzdata"] + [[package]] name = "colorama" version = "0.4.6" @@ -27,19 +105,19 @@ files = [ [[package]] name = "django" -version = "5.0.6" -description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." +version = "3.2.25" +description = "A high-level Python Web framework that encourages rapid development and clean, pragmatic design." optional = false -python-versions = ">=3.10" +python-versions = ">=3.6" files = [ - {file = "Django-5.0.6-py3-none-any.whl", hash = "sha256:8363ac062bb4ef7c3f12d078f6fa5d154031d129a15170a1066412af49d30905"}, - {file = "Django-5.0.6.tar.gz", hash = "sha256:ff1b61005004e476e0aeea47c7f79b85864c70124030e95146315396f1e7951f"}, + {file = "Django-3.2.25-py3-none-any.whl", hash = "sha256:a52ea7fcf280b16f7b739cec38fa6d3f8953a5456986944c3ca97e79882b4e38"}, + {file = "Django-3.2.25.tar.gz", hash = "sha256:7ca38a78654aee72378594d63e51636c04b8e28574f5505dff630895b5472777"}, ] [package.dependencies] -asgiref = ">=3.7.0,<4" -sqlparse = ">=0.3.1" -tzdata = {version = "*", markers = "sys_platform == \"win32\""} +asgiref = ">=3.3.2,<4" +pytz = "*" +sqlparse = ">=0.2.2" [package.extras] argon2 = ["argon2-cffi (>=19.1.0)"] @@ -47,13 +125,13 @@ bcrypt = ["bcrypt"] [[package]] name = "django-debug-toolbar" -version = "4.3.0" +version = "3.8.1" description = "A configurable set of panels that display various debug information about the current request/response." optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "django_debug_toolbar-4.3.0-py3-none-any.whl", hash = "sha256:e09b7dcb8417b743234dfc57c95a7c1d1d87a88844abd13b4c5387f807b31bf6"}, - {file = "django_debug_toolbar-4.3.0.tar.gz", hash = "sha256:0b0dddee5ea29b9cb678593bc0d7a6d76b21d7799cb68e091a2148341a80f3c4"}, + {file = "django_debug_toolbar-3.8.1-py3-none-any.whl", hash = "sha256:879f8a4672d41621c06a4d322dcffa630fc4df056cada6e417ed01db0e5e0478"}, + {file = "django_debug_toolbar-3.8.1.tar.gz", hash = "sha256:24ef1a7d44d25e60d7951e378454c6509bf536dce7e7d9d36e7c387db499bc27"}, ] [package.dependencies] @@ -99,6 +177,7 @@ files = [ ] [package.dependencies] +"backports.zoneinfo" = {version = "*", markers = "python_version < \"3.9\""} django = ">=3.0" [[package]] @@ -114,6 +193,7 @@ files = [ [package.dependencies] Faker = ">=0.7.0" +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [package.extras] dev = ["Django", "Pillow", "SQLAlchemy", "coverage", "flake8", "isort", "mongoengine", "sqlalchemy-utils", "tox", "wheel (>=0.32.0)", "zest.releaser[recommended]"] @@ -121,33 +201,58 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"] [[package]] name = "faker" -version = "25.2.0" +version = "18.13.0" description = "Faker is a Python package that generates fake data for you." optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "Faker-25.2.0-py3-none-any.whl", hash = "sha256:cfe97c4857c4c36ee32ea4aaabef884895992e209bae4cbd26807cf3e05c6918"}, - {file = "Faker-25.2.0.tar.gz", hash = "sha256:45b84f47ff1ef86e3d1a8d11583ca871ecf6730fad0660edadc02576583a2423"}, + {file = "Faker-18.13.0-py3-none-any.whl", hash = "sha256:801d1a2d71f1fc54d332de2ab19de7452454309937233ea2f7485402882d67b3"}, + {file = "Faker-18.13.0.tar.gz", hash = "sha256:84bcf92bb725dd7341336eea4685df9a364f16f2470c4d29c1d7e6c5fd5a457d"}, ] [package.dependencies] python-dateutil = ">=2.4" +typing-extensions = {version = ">=3.10.0.1", markers = "python_version < \"3.8\""} + +[[package]] +name = "gunicorn" +version = "20.1.0" +description = "WSGI HTTP Server for UNIX" +optional = false +python-versions = ">=3.5" +files = [ + {file = "gunicorn-20.1.0-py3-none-any.whl", hash = "sha256:9dcc4547dbb1cb284accfb15ab5667a0e5d1881cc443e0677b4882a4067a807e"}, + {file = "gunicorn-20.1.0.tar.gz", hash = "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"}, +] + +[package.dependencies] +setuptools = ">=3.0" + +[package.extras] +eventlet = ["eventlet (>=0.24.1)"] +gevent = ["gevent (>=1.4.0)"] +setproctitle = ["setproctitle"] +tornado = ["tornado (>=0.2)"] [[package]] -name = "flake8" -version = "7.0.0" -description = "the modular source code checker: pep8 pyflakes and co" +name = "importlib-metadata" +version = "6.7.0" +description = "Read metadata from Python packages" optional = false -python-versions = ">=3.8.1" +python-versions = ">=3.7" files = [ - {file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"}, - {file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"}, + {file = "importlib_metadata-6.7.0-py3-none-any.whl", hash = "sha256:cb52082e659e97afc5dac71e79de97d8681de3aa07ff18578330904a9d18e5b5"}, + {file = "importlib_metadata-6.7.0.tar.gz", hash = "sha256:1aaf550d4f73e5d6783e7acb77aec43d49da8017410afae93822cc9cca98c4d4"}, ] [package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.11.0,<2.12.0" -pyflakes = ">=3.2.0,<3.3.0" +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] [[package]] name = "iniconfig" @@ -161,16 +266,22 @@ files = [ ] [[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" +name = "isort" +version = "5.11.5" +description = "A Python utility / library to sort Python imports." optional = false -python-versions = ">=3.6" +python-versions = ">=3.7.0" files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, + {file = "isort-5.11.5-py3-none-any.whl", hash = "sha256:ba1d72fb2595a01c7895a5128f9585a5cc4b6d395f1c8d514989b9a7eb2a8746"}, + {file = "isort-5.11.5.tar.gz", hash = "sha256:6be1f76a507cb2ecf16c7cf14a37e41609ca082330be4e3436a18ef74add55db"}, ] +[package.extras] +colors = ["colorama (>=0.4.3,<0.5.0)"] +pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] +plugins = ["setuptools"] +requirements-deprecated-finder = ["pip-api", "pipreqs"] + [[package]] name = "packaging" version = "24.0" @@ -184,15 +295,18 @@ files = [ [[package]] name = "pluggy" -version = "1.5.0" +version = "1.2.0" description = "plugin and hook calling mechanisms for python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, - {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, + {file = "pluggy-1.2.0-py3-none-any.whl", hash = "sha256:c2fd55a7d7a3863cba1a013e4e2414658b1d07b6bc57b3919e0c63c9abb99849"}, + {file = "pluggy-1.2.0.tar.gz", hash = "sha256:d12f0c4b579b15f5e054301bb226ee85eeeba08ffec228092f8defbaa3a4c4b3"}, ] +[package.dependencies] +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} + [package.extras] dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] @@ -279,46 +393,51 @@ files = [ ] [[package]] -name = "pycodestyle" -version = "2.11.1" -description = "Python style guide checker" +name = "py" +version = "1.11.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" optional = false -python-versions = ">=3.8" +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" files = [ - {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, - {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] [[package]] -name = "pyflakes" -version = "3.2.0" -description = "passive checker of Python programs" +name = "pycodestyle" +version = "2.10.0" +description = "Python style guide checker" optional = false -python-versions = ">=3.8" +python-versions = ">=3.6" files = [ - {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, - {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, + {file = "pycodestyle-2.10.0-py2.py3-none-any.whl", hash = "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610"}, + {file = "pycodestyle-2.10.0.tar.gz", hash = "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053"}, ] [[package]] name = "pytest" -version = "8.2.1" +version = "6.2.5" description = "pytest: simple powerful testing with Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.6" files = [ - {file = "pytest-8.2.1-py3-none-any.whl", hash = "sha256:faccc5d332b8c3719f40283d0d44aa5cf101cec36f88cde9ed8f2bc0538612b1"}, - {file = "pytest-8.2.1.tar.gz", hash = "sha256:5046e5b46d8e4cac199c373041f26be56fdb81eb4e67dc11d4e10811fc3408fd"}, + {file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"}, + {file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"}, ] [package.dependencies] +atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} +attrs = ">=19.2.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} iniconfig = "*" packaging = "*" -pluggy = ">=1.5,<2.0" +pluggy = ">=0.12,<2.0" +py = ">=1.8.2" +toml = "*" [package.extras] -dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] [[package]] name = "python-dateutil" @@ -334,6 +453,33 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "pytz" +version = "2024.1" +description = "World timezone definitions, modern and historical" +optional = false +python-versions = "*" +files = [ + {file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"}, + {file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"}, +] + +[[package]] +name = "setuptools" +version = "68.0.0" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +optional = false +python-versions = ">=3.7" +files = [ + {file = "setuptools-68.0.0-py3-none-any.whl", hash = "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f"}, + {file = "setuptools-68.0.0.tar.gz", hash = "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + [[package]] name = "six" version = "1.16.0" @@ -347,31 +493,72 @@ files = [ [[package]] name = "sqlparse" -version = "0.5.0" +version = "0.4.4" description = "A non-validating SQL parser." optional = false -python-versions = ">=3.8" +python-versions = ">=3.5" files = [ - {file = "sqlparse-0.5.0-py3-none-any.whl", hash = "sha256:c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663"}, - {file = "sqlparse-0.5.0.tar.gz", hash = "sha256:714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93"}, + {file = "sqlparse-0.4.4-py3-none-any.whl", hash = "sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3"}, + {file = "sqlparse-0.4.4.tar.gz", hash = "sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c"}, ] [package.extras] -dev = ["build", "hatch"] +dev = ["build", "flake8"] doc = ["sphinx"] +test = ["pytest", "pytest-cov"] [[package]] -name = "tzdata" -version = "2024.1" -description = "Provider of IANA time zone data" +name = "toml" +version = "0.10.2" +description = "Python Library for Tom's Obvious, Minimal Language" optional = false -python-versions = ">=2" +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" files = [ - {file = "tzdata-2024.1-py2.py3-none-any.whl", hash = "sha256:9068bc196136463f5245e51efda838afa15aaeca9903f49050dfa2679db4d252"}, - {file = "tzdata-2024.1.tar.gz", hash = "sha256:2674120f8d891909751c38abcdfd386ac0a5a1127954fbc332af6b5ceae07efd"}, + {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, + {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] +[[package]] +name = "typing-extensions" +version = "4.7.1" +description = "Backported and Experimental Type Hints for Python 3.7+" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, + {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, +] + +[[package]] +name = "whitenoise" +version = "5.3.0" +description = "Radically simplified static file serving for WSGI applications" +optional = false +python-versions = ">=3.5, <4" +files = [ + {file = "whitenoise-5.3.0-py2.py3-none-any.whl", hash = "sha256:d963ef25639d1417e8a247be36e6aedd8c7c6f0a08adcb5a89146980a96b577c"}, + {file = "whitenoise-5.3.0.tar.gz", hash = "sha256:d234b871b52271ae7ed6d9da47ffe857c76568f11dd30e28e18c5869dbd11e12"}, +] + +[package.extras] +brotli = ["Brotli"] + +[[package]] +name = "zipp" +version = "3.15.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +optional = false +python-versions = ">=3.7" +files = [ + {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, + {file = "zipp-3.15.0.tar.gz", hash = "sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + [metadata] lock-version = "2.0" -python-versions = "^3.12" -content-hash = "4e6e0fdefbb923f51712ef536efdc91fb2d5aa948e2d3aa4f41d79bdb27a4104" +python-versions = "^3.7" +content-hash = "3d24a74ddb066994975c85b456e5889359e72bfa95d271ccd733f12dee92b275" diff --git a/pyproject.toml b/pyproject.toml index dfecbb6..a0486e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,21 +2,24 @@ name = "bookstore" version = "0.1.0" description = "Bookstore API" -authors = ["matheus-dev-fullstack "] -readme = "README.md" +authors = ["Daniel Santos "] [tool.poetry.dependencies] -python = "^3.8" -pytest = "^8.0.2" -psycopg2-binary = "*" -factory-boy = "^3.3.0" -django = "^5.0.3" +python = "^3.7" +Django = "^3.2.8" django-rest-framework = "^0.1.0" -django-extensions = "^3.2.3" -django-debug-toolbar = "^4.3.0" -flake8 = "^7.0.0" +django-extensions = "^3.1.3" +django-debug-toolbar = "^3.2.2" +psycopg2-binary = "^2.9.2" +autopep8 = "^1.6.0" +isort = "^5.10.1" +whitenoise = "^5.3.0" +gunicorn = "^20.1.0" +[tool.poetry.dev-dependencies] +pytest = "^6.2.5" +factory-boy = "^3.2.0" [build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" \ No newline at end of file From 2e57690b2a5b93f612dcbca7c19fd75c2a2f0975 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 20:41:17 -0300 Subject: [PATCH 39/42] Congiurando ALLOWED_HOSTS em settings.py --- bookstore/settings.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bookstore/settings.py b/bookstore/settings.py index c746d5e..eb446c5 100644 --- a/bookstore/settings.py +++ b/bookstore/settings.py @@ -150,10 +150,12 @@ "127.0.0.1", ] -SECRET_KEY = os.environ.get("SECRET_KEY") +# SECRET_KEY = os.environ.get("SECRET_KEY") -DEBUG = int(os.environ.get("DEBUG", default=0)) +# DEBUG = int(os.environ.get("DEBUG", default=0)) # 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each. # For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]' -ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") +# ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") + +ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'ebac-bookstore-api.herokuapp.com'] \ No newline at end of file From 976aed25a1f03cd1cc611963bd7c8fe252950e4e Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Sun, 19 May 2024 21:56:56 -0300 Subject: [PATCH 40/42] Corrigindo Viewsets, e testes --- .../__pycache__/settings.cpython-312.pyc | Bin 4012 -> 3733 bytes bookstore/__pycache__/urls.cpython-312.pyc | Bin 1477 -> 1477 bytes order/__pycache__/admin.cpython-312.pyc | Bin 251 -> 251 bytes order/__pycache__/factories.cpython-312.pyc | Bin 1747 -> 1738 bytes order/__pycache__/urls.cpython-312.pyc | Bin 604 -> 604 bytes order/factories.py | 9 ++-- .../__pycache__/0001_initial.cpython-312.pyc | Bin 1400 -> 1400 bytes .../0002_alter_order_user.cpython-312.pyc | Bin 1134 -> 1134 bytes .../0003_alter_order_user.cpython-312.pyc | Bin 1118 -> 1118 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 208 -> 208 bytes .../models/__pycache__/order.cpython-312.pyc | Bin 758 -> 758 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 234 -> 234 bytes .../order_serializer.cpython-312.pyc | Bin 2150 -> 2154 bytes order/serializers/order_serializer.py | 2 +- .../__pycache__/__init__.cpython-312.pyc | Bin 169 -> 169 bytes order/tests/test_serializers/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 206 bytes .../test_order_serializer.cpython-312.pyc | Bin 0 -> 1617 bytes .../test_serializers/test_order_serializer.py | 20 +++++++++ .../__pycache__/__init__.cpython-312.pyc | Bin 183 -> 183 bytes .../test_order_viewset.cpython-312.pyc | Bin 3452 -> 3491 bytes .../tests/test_viewsets/test_order_viewset.py | 14 +++--- .../__pycache__/__init__.cpython-312.pyc | Bin 225 -> 225 bytes .../__pycache__/order_viewset.cpython-312.pyc | Bin 651 -> 706 bytes order/viewsets/order_viewset.py | 2 +- product/__pycache__/admin.cpython-312.pyc | Bin 277 -> 277 bytes product/__pycache__/factories.cpython-312.pyc | Bin 1939 -> 1939 bytes product/__pycache__/urls.cpython-312.pyc | Bin 610 -> 721 bytes .../__pycache__/0001_initial.cpython-312.pyc | Bin 1777 -> 1777 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 256 -> 256 bytes .../__pycache__/category.cpython-312.pyc | Bin 951 -> 951 bytes .../__pycache__/product.cpython-312.pyc | Bin 967 -> 958 bytes product/models/product.py | 2 +- .../__pycache__/__init__.cpython-312.pyc | Bin 303 -> 303 bytes .../category_serializer.cpython-312.pyc | Bin 770 -> 829 bytes .../product_serializer.cpython-312.pyc | Bin 1627 -> 1627 bytes product/serializers/category_serializer.py | 1 + .../__pycache__/__init__.cpython-312.pyc | Bin 171 -> 171 bytes product/tests/test_serializers/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 208 bytes .../test_category_serializer.cpython-312.pyc | Bin 0 -> 1243 bytes .../test_product_serializer.cpython-312.pyc | Bin 0 -> 1561 bytes .../test_category_serializer.py | 15 +++++++ .../test_product_serializer.py | 20 +++++++++ .../__pycache__/__init__.cpython-312.pyc | Bin 186 -> 186 bytes .../test_category_viewset.cpython-312.pyc | Bin 0 -> 2502 bytes .../test_product_viewset.cpython-312.pyc | Bin 4069 -> 4041 bytes .../tests_viewsets/test_category_viewset.py | 40 ++++++++++++++++++ .../tests_viewsets/test_product_viewset.py | 28 ++++++------ product/urls.py | 1 + product/viewsets/__init__.py | 1 + .../__pycache__/__init__.cpython-312.pyc | Bin 231 -> 288 bytes .../category_viewset.cpython-312.pyc | Bin 0 -> 873 bytes .../product_viewset.cpython-312.pyc | Bin 974 -> 934 bytes product/viewsets/category_viewset.py | 2 +- product/viewsets/product_viewset.py | 1 - 56 files changed, 130 insertions(+), 28 deletions(-) create mode 100644 order/tests/test_serializers/__init__.py create mode 100644 order/tests/test_serializers/__pycache__/__init__.cpython-312.pyc create mode 100644 order/tests/test_serializers/__pycache__/test_order_serializer.cpython-312.pyc create mode 100644 order/tests/test_serializers/test_order_serializer.py create mode 100644 product/tests/test_serializers/__init__.py create mode 100644 product/tests/test_serializers/__pycache__/__init__.cpython-312.pyc create mode 100644 product/tests/test_serializers/__pycache__/test_category_serializer.cpython-312.pyc create mode 100644 product/tests/test_serializers/__pycache__/test_product_serializer.cpython-312.pyc create mode 100644 product/tests/test_serializers/test_category_serializer.py create mode 100644 product/tests/test_serializers/test_product_serializer.py create mode 100644 product/tests/tests_viewsets/__pycache__/test_category_viewset.cpython-312.pyc create mode 100644 product/tests/tests_viewsets/test_category_viewset.py create mode 100644 product/viewsets/__pycache__/category_viewset.cpython-312.pyc diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index 5db735e5c84c69bb61daa03fb6150d2a1276973a..6a37da8421613afcc040ef2dee9e6ce32940b9d5 100644 GIT binary patch delta 169 zcmZ1@KUJ3RG%qg~0}!ZA@Je$Ln#d=?6vnhs!;gt4ogqbQ5n~irC6lK1W-sO@4(nf> zhDPRk20&=2$y_7`)KsJbB&rlrlM<74lk)Ski%as0QgssxGW9Z2i}JHe6AKFTlJj#l zWhe9SI0)b33U+l4at(?1c8$En>f-7Y>OMJ)=kMfr-Y6~?ph1j4Ts&*@Vcw~Xyq_c( N1pOHsd5fHYf&g|qEdKxi delta 334 zcmbO#yGEYxG%qg~0}$A@dZoP+oX97^B*(l_!;fil9iukC)@nwO90NlX2NOf8EJ#dT zJB4wL&T1xzI9#3+B&Vwj<7e4IKx=667TIAd5hJ>)hX0nld*^oXvQrO7cWOYcmH@tA0Pj4SC@DX|KO0|UyKTx@{{ek z9k_~AfQpJ#fyCrV+<$p)F=ytL++r;*$jL03+|LumcKB->=hehWQG|4!_GhdY3u$8(4wL1%;<`P2`%+ fH<9mxyy;~Dv+Dvj7X@r~1YZ_#Y~(F+1)2>2$rn@5 diff --git a/bookstore/__pycache__/urls.cpython-312.pyc b/bookstore/__pycache__/urls.cpython-312.pyc index e723a99f92d9bb9719c65846842ca8b42065b437..5338c856a31cb591705d4dfc6eadc4bafa5c5064 100644 GIT binary patch delta 20 acmX@geUzK~G%qg~0}yyVcHYRnixmJmNCkxe delta 20 acmX@geUzK~G%qg~0}zBo+iv9E#R>p7RRsh9 diff --git a/order/__pycache__/admin.cpython-312.pyc b/order/__pycache__/admin.cpython-312.pyc index 11a41534e6a85b87cbd7d66db70c7e723b79c00a..71bb81ca9bf63b09b824386e216bd220800ae5e1 100644 GIT binary patch delta 19 Zcmey(_?waYG%qg~0}yyVcAm)n0RTGP1?~U< delta 19 Zcmey(_?waYG%qg~0}zBo+fL;E001~^1#JKT diff --git a/order/__pycache__/factories.cpython-312.pyc b/order/__pycache__/factories.cpython-312.pyc index a72a47cd9fd12b58ef38238f49d34eaf1c4fb4ca..aea111b4d8ba7fe4ab45f4a9670d290d7ceff9a7 100644 GIT binary patch delta 532 zcmcc2dy1F$G%qg~0}%L3^GZ81k@t=StA9~SYLO=6Exv%F{FKt<61T+UlKi5|$&8GN zlkFI}blI2~+!<1sS{PE8S2KaMGB8B3SF&ib-r^1|PA!5ezr|WmSzJ;yc?XN`O-6yqTUp%VQLQUt0U5*xB9M#(aY4>2QUnsRKn!=iD5~qZ&|F_6JUNQh zPynnK$-K$4Sxr^hShYSgGqA~iU;?tf3ox>Zfm|vE@r4A?5>0NP_OGm}Dm?k1sL;#J zPf5)w2D|WF#rjO9LPqX zcWgGhGjlOA3QZ1T(Pz9lxrs%SQE>7a7Poj*i;Gx6hVp|5B;!F`kVA_UfrJbY!~G$O z>JKh7e-w#K4rDbH0P96EZ}KEoQ&m=0t@rwnpm*jO1wC#X-? po2YkP$oQg=@fQZ5z!w1?MzIOz)9ohOT^BaFC~WeT0Vn{r5dgKXcxM0r diff --git a/order/__pycache__/urls.cpython-312.pyc b/order/__pycache__/urls.cpython-312.pyc index 12fdf8a475794888a3eb555c5a4aa1f280c1b6c9..62b0d80eb3e56ba514af62b1a89d107dbdf0be36 100644 GIT binary patch delta 20 acmcb^a)*WcG%qg~0}yyVcHYPx$OHg8;RQJW delta 20 acmcb^a)*WcG%qg~0}zBo+iv6zWC8#c!81kG%qg~0}yyVc21L;$a@$7KS%}d delta 21 bcmcb>c!81kG%qg~0}zBo+onlQ)2GA_a&5 diff --git a/order/serializers/__pycache__/__init__.cpython-312.pyc b/order/serializers/__pycache__/__init__.cpython-312.pyc index add5d28acb988ead60d227d0504031c06f6380c1..ad967c927b207ec126c07fbf495e76069807733b 100644 GIT binary patch delta 21 bcmaFG_==JDG%qg~0}yyVc23iu$a@z6L&gSD delta 21 bcmaFG_==JDG%qg~0}zBo+otJFfW&l$$#+@ACtqUGV`Q4l$SNz( t4irQKHOy<6S2IEcCtI_IvuH9FNlu=^dYWT}<^=(j%K|2w)7kzr0s#E%7jOUo delta 93 zcmaDQ@JxXBG%qg~0}zBo+ooA;(>JmtkIamWj77{q764Y#JIMe5 literal 0 HcmV?d00001 diff --git a/order/tests/test_serializers/__pycache__/test_order_serializer.cpython-312.pyc b/order/tests/test_serializers/__pycache__/test_order_serializer.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fce5725e8e89d6b1f54abb2fc1987348370baeb0 GIT binary patch literal 1617 zcma)6O=uHA6rS0iWKGkiRSP!$5ItB|Xp54As06Y8Mu_6iWeF_X>_n^CY@OL2QWQM& z(1YNy9z9kns3-L#coo5*(z3K5C`iGB5WRTvz1jTK5X6Cf`+mOn!+US$ZGV4)!1?hY zUw)?$@&$#~(VI-;BruD_B`&QHk6M%>uT&IIwNy{DG%2eU-HTZ=EYDf@|JkaN6Tien}EoSRFW#tK7Zf1a7ZA8%50zx#S#drRjd}1wa zjhIRSx)+~``f0{FPBYxnlBr32w0BDZe!9v1%ZSY|1GW?aNNp^*y^d<@>h;43>?#e(4tDVVgH=X68nE40K$Yutnkokb7ipWc0&`xuD%2=x|?$_bz3h z<{sx>W?$!C<=!96e;mF5ki=SM;+gg$@jUS%b8JETWbAH04AOf?zJp~Er;CuT(`({) zDPUXoX%qeqb?FGmt|F<56p-yXcAz~c-`p*VKL3iY{S{r__)cWx{v92*NiT48T|eF!(DgixkO(T6M%d@x zbgI|=acl<1*DFlP?v0n_gF4NGyxh^{ABs$!0SI~9ql|mNxl_e&<9Jkbj_(5lPFm~& d@u{sZ{1Yu*3= literal 0 HcmV?d00001 diff --git a/order/tests/test_serializers/test_order_serializer.py b/order/tests/test_serializers/test_order_serializer.py new file mode 100644 index 0000000..6ed1588 --- /dev/null +++ b/order/tests/test_serializers/test_order_serializer.py @@ -0,0 +1,20 @@ +from django.test import TestCase + +from order.factories import OrderFactory, ProductFactory +from order.serializers import OrderSerializer + + +class TestOrderSerializer(TestCase): + def setUp(self) -> None: + self.product_1 = ProductFactory() + self.product_2 = ProductFactory() + + self.order = OrderFactory(product=(self.product_1, self.product_2)) + self.order_serializer = OrderSerializer(self.order) + + def test_order_serializer(self): + serializer_data = self.order_serializer.data + self.assertEqual( + serializer_data["product"][0]["title"], self.product_1.title) + self.assertEqual( + serializer_data["product"][1]["title"], self.product_2.title) diff --git a/order/tests/test_viewsets/__pycache__/__init__.cpython-312.pyc b/order/tests/test_viewsets/__pycache__/__init__.cpython-312.pyc index 9a5ab68078aef551ff1b29967965a24f59e2a293..c4de5a608865b84e1693fffba75d815795666a38 100644 GIT binary patch delta 19 ZcmdnaxSf&vG%qg~0}yyVcAm(+1^_V$1tI_d delta 19 ZcmdnaxSf&vG%qg~0}#0Wv!2Mk1^_Ww1u*~s diff --git a/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc b/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc index 6cf350f198769146da2a5bc848c202d4edd57d58..c47a36aa67a29c5f8b11dcedf175715e01270be6 100644 GIT binary patch delta 698 zcmYjPOKTHR6u!6f$~+sLr0F9~sI*Fa1S3fmLt3O(R0NAgkcx!RnP_6t33nzcn1yaM z3(*W04C2CyE<`s%UAgHG=*EQ$9Ss$<`%0=Vbm80?)Skt69^bj=p2Io6ho6qftFkNr zSE3J2mb$i_6Cu!mMpu~{J8z#G^Ifhg*OYntRt&QCQY643{i=>k-F`iRIT&Y|(@4{i z{bgK$4mXDkt+8M&AB5*&n3P6g0wRF{0)gdceLpBj;YVx?()bPA**gURxC!2?kxtgm zcBbv=Pm>os{iSFqCTrHdw&R%h$OSgtzgFz@4N;s(R9-Ub;1iK+psg z$+x#+r5``xRk#gbpbi>pU zJ|s+CKq;3@1QF*df98a1IgHk*)lH|btT{{_l@~2EPQrBEFfBxp+?@n=5ugbZJf6?b z6%OoA6=u%N9?8!hMLb>=hF}V>3zylXn_@2Ev*JW-F#4E#$bDldS?N(sP-xMc3gDHN zc31qYM(};{1pJCWh%=DIqtdaQ$_TyPAtr-H$XALB2^D!Qidv<(c*#gMP}THWaulSS zR-uH7HT{}_t{@uUlZMg^dC0op^c!UD$x?B_GEiAJ{h>GU2qvOz%zKLT+b#JgZ@4NU%I0i5iD*c!-n!H!Kf4KwW<-+`;V#{U2h C?4z&% delta 746 zcmZWnOKcKB7@lDtz%C1=P(V?d);=V*gpwjLh*kTDp2SK`Qx62$#jt{lvx|>dQ$5+E zn>mn16HV;Fn;JZMGM<`vG0}rrZR(}*T2u98j5Av`B%Q;z-}k>}|NoyS(O-L|w~{0P za?W4KRbH4 zM)GbmT$ixSZh1j4f?tZK;b;6?oP-=c>6r<2bHesPKbJ;PTE|Nu9zb#Y+!I`~e=2|! z-6&R2sjght(B*_dBw}eSN5B$gwRGi@mT01yZZ~E58#_x+RP0w#Rdi%8obKB4Y4nA3 zxa?ukomt+0d38-zNHNj2dh7(8mBv$anp+Hn@DmU>LEi>Aya{^0g4_m3uY>+|5c|$2 OVfy~9AAo%9cK!f@NVt^% diff --git a/order/tests/test_viewsets/test_order_viewset.py b/order/tests/test_viewsets/test_order_viewset.py index d8d3e2c..4695348 100644 --- a/order/tests/test_viewsets/test_order_viewset.py +++ b/order/tests/test_viewsets/test_order_viewset.py @@ -1,14 +1,14 @@ import json +from django.urls import reverse from rest_framework import status from rest_framework.test import APITestCase, APIClient -from django.urls import reverse -from product.factories import CategoryFactory, ProductFactory from order.factories import UserFactory, OrderFactory -from product.models import Product from order.models import Order +from product.factories import CategoryFactory, ProductFactory +from product.models import Product class TestOrderViewSet(APITestCase): @@ -23,7 +23,8 @@ def setUp(self): self.order = OrderFactory(product=[self.product]) def test_order(self): - response = self.client.get(reverse("order-list", kwargs={"version": "v1"})) + response = self.client.get( + reverse("order-list", kwargs={"version": "v1"})) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -48,10 +49,12 @@ def test_create_order(self): data = json.dumps( { "products_id": [product.id], - "user_id": user.id, + "user": user.id, } ) + print(data) + response = self.client.post( reverse("order-list", kwargs={"version": "v1"}), data=data, @@ -59,4 +62,5 @@ def test_create_order(self): ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) + created_order = Order.objects.get(user=user) diff --git a/order/viewsets/__pycache__/__init__.cpython-312.pyc b/order/viewsets/__pycache__/__init__.cpython-312.pyc index 5d98afe0ed71c4935e2681aa435146de97ba5670..3eb660cbdbcc86145039dc2642199609be6fe167 100644 GIT binary patch delta 19 ZcmaFJ_>htNG%qg~0}yyVcAm(64FESA1)u-` delta 19 ZcmaFJ_>htNG%qg~0}zBo+fL-Z1^_gv1s?za diff --git a/order/viewsets/__pycache__/order_viewset.cpython-312.pyc b/order/viewsets/__pycache__/order_viewset.cpython-312.pyc index 8fa93d6a15295c5df2b7c06409c43c1f2daa6738..8f92765678e529e86b80b88a1ddcc587aea60bcd 100644 GIT binary patch delta 182 zcmeBXJ;cg)nwOW00SGQl@k(Q7oX9teiy6cPg3n14H#u8o2|{?tWD4VIMhHKOvyw@Z z`4*3VQA%o2SY~Q@aB9gdrpy#SO|Hp2i~$_^Ao2L5%E?iTMU1MG&oWB$U+34p$gjP^ zv~1V+@$w!C1g3HTfr_G)tpLk-%hSrYI?XpvEEr5FrR8esS33=BJeAq}mmU UPM*#r$E!TS<|_j;qcT_t08F_cM*si- diff --git a/order/viewsets/order_viewset.py b/order/viewsets/order_viewset.py index 5a92cd6..ad52962 100644 --- a/order/viewsets/order_viewset.py +++ b/order/viewsets/order_viewset.py @@ -7,4 +7,4 @@ class OrderViewSet(ModelViewSet): serializer_class = OrderSerializer - queryset = Order.objects.all() + queryset = Order.objects.all().order_by("id") diff --git a/product/__pycache__/admin.cpython-312.pyc b/product/__pycache__/admin.cpython-312.pyc index 784abddc0752278d4f00a66079810898a1eded60..bfb9952242bfd97501316a6be4f3dae1793e3f02 100644 GIT binary patch delta 20 acmbQrG?j__G%qg~0}yyVcHYR%#Rvc}fCOIv delta 20 acmbQrG?j__G%qg~0}zBo+iv9MVgvv!jRW2Q diff --git a/product/__pycache__/factories.cpython-312.pyc b/product/__pycache__/factories.cpython-312.pyc index 2663c483b9c097a208c911f70903fbd68fae9d99..817d3e2a4e5da876ec09c37a222bddcabc0ef03d 100644 GIT binary patch delta 20 acmbQtKbfEVG%qg~0}%ATb>7I`!43d5Fa=2f delta 20 acmbQtKbfEVG%qg~0}$Mr;tyG%qg~0}%X~;gyy!kyn!O*F^PhuT+jKVUQ>)NMTE5%MwEs1MyPW*08Q- zhKMsVFfpVurmzD^CZH)26A!4e@>X(aa!!2Z%*T*^x<>MHHwG E08X4J`~Uy| delta 91 zcmcb}`iO=1G%qg~0}zBo+olOmG%qg~0}#Yc@!H6}h8X}hTLm2e delta 20 acmdnazMY->G%qg~0}zBo+iv7u!wdj4lLXKJ diff --git a/product/models/__pycache__/product.cpython-312.pyc b/product/models/__pycache__/product.cpython-312.pyc index fb9b858f84e7b7b68bd34512c91a3fbcaf3b8ca0..ecdd6a1aa7015739f4f1f248634a6fd2e17a077c 100644 GIT binary patch delta 65 zcmX@kzK@;vG%qg~0}$v;@k(pl$m_+-&sR{CpHiA!qL-VWlA2RIIiJ}{O!*5NE2B+E RT7OPw&Q}H?vq%c42LNt+61e~X delta 74 zcmdnTew>~6G%qg~0}z~_?3C8Ek=Kh^LcE|TKczIeL@zf#B{ip5FFCO!H9fzma&j88 albFsIHdaQPjeyM z6l)4o3UdleCSxXJ6k8>$Cfj5&MqA+`kTJJ7ic$+pGmBDF-261zCx?%gY^>=s}NTQ+Xo&7N%;j*D?%?Q7+(-K>EtOA1*$0$ z2NHgoEJb`E4nK$xfC(3gfLLHvVv`-2q_{X(O+PUJi6YU-sZ60BNYX%szc_4i^HWN5 vQtgVQfm}u)E|vunAD9^#8SgTvJ!R1O!p6yHIz#%pq{&4|ldlXw4%l=69H~I7 delta 213 zcmdnX*2KnpnwOW00SLmPZPRQf@;*{$0`Y+0vjmWs&XCFw#hAhn#gxh%#gfjD!nlYr zinWqSlXIBIE diff --git a/product/serializers/category_serializer.py b/product/serializers/category_serializer.py index cfe2ff8..7da9ace 100644 --- a/product/serializers/category_serializer.py +++ b/product/serializers/category_serializer.py @@ -12,3 +12,4 @@ class Meta: "description", "active", ] + extra_kwargs = {"slug": {"required": False}} diff --git a/product/tests/__pycache__/__init__.cpython-312.pyc b/product/tests/__pycache__/__init__.cpython-312.pyc index e813dd51749e90032d156fe495b0d6fba26ae23b..822a00d8e2874e7db2a90954cfb937d83a7980f4 100644 GIT binary patch delta 19 ZcmZ3@xSEmsG%qg~0}yyVcAm(+001vd1pWX3 delta 19 ZcmZ3@xSEmsG%qg~0}#0Wv!2Mk001wX1q}cI diff --git a/product/tests/test_serializers/__init__.py b/product/tests/test_serializers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/product/tests/test_serializers/__pycache__/__init__.cpython-312.pyc b/product/tests/test_serializers/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3904fb3557470053ca2b9008ae7472931343a0ed GIT binary patch literal 208 zcmX@j%ge<81XuUFr-A6lAOanHW&w&!XQ*V*Wb|9fP{ah}eFmxdmG5j76Iz^FR2-9= zSdx(%Z5r~UHjE~HWjEqIhKo$VyPCT#x literal 0 HcmV?d00001 diff --git a/product/tests/test_serializers/__pycache__/test_category_serializer.cpython-312.pyc b/product/tests/test_serializers/__pycache__/test_category_serializer.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d2adbf91d84bc0b91366c7ee33bc60d543bf5899 GIT binary patch literal 1243 zcmZ`&&1(}u6rb6TbZMK$TC8al8}OhDHejI^TJ>OC1rI^gf-DQmc4t!4?q=i6=8#gc zha7qkJhp#Ar5@_ZKSDeNEtRDO!Gm~Gh+cZ~&FQ4^+h2bdj15Wz0;uz|7QC0FufL-rIyiDcPTy_Au{NJ94zQ5uM-6z|J% z3}c|4(g(f^LC2x?nDSu3=2Vx$%z_=zRiD-G+D-shIP!q`q~-*P4CZIsCXXm9+irP- zGA9ljQz;QzIbe1WMFu9wkcdL0hGNJ>ZXiRcV_gl$u1yU~gcl-@ZaW%0EPAUi1N z=m>rz?I+SEvO52RHc)62t+kWsghQyuCxHW@I@0B0sFZx4K!s{h4qU1$OaZr0a}r2c zN{C}^(c+!@!AIfLEpd@V{`AGdoVg5IZhCg`l$wjaQ}bvg;3i$M9n*SfSBURf=8EsH zb3mC+5#L#-Y|8Pys?X_EiQ0i#je$1<=nju)&x^^AKDiXC^-$$BSgvkd?2m6D(rS<@ zp9Hdnj~`jhHhiRI zn_6~va_@X|;`+gjLv4N#wRHM4c$6H)4x(0 Np5J})8^IO%{sDnbI8Fcn literal 0 HcmV?d00001 diff --git a/product/tests/test_serializers/__pycache__/test_product_serializer.cpython-312.pyc b/product/tests/test_serializers/__pycache__/test_product_serializer.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1f7803cdfa6b15d9f24ec4c31956a68bc621d5e5 GIT binary patch literal 1561 zcma(RJx?4*bY{O;;0^@DGMuA;;sR|XkWP+_WIHKx?%d%F4EzKD(~&boo%p`Dc<+jy!U4QD3>P) zoL_&sy>X@y@;5TYF>_+@2@rdP5k^B2(FUbRYoQkD4Lvd%M#}4<8CeaB5{-OLn6X2c z$?1Wf#b}ImEobZnG7e4bZ@5%7UvfuFrfa_9o3ZGA<_8K;GWDg1Stn3A59Twu<0_bmOrbZ*m>b*(Z1im6kJT>bEH z{b~J4{m=JnyT)Jk;sCtKYpa2cOIPD}Aod813{BoR7mfdW3bw-mjvTfrqYJtol&6l4`;1h^%lgdklBtV7_J01Gq&C^49?{AALX zFdX&icO5@;G%<^s>Cw16G?M7Mv?S(Gc^Sv*ouA*<%EeQAi#gULzXkA!oK)UBu2lP# z>T%_IzjA$d`ou0B+w*;Uet)rdxxY|7ymn--ofEDd**Ay6lhT#_+x^mVkM>I+^w#>N zYlrSjosQS2xCBYyJF)~<9nq@8Z()00%a6F{B@><(!JiZ&UGh9^LZ%V#fS163=Qol@ zNG~sN`%*9lgv4I&kb!2J>vS+>nt8I+pzheoB)jjoHse)nfx!JrX7awRZlr%=lgsSU zrtfvGP>$L!)0dm2UBujYnY5HM`&L%@$Koo;@cqhn0sN~|N}rRZf5=DAN%hn!(;D6X K;w3?xdjAKDR&t>L literal 0 HcmV?d00001 diff --git a/product/tests/test_serializers/test_category_serializer.py b/product/tests/test_serializers/test_category_serializer.py new file mode 100644 index 0000000..f79b26f --- /dev/null +++ b/product/tests/test_serializers/test_category_serializer.py @@ -0,0 +1,15 @@ +from django.test import TestCase + +from product.factories import CategoryFactory, ProductFactory +from product.serializers import CategorySerializer + + +class TestCategorySerializer(TestCase): + def setUp(self) -> None: + self.category = CategoryFactory(title="food") + self.category_serializer = CategorySerializer(self.category) + + def test_order_serializer(self): + serializer_data = self.category_serializer.data + + self.assertEqual(serializer_data["title"], "food") diff --git a/product/tests/test_serializers/test_product_serializer.py b/product/tests/test_serializers/test_product_serializer.py new file mode 100644 index 0000000..2be469a --- /dev/null +++ b/product/tests/test_serializers/test_product_serializer.py @@ -0,0 +1,20 @@ +from django.test import TestCase + +from product.factories import CategoryFactory, ProductFactory +from product.serializers import ProductSerializer + + +class TestProductSerializer(TestCase): + def setUp(self) -> None: + self.category = CategoryFactory(title="technology") + self.product_1 = ProductFactory( + title="mouse", price=100, category=[self.category] + ) + self.product_serializer = ProductSerializer(self.product_1) + + def test_product_serializer(self): + serializer_data = self.product_serializer.data + self.assertEqual(serializer_data["price"], 100) + self.assertEqual(serializer_data["title"], "mouse") + self.assertEqual( + serializer_data["category"][0]["title"], "technology") diff --git a/product/tests/tests_viewsets/__pycache__/__init__.cpython-312.pyc b/product/tests/tests_viewsets/__pycache__/__init__.cpython-312.pyc index aa0b8d851d0bfed97d0161ae145bbb7f32d68b41..c085ab451796cb51fb4e82c46b77aa6f71516ca9 100644 GIT binary patch delta 19 ZcmdnRxQmhdG%qg~0}yyVcAm(+9sn_T1uFmm delta 19 ZcmdnRxQmhdG%qg~0}#0Wv!2Mk9sn`N1v&r# diff --git a/product/tests/tests_viewsets/__pycache__/test_category_viewset.cpython-312.pyc b/product/tests/tests_viewsets/__pycache__/test_category_viewset.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9343ddc45e6472b64f311e18e312d51b0fef974 GIT binary patch literal 2502 zcmZ`*&2JM&6rcUF*Iy*m4%nEqkpiSvNKBxD7AR>N2>nt(G*qf(QdL!<7t<4PDkwQ{YyXE{Vv)+}7F48`LvIw93#Y!f>$O$ajN~_OX5P+w^XB(^ zJ5Q<_(EJ_*48HcK)r~0x^nV#b9 zz|_SLr;WT`vg{D3b2_u8RaoI{AG1`e!a(brRxN$eq}3TUXF&&3vNx4;9k`Nj4Vs5R zsS%xIIE`d@p6J3xYbhgY+;x(XG#;c+6F~Z_VoK^b`7Ezr{ZzMdTPzGT^w>58vBzu5}(bh{$wff#G*UFBhgy zW-l{HOtz?6SM=;zGgm1>W>{9AS94kAl3LQtqLOuXg+%DtGBveI&dOSlHs(rY8RBPp zYp8gxyy@|B)s|rSa(QLI%VF!pl{APe=E(PHcb}dG=+* zyRR`L&n(-IG|8JKn_r#)82Og2s&tVde^|w^7{#nnysT8%_T^j}35&W#G3|CpWq>B@ z+?N&AutP4Ll$@#Q)aNXJFgJHmIeO%Xa^YiJEHH2*8K$bi{yDQ`0q`j1%iUj~m@!)h z&tXhU%2U^n1;n&A#?9mF-V6Wv=ob@Nnh z^5*2DaP-E7d!PR#ZXJGiJA9@oaIyEeb@`c(1R@PNUYFyy;*G>uJu$Yq+(=K=(^K2> z`;X%LZwJ2*-g&z*e5^iv>|y+^^~e)B+_E3MQ>`Z^cJ?Lz7Px(bJA((XKeRJ4`or4Y zwZ_QF`pC%_0v9+fM=x%ny5)Y z6rTr}RZjD7%3gh4LvV&X>rTJQ_acOah;dpk8h9RnE^RvWg!5i+mrk$on}PO8g;&HR z6ylvPJWb;}et`p?;5pjRu1%JN0$`_ z&AtNx)wwVF?aEgxw@%#oWNY8V!@i^I;uDuIjp%SaI^4yWo!tXFiP2|%54(YbEjiw1&{iVVNTlnD^n?As$Y&gy z%%)^pR+N%j)D^`JDoPO^CLEI7Lg|1kI>$`m3;gCAGL4deHA43hxhI5dY@@Y2> vXXraHhmSo&pga>ej{A*-o{~3yC&wR?k*8$rF&X~HH^@!iSb9OAb2j-GTevP` literal 0 HcmV?d00001 diff --git a/product/tests/tests_viewsets/__pycache__/test_product_viewset.cpython-312.pyc b/product/tests/tests_viewsets/__pycache__/test_product_viewset.cpython-312.pyc index e298ec0dd3092578467b2e12b197d00ef448e9a4..fb0eeee52aaacf70f25d222f9839b8090428b447 100644 GIT binary patch delta 1367 zcmZ`(O>7%Q7@gT4@7n9JH;t1tq#rH39IC@Rqig%dv~f)c5fdO;lFgpjIMt<*5s>WKpvR2n$-!pu605fXEF^JeFp znQy-LW`7;{aRB{qxoEF>EF|Q5rdM^hZ=Ic2 z7O`Vh^WH+9?-VrQh#bDi$PTbU4q6~52*4Kij;3;w1+RmgYzYiQmdH>cmtY!xM?Qqf zGg7csDHO1FUkbN*z-nYB+?C#kd$9H8Dy+eh7R(Z=9l53X>RQ7nyTz>6A@=(~CiZSNSGPnjB zi2*WSmu`d`de;uxMvwI5eLcCGyk&f2+|!c}^jGTgfr@TMwjwv8cXq^rc#$W7k1?R) zitYJHQMKyYc+ITXEFoV9sjNyHs4YH!zo$YNpE~z07-6vrM&?QpL$qBXo5_tC;J-F&QBJ0&)@d$rCxg&ojw#{ zVy3P>34t&o74-+`-5C$}LGpRHXS0{B{7>`xf)AErsaCiM_al2p_Na-LwjT`)c~z=` zQhyNL?rT!%`SvJa-eAB=LjfbV<%HlRiLOlyqknuL|IfB^X@uyJ1gU8V_LC*eh|57@ z5NrS=M!wfxCn$Puv&(mcF9?2t9oBM*!P#jJDGuD}SmiLrfXY_2vhGr$Xi;h1aXnuf z{1Tr}b5MAY{$@72xO`@8e0gpuGn>tv!`!fKaf}exrH2W_qt!gK;fjMd@T)v(g8Uve zl@UhWXMnte=F*MMp$DDGy4r|$-n_DP<)C|Tck*E9^w+7cQeXD}Awo2ED2jTdEuf1{EWIkx^(T0r;;j1o+hGl z79O5R$W!<^9*7ti$EaqN%(WFKUBzV=i$sVILy1hsdpBhs#5bog%zi4%17%Q6rR~1@7kMPC-EOipl;ICVGFczXqvPVh1Q7#La9P(1aehbi+5d|*j{&L z404pJ2=(Afi}xgiup1Js@T_Hf0XqeDmI$ zd9&|*v)?6uP3qt4dI+%b@Qc&McUN^YQ4w+i1U9gRvRILFlF!BR>fD)Vs3r1H0CIf| z)zp6HboIB%%W~FTa;hfulzHUZ^#U;kPdhdLQr5vFV`0Y&vPGs`a;k&}A?GazVTaKG zCKjpVGX;K9cfbzW-N(pv;D8*oK~AvY6_68cfuUrJ4CRJo%3gogp%-Baenr>dXiDxL z(&~^Eknh|X0HSt`G%cC58jL@-0b8AHEKcd}C4Dq448S0LS$KXvgo4cO1q%N45l?`^ z90J^|xNj^v1%jC$ITmp|neb8|$#>Q|)qtLaopKTLTy$HwdO~LeXBfN#cH&98)ReAi zJJBSaV3QB{+}K zkCitSPH`C0aeabLsl)M4rq)kx9=~PZK7DrkKz1wgYE!+Z_E4;T4X@pt3J$?uGQhU@ z!&X+rmOz)KZ z$OwHXrv#Fs|Ad|m8{LLplKC$Bf)=CiX;E6z4Ct@mA^N^H48!zu?WDe}%~-_Rk6Go? zC+MHr%;mV>R}^7s(32eeUYnfpLZd?*p5nk|g^n=rWV>FeVNWR8o?JtvD)FS6i;3R? z^fV89hJ(gqdtc0E=kpWe>3n8k_EdIu265T_*Moh)40P(xqtyb_)CCtc&@_*lptpJ~ zWt34Y@SbEQe~FB2MMj(IPB`+x^3~-Z=k$aH@y`iTRIT~uJe;Kr<#^}%bD=D^@4l2j+oO|vVqvYBws{U#d+IBOMWrY5n2u(HSdDw+F+~=(rqwu b7aVJYWE%|s1hfZ%aX7s;^fzFWf9-z(=EpXR diff --git a/product/tests/tests_viewsets/test_category_viewset.py b/product/tests/tests_viewsets/test_category_viewset.py new file mode 100644 index 0000000..5a7d755 --- /dev/null +++ b/product/tests/tests_viewsets/test_category_viewset.py @@ -0,0 +1,40 @@ +import json + +from django.urls import reverse +from rest_framework.test import APIClient, APITestCase +from rest_framework.views import status + +from product.factories import CategoryFactory +from product.models import Category + + +class CategoryViewSet(APITestCase): + client = APIClient() + + def setUp(self): + self.category = CategoryFactory(title="books") + + def test_get_all_category(self): + response = self.client.get( + reverse("category-list", kwargs={"version": "v1"})) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + category_data = json.loads(response.content) + + self.assertEqual(category_data["results"] + [0]["title"], self.category.title) + + def test_create_category(self): + data = json.dumps({"title": "technology"}) + + response = self.client.post( + reverse("category-list", kwargs={"version": "v1"}), + data=data, + content_type="application/json", + ) + + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + + created_category = Category.objects.get(title="technology") + + self.assertEqual(created_category.title, "technology") diff --git a/product/tests/tests_viewsets/test_product_viewset.py b/product/tests/tests_viewsets/test_product_viewset.py index a943941..ac6eddc 100644 --- a/product/tests/tests_viewsets/test_product_viewset.py +++ b/product/tests/tests_viewsets/test_product_viewset.py @@ -1,19 +1,20 @@ -from product.factories import CategoryFactory, ProductFactory -from order.factories import UserFactory +from django.urls import reverse from rest_framework.authtoken.models import Token -from product.models import Product from rest_framework.test import APITestCase, APIClient -from django.urls import reverse from rest_framework import status +from product.factories import CategoryFactory, ProductFactory +from order.factories import UserFactory +from product.models import Product import json class TestProductViewSet(APITestCase): - + client = APIClient() + def setUp(self): - self.client = APIClient() self.user = UserFactory() - self.token = Token.objects.create(user=self.user) + token = Token.objects.create(user=self.user) + token.save() self.product = ProductFactory( title="pro controller", @@ -22,8 +23,10 @@ def setUp(self): def test_get_all_product(self): token = Token.objects.get(user__username=self.user.username) - self.client.credentials(HTTP_AUTHORIZATION="Token " + token.key) - response = self.client.get(reverse("product-list", kwargs={"version": "v1"})) + self.client.credentials( + HTTP_AUTHORIZATION="Token " + token.key) + response = self.client.get( + reverse("product-list", kwargs={"version": "v1"})) self.assertEqual(response.status_code, status.HTTP_200_OK) product_data = json.loads(response.content) @@ -35,19 +38,16 @@ def test_get_all_product(self): def test_create_product(self): token = Token.objects.get(user__username=self.user.username) self.client.credentials(HTTP_AUTHORIZATION="Token " + token.key) - category = CategoryFactory() data = json.dumps( - {"title": "notebook", "price": 800.00, "categories_id": [category.id]} + {"title": "notebook", "price": 800.00, + "categories_id": [category.id]} ) - print("Data sent1:", data) - response = self.client.post( reverse("product-list", kwargs={"version": "v1"}), data=data, content_type="application/json", - # content_type='json' ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/product/urls.py b/product/urls.py index d4484f7..381f1c0 100644 --- a/product/urls.py +++ b/product/urls.py @@ -5,6 +5,7 @@ router = routers.SimpleRouter() router.register(r"product", viewsets.ProductViewSet, basename="product") +router.register(r"category", viewsets.CategoryViewSet, basename="category") urlpatterns = [ path("", include(router.urls)), diff --git a/product/viewsets/__init__.py b/product/viewsets/__init__.py index ab3446c..a68317b 100644 --- a/product/viewsets/__init__.py +++ b/product/viewsets/__init__.py @@ -1 +1,2 @@ from .product_viewset import ProductViewSet +from .category_viewset import CategoryViewSet diff --git a/product/viewsets/__pycache__/__init__.cpython-312.pyc b/product/viewsets/__pycache__/__init__.cpython-312.pyc index bd4047dd92d894ea9e91e8072d799fcc3a590469..681cce64c93845e9f455562d4684ff2aca97a856 100644 GIT binary patch delta 182 zcmaFPxPXcGG%qg~0}y4BO~Ko2JL$cxu_y81O^9B4@=bQv6d&w+zj=S=z4^WU(rBy!%Bzphy3Yx~cYP?u zF2G_J!2}pEA|NI{AsQRPh)v&IVpCYL?b`$lcnZuK1G71qnt8on8CBfsPknGnR)3K& zE?)QeNt>s5uI+^>KTPBZ@wF1Sx$K3acgkgy-;rw^a4CzMXePkHCk%Xpo4&=!7<_wV zxMt>*w-imHvP{?Nne?{^P)#63olD;+(aQEq239VZ7Pw!%;w&H|)1p@!Tw^~odd#(? zh0&~Rc3}lWVJ*xE@?+U+EQF}m9D#cd9e2|I8a=wAP&PwBa{eOB9EU>5AVm8?eTAdESs*&3xW z&LcFgQ*0TEJR&ud*#$1hsuC)VjbTHhC}8d`9ufvCI;TGLy@g75P~iO(w*AWdKq|f Date: Wed, 22 May 2024 20:16:21 -0300 Subject: [PATCH 41/42] =?UTF-8?q?Sinalizando=20requirements.txt=20para=20e?= =?UTF-8?q?xerc=C3=ADcio=20EBAC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index dc60196..9783973 100644 --- a/requirements.txt +++ b/requirements.txt @@ -53,3 +53,5 @@ trove-classifiers==2024.4.10 tzdata==2024.1 urllib3==2.2.1 virtualenv==20.26.1 + +# Exercício EBAC Build From fcf3c2c37326770d71e3c61d65dd9ce68bca47a8 Mon Sep 17 00:00:00 2001 From: matheus-dev-fullstack Date: Wed, 22 May 2024 20:25:00 -0300 Subject: [PATCH 42/42] =?UTF-8?q?Sinalizando=20testes=20para=20exerc=C3=AD?= =?UTF-8?q?cio=20EBAC=20-=20modulo=2014?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__pycache__/settings.cpython-312.pyc | Bin 3733 -> 3733 bytes order/__pycache__/factories.cpython-312.pyc | Bin 1738 -> 1738 bytes .../order_serializer.cpython-312.pyc | Bin 2154 -> 2154 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 206 -> 186 bytes .../test_order_serializer.cpython-312.pyc | Bin 1617 -> 1597 bytes .../test_order_viewset.cpython-312.pyc | Bin 3491 -> 3491 bytes .../__pycache__/order_viewset.cpython-312.pyc | Bin 706 -> 706 bytes product/__pycache__/factories.cpython-312.pyc | Bin 1939 -> 1939 bytes product/__pycache__/urls.cpython-312.pyc | Bin 721 -> 721 bytes .../__pycache__/product.cpython-312.pyc | Bin 958 -> 958 bytes .../category_serializer.cpython-312.pyc | Bin 829 -> 829 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 208 -> 188 bytes .../test_category_serializer.cpython-312.pyc | Bin 1243 -> 1223 bytes .../test_product_serializer.cpython-312.pyc | Bin 1561 -> 1541 bytes .../test_category_serializer.py | 2 +- .../test_category_viewset.cpython-312.pyc | Bin 2502 -> 2502 bytes .../test_product_viewset.cpython-312.pyc | Bin 4041 -> 4041 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 288 -> 288 bytes .../category_viewset.cpython-312.pyc | Bin 873 -> 873 bytes .../product_viewset.cpython-312.pyc | Bin 934 -> 934 bytes 20 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bookstore/__pycache__/settings.cpython-312.pyc b/bookstore/__pycache__/settings.cpython-312.pyc index 6a37da8421613afcc040ef2dee9e6ce32940b9d5..cbb2987e2593d5903e07ddda4861d2c5cf947e1d 100644 GIT binary patch delta 20 acmbO#J5`qZG%qg~0}#Bf_1nnZ#RmX4ngwY9 delta 20 acmbO#J5`qZG%qg~0}!ZA@Y=}T#RmW~js&s* diff --git a/order/__pycache__/factories.cpython-312.pyc b/order/__pycache__/factories.cpython-312.pyc index aea111b4d8ba7fe4ab45f4a9670d290d7ceff9a7..50fecba5fdc0816e7fa53aca0e7fcc22ff1d3434 100644 GIT binary patch delta 20 acmX@bdy1F)G%qg~0}#Bf_1nn3pA7&#ng!qh delta 20 acmX@bdy1F)G%qg~0}%L3^V-P0pA7&x!v$6V diff --git a/order/serializers/__pycache__/order_serializer.cpython-312.pyc b/order/serializers/__pycache__/order_serializer.cpython-312.pyc index 4849f599ca9fb5670f1d18ec5c5a71153e2f5e60..af7b5876faa51f5a0c07bd2b380660772ffc6203 100644 GIT binary patch delta 20 acmaDQ@JfLDG%qg~0}#Bf_1nlD&jA2J2nEOh delta 20 acmaDQ@JfLDG%qg~0}$lQ^xDWB&jA2GBL!gq diff --git a/order/tests/test_serializers/__pycache__/__init__.cpython-312.pyc b/order/tests/test_serializers/__pycache__/__init__.cpython-312.pyc index 511bf22f1504559ef8f9d7eee93f04507ad1be08..c1524b4afb70e4fd9a5d814e86b7feeaa852a061 100644 GIT binary patch delta 27 hcmX@dxQmhdG%qg~0}#Bf^_$3T%osV*-e6+0Hvngz2g3jW delta 48 zcmdnRc#e_#G%qg~0}x!@?>>>+m@#*vy@7~sN`7*7YLRYoer`d2ajI@wYGTR6d~X0- CAPSI1lfmX1rmM^Vrn?FE delta 54 zcmdnXbCHMlG%qg~0}y=Z_ewjvkynd}v1+mflYxkCN`7*7YLRYoer`d2ajI@wYGTRe I45q8h0L3>Ep8x;= diff --git a/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc b/order/tests/test_viewsets/__pycache__/test_order_viewset.cpython-312.pyc index c47a36aa67a29c5f8b11dcedf175715e01270be6..c2d338344cce3a0313996967c8aac41db06452f5 100644 GIT binary patch delta 20 acmZ21y;z$2G%qg~0}#Bf_1nljgBJiffd!5L delta 20 acmZ21y;z$2G%qg~0}#ke^V-NggBJiaS_ISp diff --git a/order/viewsets/__pycache__/order_viewset.cpython-312.pyc b/order/viewsets/__pycache__/order_viewset.cpython-312.pyc index 8f92765678e529e86b80b88a1ddcc587aea60bcd..bb3ba9579104d74ef4e42a2f8a9e663460e16e90 100644 GIT binary patch delta 20 acmX@adWe<#G%qg~0}#Bf_1nn3oe2OtHU+c* delta 20 acmX@adWe<#G%qg~0}x!A;7I`!43d5Fa=2f diff --git a/product/__pycache__/urls.cpython-312.pyc b/product/__pycache__/urls.cpython-312.pyc index d9c0e2b666638a03eca4d53e7c8f24ec22dad369..e6d483d2c4d240a04aa01b4bb39c0e4dc73ed6b3 100644 GIT binary patch delta 20 acmcb}dXbg;G%qg~0}#Ba_1nmOj0pfel?CDe delta 20 acmcb}dXbg;G%qg~0}%X~;kA+b7!v?KlLiR@ diff --git a/product/models/__pycache__/product.cpython-312.pyc b/product/models/__pycache__/product.cpython-312.pyc index ecdd6a1aa7015739f4f1f248634a6fd2e17a077c..63177894e636e3f6c8618e06f2ebf0acef571b38 100644 GIT binary patch delta 20 acmdnTzK@;zG%qg~0}#Bf_1nn3nHc~&-vzAz delta 20 acmdnTzK@;zG%qg~0}$v;@!H6}nHc~!90dUY diff --git a/product/serializers/__pycache__/category_serializer.cpython-312.pyc b/product/serializers/__pycache__/category_serializer.cpython-312.pyc index ff3de3b393698ef9522d9776bafd4ae313b44cd6..687a9098ddbc157f9eb488c8b8d033c0a5d2f4e6 100644 GIT binary patch delta 20 acmdnXwwI0jG%qg~0}#Bf_1nm8#0&sAlLaUM delta 20 acmdnXwwI0jG%qg~0}wRM^4iF4#0&s8M+DaZ diff --git a/product/tests/test_serializers/__pycache__/__init__.cpython-312.pyc b/product/tests/test_serializers/__pycache__/__init__.cpython-312.pyc index 3904fb3557470053ca2b9008ae7472931343a0ed..3e4015014a6161cc3256795438d5f63afd7f82f3 100644 GIT binary patch delta 27 hcmcb>xQCJZG%qg~0}#Bf^_$3T%osh<-e6+0F92v32g?8e delta 48 zcmdnPc!81oG%qg~0}x!@?>>>+m@$8%y@7~sN`7*7YLRYoer`d2ajI@wYGTR6d|v=u C77v*K diff --git a/product/tests/test_serializers/__pycache__/test_category_serializer.cpython-312.pyc b/product/tests/test_serializers/__pycache__/test_category_serializer.cpython-312.pyc index d2adbf91d84bc0b91366c7ee33bc60d543bf5899..6c1202da331dd96e0c97adc901c4c306527506bb 100644 GIT binary patch delta 33 ocmcc3d7P8?G%qg~0}#Bf^-KG=k#`p(WA@||j0T%|n9ef+0JL)o&Hw-a delta 54 zcmX@kd7G2>G%qg~0}!0;_ey)ek#`p(WBue4j0PgQDf!9SsYSZU`MCx8#i_b!sfi_< Je=weB0s!rB6ITEL diff --git a/product/tests/test_serializers/__pycache__/test_product_serializer.cpython-312.pyc b/product/tests/test_serializers/__pycache__/test_product_serializer.cpython-312.pyc index 1f7803cdfa6b15d9f24ec4c31956a68bc621d5e5..64b1904e17294c16ecb562ae4590a959d3d3cf69 100644 GIT binary patch delta 34 ocmbQq)5^nlnwOW00SI2#`lazPZ{$;FV$7Os#$>R$ifKMG0FS{4fB*mh delta 55 zcmZqWnaRU None: self.category = CategoryFactory(title="food") diff --git a/product/tests/tests_viewsets/__pycache__/test_category_viewset.cpython-312.pyc b/product/tests/tests_viewsets/__pycache__/test_category_viewset.cpython-312.pyc index f9343ddc45e6472b64f311e18e312d51b0fef974..493a56453aa05994f559e94cab86bbe0d84d53ad 100644 GIT binary patch delta 22 ccmX>md`y`4G%qg~0}#Ba^-H_Ik#{F208NPpD*ylh delta 22 ccmX>md`y`4G%qg~0}#xg?v=KEBkxX507}3H%m4rY diff --git a/product/tests/tests_viewsets/__pycache__/test_product_viewset.cpython-312.pyc b/product/tests/tests_viewsets/__pycache__/test_product_viewset.cpython-312.pyc index fb0eeee52aaacf70f25d222f9839b8090428b447..5302a185bcdf59684468dd72809f0fb6e978ccff 100644 GIT binary patch delta 20 acmX>pe^Q?NG%qg~0}#Ba_1nn3j~@U)3I+=R delta 20 acmX>pe^Q?NG%qg~0}$+(?zNG7A3p#;CI#&P diff --git a/product/viewsets/__pycache__/__init__.cpython-312.pyc b/product/viewsets/__pycache__/__init__.cpython-312.pyc index 681cce64c93845e9f455562d4684ff2aca97a856..1d5695c715fa01e00f1c3144b35d752701df87cc 100644 GIT binary patch delta 20 acmZ3$w1A2GG%qg~0}#Ba_1nlT$_M~7fCR_@ delta 20 acmZ3$w1A2GG%qg~0}y