From e9c0fd64069fab74bbede8eb3f09c1dec3bf1518 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 5 Aug 2024 02:04:13 -0700 Subject: [PATCH 1/8] added something in the README.md file --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f1d72de6355..975f536be4d 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,7 @@ No known bugs at this time. ## Authors Alexa Orrico - [Github](https://github.com/alexaorrico) / [Twitter](https://twitter.com/alexa_orrico) Jennifer Huang - [Github](https://github.com/jhuang10123) / [Twitter](https://twitter.com/earthtojhuang) +Kyakuwa Peninnah - [Github] (https://github.com/KyakuwaPeninnah) Second part of Airbnb: Joann Vuong ## License From 2d13356a95934b1eae83949fa5a8ab4156ec9e05 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 5 Aug 2024 15:30:38 -0700 Subject: [PATCH 2/8] task3 --- api/v1/views/__init__.py | 16 ++++++++++++++++ api/v1/views/index.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 api/v1/views/__init__.py create mode 100644 api/v1/views/index.py diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py new file mode 100644 index 00000000000..804bd4d5849 --- /dev/null +++ b/api/v1/views/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 +'''init in views''' + +from flask import Blueprint + + +app_views = Blueprint('app_views', __name__, url_prefix='/api/v1') + +from api.v1.views.index import * +from api.v1.views.states import * +from api.v1.views.cities import * +from api.v1.views.amenities import * +from api.v1.views.users import * +from api.v1.views.places import * +from api.v1.views.places_reviews import * +from api.v1.views.places_amenities import * diff --git a/api/v1/views/index.py b/api/v1/views/index.py new file mode 100644 index 00000000000..59adfd09be0 --- /dev/null +++ b/api/v1/views/index.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +'''index module''' + +from api.v1.views import app_views +from flask import jsonify +from models import storage + +from models.amenity import Amenity +from models.city import City +from models.place import Place +from models.review import Review +from models.state import State +from models.user import User + + +classes = {"amenities": Amenity, "cities": City, + "places": Place, "reviews": Review, "states": State, "users": User} + + +@app_views.route('/status') +def status(): + '''returns json status OK''' + return jsonify({"status": "OK"}) + + +@app_views.route('/stats') +def stats(): + '''retrieves the number of each objects by type''' + result = {} + for clss in classes: + counter = storage.count(classes[clss]) + result[clss] = counter + return jsonify(result) From e2f21a18e5b40830b37fe3fba6c294c115306d80 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 5 Aug 2024 15:50:16 -0700 Subject: [PATCH 3/8] made changes --- api/__init__.py | 0 api/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 128 bytes api/v1/__init__.py | 0 api/v1/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 131 bytes api/v1/__pycache__/app.cpython-38.pyc | Bin 0 -> 1053 bytes api/v1/app.py | 33 +++++++++++++++++++++ 6 files changed, 33 insertions(+) create mode 100644 api/__init__.py create mode 100644 api/__pycache__/__init__.cpython-38.pyc create mode 100644 api/v1/__init__.py create mode 100644 api/v1/__pycache__/__init__.cpython-38.pyc create mode 100644 api/v1/__pycache__/app.cpython-38.pyc create mode 100644 api/v1/app.py diff --git a/api/__init__.py b/api/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/api/__pycache__/__init__.cpython-38.pyc b/api/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2744ac8c3f5028088687a74b5f82fbb3c10488ba GIT binary patch literal 128 zcmWIL<>g`kg5!Q0(?IlN5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!Hjeo=mYiN0fI xkyD;id~!~HUTS=qv3_Dfrha^UW?p7Ve7s&kg`k0zUtZX(0MBh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o2BlzbHSyMBg#9 z$SKb$J~<~pFEzf*SU<5KQ@_kmKR!M)FS8^*Uaz3?7Kcr4eoARhsvXFL&p^xo07DQP A4*&oF literal 0 HcmV?d00001 diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6c407bb898b244e01552781c7d6808aec83375b9 GIT binary patch literal 1053 zcmZWoy>8nu5Edm_mTW6Oj+1s2(8(QQ2Ti9IMUwzUx+Fo8q5u~`H7~Yei4;iMNxY_O zwmv{IcI?`r52CeGUZGQuOp6961s*>hkH_zR^dXL04vvpU-_D+Tj`P!O9*+iY-r`h0 zP%wu&j4-z#rAyt?qh9G#pBSB2G|GSm7W+lB3~6X_qln5DZCM-?ZQ2GGI@g585Z^9A z>y8iy0*G0Yg)GWRPFU;4rOObXudp`je0I=w6>YmLz9VdjEn7_&I&5X?%J0y=U1O^( zx^rpI;x1c5ypH!bpa<)$$JTE=d_6dE`WuVrU6HA2l2z3`hU4_Tx?weSTxL^9C8$bp z1$FaW37(%_^-1mT9Uh(yFp~cwGbT2&E&}anVwxo< z*VrD{F2?0Ax|58v!VumbZYLn6kafc@i|9b;Hgu#>7(t@;qfW;Uk-=EQ)~r) zB9yNEN=QvZJ&}+xVErd`GfkNop`XT?=^kkw`Nxg6tTr79sigT^Xiy3Ug|aoE9Zc!w zd~4ITi) Date: Mon, 5 Aug 2024 16:26:01 -0700 Subject: [PATCH 4/8] made changes --- api/v1/views/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 543 bytes api/v1/views/__pycache__/index.cpython-38.pyc | Bin 0 -> 1051 bytes models/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 431 bytes models/__pycache__/amenity.cpython-38.pyc | Bin 0 -> 931 bytes models/__pycache__/base_model.cpython-38.pyc | Bin 0 -> 2471 bytes models/__pycache__/city.cpython-38.pyc | Bin 0 -> 1037 bytes models/__pycache__/place.cpython-38.pyc | Bin 0 -> 2530 bytes models/__pycache__/review.cpython-38.pyc | Bin 0 -> 1003 bytes models/__pycache__/state.cpython-38.pyc | Bin 0 -> 1356 bytes models/__pycache__/user.cpython-38.pyc | Bin 0 -> 1100 bytes .../engine/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 138 bytes .../engine/__pycache__/db_storage.cpython-38.pyc | Bin 0 -> 2847 bytes 12 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 api/v1/views/__pycache__/__init__.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/index.cpython-38.pyc create mode 100644 models/__pycache__/__init__.cpython-38.pyc create mode 100644 models/__pycache__/amenity.cpython-38.pyc create mode 100644 models/__pycache__/base_model.cpython-38.pyc create mode 100644 models/__pycache__/city.cpython-38.pyc create mode 100644 models/__pycache__/place.cpython-38.pyc create mode 100644 models/__pycache__/review.cpython-38.pyc create mode 100644 models/__pycache__/state.cpython-38.pyc create mode 100644 models/__pycache__/user.cpython-38.pyc create mode 100644 models/engine/__pycache__/__init__.cpython-38.pyc create mode 100644 models/engine/__pycache__/db_storage.cpython-38.pyc diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a96bdb3bfe37d96ed5537b083a6902f1df0f2353 GIT binary patch literal 543 zcmZutu};G<5OtEKNlL>2hy@{aEkmM;6(Pt6AR%DMatg64S-6g6C!zEo_z(sLekUsv zzre&LM5w8-<$Jn!Pw&q65QY+EJ8HXZ;ia)8ENip)G|8@(DIKxQij zpdC!p19XV$MbsHaTvE194+oqnvyzz|GUp{n@_3*`Tb#Y+hpv@jde=aSEJxwVz~Gkz z&AMsQ)BlQpP2PwO@CRM^j$&ODWqi$bA`{3(AsN)?{d(fgE(T~<3lOQ7#=lq;F)L|bl^C~E0tB^0H*4&CD24YoIsC_R;* z!J$2t8-K@FPW%NfFrGvZyz=;)&pV!n#~00Joxpf|_I>o!Cgg`vR)-JDOPKN-h?K-6 zrK!bfZp9Wg*yeWb#13MIySW#8h+XdIK^!3VcrCBTb;LezkGN1@fI>`z_inKWVX}JIq7c9 z!mLQy=O{1JinE^(J?TDTeQvfrmLOGG$ojc(J-~ z_%Jbh-WfB-fZTI6REBacBokc^PDZngN$n+>!gXxSr1k|`!G<(OQo9w{$eG_adLZB}zt@(@0Intm|k$;X^5z6vnA`ld>w5Z~%90?Fl9;uC$YI2^GgZCjON` zY@v;*m)rp;vF&Y#2DC-%R6GIhb@!3>2ZOXs1_K>Jae9;e9u`NKQfPMs{y(5c?Ll8L zz6__MPiSzGSrf)<87_n_= xSCo}vctM!JO1gOWm~(IdKHv$wFgeI)ARH^C@GYc4G=xG}1i#;&6VSRF&_9Sk2Z#Uw literal 0 HcmV?d00001 diff --git a/models/__pycache__/__init__.cpython-38.pyc b/models/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8911f22cde87955f378fbd7eaa03eff68773c03c GIT binary patch literal 431 zcmY*VyH3L}6t$g~8(ImN5DOjY(hM*n1QCT!1@$rD#Y$_pSassc36<#DFW?VgWaE3X zGVu#c+|UZam3*Xg?zuj`9yJ;vf*L))PrDeQkBa;)0^|Zt-UkqfA%O+aI3rJ?25rTO;OY`=I$cNGYSB(Mps4OYIe5B!U5I(bZ9?GF7NVtCegP z53-pWA$8tdB$IhEli?=>qZTgxnJi?sWP9DX7xUr$U55{bxBbhTPD#WV47ICxP#6m{ zKz6Q`mRs6ug=N6GFcZ#8Vscw8#cKJ+%nNp~iEPVkrZU+UW4`TK7o26VW$f_3Zwe8= zPOozMR%(-oH)N|{{eiFJ$Qn~bm&(Rj%qQApk}pr9%~cWS)%KjX7f&TU1MyMI^Xh&1 RE`aOS9ZD#!V@m4S$KL`ebGQHi literal 0 HcmV?d00001 diff --git a/models/__pycache__/amenity.cpython-38.pyc b/models/__pycache__/amenity.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..029b74015f8f2e7d12993dfc417562d29c7207ee GIT binary patch literal 931 zcmYjPO>Yx15VgI|ekFl^9e`7AC=yDLxFSRgf)gC5dhx~D#7?@ccQ>^+MTvSqYNeh) z;%D^6@9~vW{{kmwc0-9JzZuVXJ#XI5Nxz>GSSLS!&0aD>e&b<#b>Q$8wwnMbB8Z}j z87e5)z_20^LBR#580V%_gd%KwW+D+mtYe}g7IBe?q=|p=5s zE_#X`lVP$x7@Sr{xxv(A&J7L=UFP-b9;%biL*|pC%;`^+(#CUiht!92UF-4^lHt3` zEQ`{I$Fm#0xrs%3OE?i-pr86^!+8Ddi(XjmbXhk92G#6eGXu}mL?l_$ zTCUywHz@yMNJU&OjmaiPdoraPZfJtdehk*_0o3H0oY5 literal 0 HcmV?d00001 diff --git a/models/__pycache__/base_model.cpython-38.pyc b/models/__pycache__/base_model.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9fe6785cb21111e51699f971dfe855f014f3a2f3 GIT binary patch literal 2471 zcmZuzOK;mo5a#kFnwDk7O&>A(V9~gVg2V=z0tEsmO_Km^4s{PnfRs%@(Arf@nIfI# z%B~d|DBxTRr2oJ==GJq6${u>@DSx4t_M4?_%WVYgaA$XhyYtOALp@qp2rc{`{q}or z53|2Wnf*CXZevuxKyWLzIOBHC1}tWb=1y+MHlA+o4BXhAu6ePCH81xDe(Vn#abpm~ zf!Xu(xj`6*Q@i^j!jI>f^ci|2P_Hb~`uvMu(3PlJnII?PpyBFXvpV}qWeXrvNX>|U`km;WiL{|oCp&Qh=Y1ANenHMM2B4| zz%ZVqYD0&^9bzRZ+Rk{VrM*mvL8Tj&P^nT<(_QOraK&FTze$Hl#5vDc-pN*-qUU>pHE9D?nvWa6Tk|G_5Br#}_%Cjy4d(GrB_6;<( zh{(K=B!E9jzJOBs5EkNd{~4V-IT-O7i~og3tuiE%s+8$7 zp`AkPfgtIwkSkdPF*Nt4H70z#(brO-iJ|$Y5v2`9 zh$arVo@dX%E6f$G(op?Y;(qWE5@wCL8gWuP%^h?kNo1+(i-~YgD>0}J{-prndVO&YMT9xjw3JOJ@PVy_G{O-@?Z@H_c1C; zuw{?hryQugHahPZ9CVmaml)=#DBVnw=fgCw>x)Wk zs%Cgg-LKBjr!@PV1kqBilAw#tKyBz7(b^mYrKma&5il1`sEy{-vV(U6FYtq=vFMzW zRLS*m=3aJLNdj4i)$=^fyIW$gKXXI6T)cd`wJLsAt26%=WP@J!0SQBp>+~v@(9(Xn j*%w`9&VAdJb+BF|cZ)!-=pC+0%%E|er0o)CY}ff0Q4L_q literal 0 HcmV?d00001 diff --git a/models/__pycache__/city.cpython-38.pyc b/models/__pycache__/city.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ae5db6b2f24d2f5f80ed8f1dc8d136bec9e59eb9 GIT binary patch literal 1037 zcmZ8fy>1jS5VpO({kxwe2n8rWSI}H@DQF`Ei4+P%gox6(vG&%!%O>94i@g_grxZwu zlqyI(MmpYuH*iapSD<2M6Ch%w`F1=r_Ixw5hy8v^Kn}lspZ;Kk{KUgU>A>L)sG9;P zB8Z}j87e4z1H;Nd1SJ=oqMw^i8H%vAnTbRMzK)5?Sj1%_k}?%(8w*Xh?1>&F?}&<2 zd`VQS1I;hE=qq+WM#*YpcvKtZhPla{8}1g(@)pXI{SouYPUiH7T501snj`ANnQnA- zHVS;WTbo5$`S75zMK$y3UTt+TtKRD+3AD(>1?+x{dloZ~26 z%MI_hJ>}XMDeY6d+5)n+&kz!TE@(T}m~xteZqju+V4QN+#zzDD9CKd)_>DW7;|cu7 z*poIE+qbwM&uV8m8mT)qnaPiIx%`i|AN&iAYg@Lo+cFRMwIq?BkGJpU_8N=00RX2l L(CYy{roG@db4dn2 literal 0 HcmV?d00001 diff --git a/models/__pycache__/place.cpython-38.pyc b/models/__pycache__/place.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fafd22dfc24f70d8291644369db2207e14fa7479 GIT binary patch literal 2530 zcmcf@%WfP+u;;P!+Sy&d<2XUA1VJnWn+PRBC_*?+j1U4vd0bjTquK5DdhB^@x@R4B zwU&?^DJLWNgX9=ad;%ZAsjr;!3m_g1(Kki%$ z3Hb$yvk&mdCotqs02rZ!8O%%#YQWb@&CH@!W>echzMVEQhdLTJQ;z z%{s?6%*~z7&7Yq;vgyL7ge|beCxk6>i`&3i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!^;k z=SAs)!`kHK)Fu0sQTep|q^`$!!MdRyGrCX-Bd%X1+>~2P#yN^cPgc zva_Jb_?yR*wQTg5?Y7x?wP!pnQwd7JyWr^^nNZo4>21V&cf=?B38?M4U@5S9aiC^K zSyk3qomXYQnyjSv9h1i{G;JU3!!FQm;+f9I$_{h64-JUQxz^dSR!uaw%3wN&0>qIq zMTsl(U`5{mx0?VpS&&nDLvPr3in9Vftl7-Vyv{S7H|k&WvF{x_pDE)aA@I2n&~4u; zJ#l_!rq%^#m$=?j7Yor2PKbN*=k>@`RXuv2o4s-m@>QwC#hX!q^RuI+q~Yw^Af+9o z1z#Q^tl3yLW%yWa11pzVp@eXW5OBd(NhpM@#*hw{6Rb;}IjZ8eRR)J0pK6VZUaQr zrwRBD{5F{nkT1H65MZ3!ey~X=%3gFX-KBXz(w)Yn#A^bT2 literal 0 HcmV?d00001 diff --git a/models/__pycache__/state.cpython-38.pyc b/models/__pycache__/state.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dbefe8fd6b26d16a7e774d1fd63ce6c4e032dd3b GIT binary patch literal 1356 zcmY*Z&2A($5VqZ({+pgjc3H%-Tv|d1%_TV?p*D+&L~&TP32s9;w!J;0v7VqjD_r| za{9+kX%je_GaC4D?XO{um)h(0Y8Hj~xHIdf4e^P$b-N7ti_YqL+5Vt0uCUrvzV2Fg zR5zUI zm^uw{Z@ag@1F{!DByHEmRHsH;1RX}b8}^gaYJOq$B9J)+$GZ`MfwBkU9)t4amYmZq z-LgL^mIjcp&7-=leO;M)qup>hrhVkrD{Vt6CAy`ABy*?DBJj#CU5GD!!}$#jnUsCm zq`9SUz{y!#!AC+YbQChX{&+B5X4~LCy#7?)o1I zWQuYO;+}(Ak{jxQ#y#`VYkI@B?4G|S-;rOQ-9+2ye6%I!F%<3Tmfj~@h@j*WY@kXv zUqZupZOcVxOH(_K>7GL`m30f)+BqbkZxyXd-s zRb|%Ng|w$9YZVwsT&-5RRWoj%0A`WlH4^U>Ih>TRtl@iJDl`e z_bg5F;1TV+qCJO)WX+92sInNr!2-J6K_Ziz?u zHq>Lwd02ww?tz*cWmQ=>8TG4aKkF|b(sxXbxsR&7zk*agLgrDq&^jAy_09QTbv9AX z!vzot$Jyk>sHqDM)LE|19huN|A#j2x(8w0db_bv)*W{R9(o6P(VgrE^TlVrYuk%dj zOJy4p*c{(3=E}H82#g9bXgSX+J#}7YX4VBK=Q!U{7Yot!R){u#_&I2=1LnZlEF?oR#}7Z+$Hu@XL@p^ii?fpy8pdy_pz%gB6>mQVH8T$YL literal 0 HcmV?d00001 diff --git a/models/engine/__pycache__/__init__.cpython-38.pyc b/models/engine/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5730256fa17e656d4c91ef094f849f58cffc86a7 GIT binary patch literal 138 zcmWIL<>g`kg3yT@(m?cM5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!H%eo=mYiN0fI zkyD;id~!~HUTS=qv3_oTN@`BAerjHNW?rg(e0*kJW=VX!UP0w84jZ6cX-=vg$e_#9$_~5|fzF+KH9g#5U39Bu?rQH}#08zulyk`o!0|m(&GD~J*{i$R&og;JF)=b_?&yjQKJefBQ zZgZbEc$2qzm$iQJ$obC=)@Gd-2J1Yx$OUGt8olmtp>ZeAR2XM6P@6o6l2FRv?#iml zMYzEmf57gHe$Omxw^N?Q>Y!(p^_5Wa2RY+O>7WX|&K>MBOZQ&X#-R6~>l*YyvHO2y=b7@I@w7n5h`>4#G)*gM599N2=`HU+J&V2j7FY zbZzzCqq2R<@bJ64X9nE=di8PHIyK<#O6lv*d;M>Rm(l~dn_Sb9t>0K$dUkl@+2QiD zLr_XbajE*fn!xN5Qy@xjkc%`_1JS`{ zx+tbm%%GSB@zM|%p!xH|C6VW9>2@quvK1O7dB*Af^`#WqE0-$bEwObfE50x89F#t# zF)*Fd%dmjF2*R*@bNqOwRXuH!33sVl76*CCwdDvcQM~NhU#-CCaM~XP`DTxCtlcf!^w72s-0 zRa-mxQIw}?tOD3z5N(Fp2A4rT_+O3^ubTVPtb9eCP6;(3ma^F$!| zGy}-gs58RhSocYDWZA)sk-oN&*2pCE6-nP>PKLoD4VMTE^~qX$aBb2ToYKmrJ~v4N z4%je>HhFrW&rs5y7#86)t>~tS_cr>5n|mEDrGFEA0qAdGd6Msfa2y|sZWrFkqb*RD MEvRDf{Ovja00aWAegFUf literal 0 HcmV?d00001 From e20e1255713553f08de01c2ef900d3aa1174e6f2 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 5 Aug 2024 16:33:38 -0700 Subject: [PATCH 5/8] made changes --- api/v1/views/index.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 api/v1/views/index.py diff --git a/api/v1/views/index.py b/api/v1/views/index.py old mode 100644 new mode 100755 From b81aa25ec603e6d67611a1bd9f080cf0d8740e7f Mon Sep 17 00:00:00 2001 From: root Date: Mon, 5 Aug 2024 17:01:28 -0700 Subject: [PATCH 6/8] made changes --- .../__pycache__/amenities.cpython-38.pyc | Bin 0 -> 2211 bytes .../views/__pycache__/cities.cpython-38.pyc | Bin 0 -> 2451 bytes api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1051 -> 1050 bytes .../views/__pycache__/places.cpython-38.pyc | Bin 0 -> 4673 bytes .../places_amenities.cpython-38.pyc | Bin 0 -> 2387 bytes .../__pycache__/places_reviews.cpython-38.pyc | Bin 0 -> 2714 bytes .../views/__pycache__/states.cpython-38.pyc | Bin 0 -> 1981 bytes api/v1/views/__pycache__/users.cpython-38.pyc | Bin 0 -> 2123 bytes api/v1/views/amenities.py | 77 ++++++++ api/v1/views/cities.py | 88 +++++++++ api/v1/views/index.py | 6 +- api/v1/views/places.py | 186 ++++++++++++++++++ api/v1/views/places_amenities.py | 98 +++++++++ api/v1/views/places_reviews.py | 108 ++++++++++ api/v1/views/states.py | 70 +++++++ api/v1/views/users.py | 76 +++++++ 16 files changed, 706 insertions(+), 3 deletions(-) create mode 100644 api/v1/views/__pycache__/amenities.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/cities.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/places.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/places_amenities.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/places_reviews.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/states.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/users.cpython-38.pyc create mode 100644 api/v1/views/amenities.py create mode 100644 api/v1/views/cities.py create mode 100644 api/v1/views/places.py create mode 100644 api/v1/views/places_amenities.py create mode 100644 api/v1/views/places_reviews.py create mode 100644 api/v1/views/states.py create mode 100644 api/v1/views/users.py diff --git a/api/v1/views/__pycache__/amenities.cpython-38.pyc b/api/v1/views/__pycache__/amenities.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e9334b89b29ea6f018f6fa355ee80c9208b607d2 GIT binary patch literal 2211 zcmb7FOK%%D5awea(t4%X&O0#*73c#C1XhCfP@smQ9&iX%j&O%W0Rj8O1fvdDm$>UAOIay|&l&+rB+_@=CYbuG+Pm z2i=wS3MDCf779=Jhg4KV^?NP?vGS6f(ss>C!X?RdQ5P3pQjpcBvemiO4Y4NHt?a_| z#*1^=C2`r_xH`4EGMC&GSH(4JwI*u2B-$8VOuA_=(^;w-`}uL&mswArLzpC@rkeEo z@gPfIsK_z?Ggb7mgQ0Pg{X%Nv%k=qish{s-AMAhF@Lj>43aEQ_VcuZ7tTHg3%q<6hPnjPAzbz(JfUNH zMkeGZ_T1SezakXAE@A;bg4=BKwsG)g8G?nKUNxJtD0K5~Chzs`#htw9rSagSX421^ zgF8(N;R1lo{?G(ld8Txy==Qhk_&9pu5k^K0@O|#~=2l*Gl3Z=WVx}Is(g$V3AwUV) zN+idvH%Nd!716ef=4#=bTt#`fd@rWEeUk8iN(_8-b>Uxgt8`!(XJWhcR=_M9pMc#M z^8ctJS2Yprlv1MU8Pj}BCJaHevRiYR1F*Ui;K{PI4j!o~MZ?Dau#t(@`7c0Ef)(( z4nX$@YAXpShZ9fxKz{}47ajr=`J;>dLSYUxdg+S=8b3k~yb4+c)NteL-G?pX^nmVB z_-&?C);nzA?)(q%Dym9s&87lu$Jm}MD#kfVhpNn(4G=GZHq9PqzYxQ>=FJK^G{x)| z*ea}@GHC+9EwH%B58=%4N00Yj%bK!;r=99MQ2Bqgft7K>#?02t1E?7;9E5Vr&OGdH zPc}~YmV7>Ah%xlMek=UG@gKV=+Ho!~yE=&P0##bRC9lf;6J7>EF8X<5(1(I5r{l-_60DP1}DZCbe-7 z;5X)IQ9`BvSXRdC7Em*)Y&-RGvk9pNzmCJQ7F}5!>(us3+dORf*le&qEJb45k?p&c pEx748Pq*=T^)XBi3+XlRKIE%3@I2~J_P4{sV7^+Jt%7j2`UmmX?KJ=Z literal 0 HcmV?d00001 diff --git a/api/v1/views/__pycache__/cities.cpython-38.pyc b/api/v1/views/__pycache__/cities.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..555f2bf530de22996c02e2ab78401162b02fff70 GIT binary patch literal 2451 zcmb_dPj4GV6rY*>>$ROaNhwV!V4wn)R&fg#4pszhQvL|sN^UO}m9_C~l1iIBgsGk-bI`2=qH7c`u72&bH-w9h(>qHU#C-|pCbr{nb9j@$P-o_TMle!tWy z8QV#Nez{XNwwqS^)lQX?nC&ibkNew{mw51_#jo%RuRf(mv~$7u7Uq1f@e90We6{Jk z#o4^8e2Fg`-{N%M#hLGQ{tCZjd`r`Lug-jL@XLI~_?CIOO~NqHb}Nc+KDzZp|mIB$NRBVy4sKS;;xA0FdN7irg>6j zBHBjNX{$(~Vc$vAXuQ}cKGkT#bJR`vnzlaMcyKpl+Uv(^C*x8tNF|b<>dG{dJF#r_ zC`L2A7(8vb@4ziTh9(Cx_Iy!OgtH?`iJ}vxtehOPLz+|LyD{_GIh{Di&1}A5H9U_$V zC`}P6)JZa^n?UAKs}Cb7W8M-~`0$yqo>SHahs1ogA+Sdkq-R2o$uI1&-7b&|ski`s zfR(M@6pLUQK#OJ>x;kj4iB!F;KU{kY`V!N12_xfc1&R>e7Xu@?)n=OYqExPd@qEfW zr(yw@_i<6TNXu{=TH1dOvSw0ste%qRqo|$#*d>ew7bMOpcP zt&=}seM3v=8#x!Lqnx!{jMcV`4r1ZrKva>De#k@($5^nl&m#~N^H8_fV9YFcRBZtF z0u^otk;w?NcC(L*b@CMAPmpvquZupDq7aSTi2Yr{;U*6V}#Nl_S720b~9d&ySP zD`a12{N!h-63>EGhBf5N_Pv(22T?yBSH4c9Oa|L^?1{^e;mM!Sgw@k}a;iOn$Bgzt zPhG68+TM#tQnQ2?)#eTG&aq-Phi%prD>%{K%=k!K+2-zff_zK_>G=@G$*a)JNt2;S z11K?p`9Ybvj;mSsAO4ps)P&*cJ23tqt_r5s$)l^t26uq7mhy6%TRF?E6>?-z^0)=n z!8bgWQ~-9_@C2*^Pu_T8f5@>S0`#zXM+GC|Z3t1k15Id)_u-*~o`_)>??y@o#T2v) z1QC?5a-J1a<&hQfE;jGsGMimol zpDtn5zXjfqw$A)7YOmYnS+CpG6*x*(4{oiRqeNhR)y@{2mV2k0*9glgP&ESmB6JoW&hY#rThYGxkmp59Bmrd literal 0 HcmV?d00001 diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc index 4f43c81c084358cb52cf70f4cd6507e142a6868b..d1468d49d050963c3d90ef7c6b5b080bc80bba1d 100644 GIT binary patch delta 31 lcmbQuF^hvYl$V!_0SF9JH>N3UE?0KDD9}PJiXg}$kaqR5+b)Wti=zDlT@148%A5RvERufbTs|aOP8^^l@9^9? zGiT;J=A3Wt77C$-&#%}2a=&@Tvi?gihd&-(euPJtY|D~X)snUpExRqM!Y0~jIc>M< zw!Ny?_N#t7s0Q5cwleK(HQNrWA-{XATsvRQGwrtu?P9gabkLe=m#PpBS((;!d!{;L zTanl}C9^VIw`ES|f9J?oWKm8%wjbHmS>}}v@yc>q&M@!vkauc4?^QV~Pc!e#Q0AF2 z@2s4AY(e5#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9@i$sFZ~> zVu0+A+Y;v#>Ry|3Wb__+@8xLtGO1XHV?T9}qH+~gN z7t15uEWN)2&KvySht1VzAS|bDcnS!-X-O6%4d99q7x@Cp8bDatL-u?suc2$~!8dE` zXW&6_rtoO!{Lk<_D+r{_g-RCZ9spw_1e0{31*#jt>IQh!5RWsn9879@s{lm%0qpVf z8LLS-T3`?R^?UHLMqY`dba0xCJbMKf@&ky&@$Vr16At9!gaFyV?gEMrQ6L{JW~h)? zao{5qEfmwzS=NsRIyO%DdS=pn7p5t!4<_9dN(L>{T_p|Z`DC6>G}(q(Ewb98t7W^O zy>6Fhy>3?rP=gnDuP>S!EU|8AX9IrI28P+Pc;e5QIfZtU4B%6yoR&p2C`T3z$mVY7 z+IVOOeqkm4pV719kum0F(RF0DlM7Sg41LDSQwKL8FxAsvg7rJGSVs5M#~>J-@G{_y Ug)*>RK$-r->|lPXy*ttV1&q=+j{pDw literal 0 HcmV?d00001 diff --git a/api/v1/views/__pycache__/places_reviews.cpython-38.pyc b/api/v1/views/__pycache__/places_reviews.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..39dcf6e0d2fef3c0ad5b4f2b4ee24d5df0325bb5 GIT binary patch literal 2714 zcmb_ePj4Gl5Z`_K*XuuV()3T#mKvcVjKHRX0|zTAp(zxBTQ$uAi^|&gZCod7ulwFh zO03N(6*mwdK0tEh$T#2!U*TOj<-!N(0WmXcJ5C!8m2k3eXWzV8&&=;PGu|i`0|P## z?r&QgdBgY%A7(!eJluv${tXK^S_U^ci_Mk^cPnOnt7VzEXUBHmX*qqj<@UXn*Y{gK z?K^R6-F1F}FOqI?{LYJ0-6ekcxdCsyIJUYn)x5!%_%c~t;%wch z-Wbh`Xs;JNla8x@e_M$uN%J_m`RniIYbW0V6_jl1@9MgU_i@@kLn^xRQ;2lSRJgkJ8?3I+It_? z!(p$!cdJggjk65s&|_`5uY*S1ld6;ShbwQO1DHJ5V8-YsMDZ{?cW*$r)f#cq31hhe z!o;SU7ib|o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IQ~9i{^@sr`^Cl@0fsI6D6ut{hh-ri}@K2nnXL zarMba7}rt|BWv8AI8hd4c^}4Cux;Q5j&XN$eqva@dw3Jv2ybekjlor+KVczV0dVn$ z@XF7?X4s3DJJ)!HCu0zwKvTbgnCEjtlX)i6siWByeuZ-Fa?V9`G23nSJ_9=-e+I}y z{`)rn*C78H_j*jWq4(!~fV~b1TClRDJ|^mQ4`G$+)R>r2r?Mq}o)<1*pq=;1Jg=NpBF^hDCmiyL^hf1WG`jYWcr0 za7%t8$npVtGl<#EU{uR~9Pq_z1PZo(Eveen>_RZS2s6sc9@6Kg=psxSIbzMOwuR;xB>rPiST0W)9AT>t<8 literal 0 HcmV?d00001 diff --git a/api/v1/views/__pycache__/users.cpython-38.pyc b/api/v1/views/__pycache__/users.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..852287c8ada8ccdfc307291ea6463aa9deb7dfcb GIT binary patch literal 2123 zcmZuy&2Ah;5bo~z-PzxSBqUJ;8-#?HL|y`%kY$AsLqOnIvMr&NqS1J}?Mytov*~U- z+SU5xAaMx-i3ji=b40uX2Y7|Pa`G$WfT-%3-Pn*BPj7W~Rd-i?UzNA(^@zap`|fYM zKZJz*jgzyF50ks_sXt)gq(?aAETaR~V-#g4a|UkD9e6!&;P?DN&g8%uFY_zbtHrCEq;q}JJWxWa_D*&nMlv1hQwWW8sHr5QQGA$+XR70x z;EBqI>F(Hg$xbe{38Z*>Ae1)sL9#DmDby$*DgkbR(z#6bP;|Fp=ZW972N>t8wXH8Z z%mf3WALm?|hSDsV!pdMwnWRTy?x&^}K2>Uy8zUCPISUl+bF;8PngOd;d@pQSFGrd1OX@VNcyn@)C0w=se~S8-&Z2KQb=v zC~M$hhgY|{GS7AQ^Hkm&-i!NLJ{0lcC*5R}b`S4#ZO)5aERV(}TFFwS`}ttBdJzxC z9QcHh$-8jbZP@tU_-nqrlI8s*Q>!4%txtc2^mRfRfP-<8ER#TKA~BD~KTH5`WgOT; z;*PQoL&q^enSA4+pkx!*7B`nIbgrH`80$qfU?6@-BYK6^Xb7*oiiZCEwQtw9*3Q8= zPojnK0a#fWD{`fP(ZU1?1(*t*Go>>GiXf!$>uEm)xHvmz0Byh>gpnhB?xe{@CbUrP zWN1NLKm8L9keIeI5Arf9Fb~ErjE$?3Lm{!UZE9>bI!sNxqY>ME$ zkYeBwd<`n!L0@;{;pSE!q{VYC^eLz@7n#j`SB zKLcf6MeDf+?Khhb*I!ao-O2g*jdTn#41{9| z9Bo|^fa4MXQoamfk+<;%&c^oEIXV{ARCbjg!KCaeElq%8NIZJNpi5x)C};&6oHGq6#3Ho{TVN5~2ZYvm$> z@+qu#=z95g!31&4^L`wg8Z^V@!#m5i8A_}i3)_=yZCWnav(H@LHaXkh!WG!zAQP*2toj%R7uwoYq?6O4K6NSk$8{RD Nxm2sprKmZV{srku;r##r literal 0 HcmV?d00001 diff --git a/api/v1/views/amenities.py b/api/v1/views/amenities.py new file mode 100644 index 00000000000..b44bb912891 --- /dev/null +++ b/api/v1/views/amenities.py @@ -0,0 +1,77 @@ +#!/usr/bin/python3 +'''amenities blueprint''' + +from api.v1.views import app_views +from flask import jsonify, abort, request, make_response +from models import storage +from models.amenity import Amenity + + +@app_views.route('/amenities', methods=['GET'], strict_slashes=False) +def getamenities(): + '''get all amenities available''' + amens = storage.all(Amenity) + return jsonify([amen.to_dict() for amen in amens.values()]) + + +@app_views.route('/amenities/', + methods=['GET'], + strict_slashes=False) +def getAmenityById(amenity_id=None): + '''gets amenity by id''' + if amenity_id is None: + abort(404) + amen = storage.get(Amenity, amenity_id) + if amen is None: + abort(404) + return jsonify(amen.to_dict()) + + +@app_views.route('/amenities/', + methods=['DELETE'], + strict_slashes=False) +def deleteAmenity(amenity_id=None): + '''deletes an amenity''' + if amenity_id is not None: + res = storage.get(Amenity, amenity_id) + if res is not None: + storage.delete(res) + storage.save() + return make_response(jsonify({}), 200) + abort(404) + + +@app_views.route('/amenities', + methods=['POST'], + strict_slashes=False) +def postAmenity(): + '''posts a new amenity''' + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + if 'name' not in body.keys(): + abort(400, 'Missing name') + amen = Amenity(**body) + amen.save() + return make_response(jsonify(amen.to_dict()), 201) + + +@app_views.route('/amenities/', + methods=['PUT'], + strict_slashes=False) +def updateAmenity(amenity_id=None): + '''updates a amenity''' + if amenity_id is None: + abort(404) + obj = storage.get(Amenity, amenity_id) + if obj is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + for key in body.keys(): + if key not in ['id', 'created_at', 'updated_at']: + setattr(obj, key, body[key]) + obj.save() + return make_response(jsonify(obj.to_dict()), 200) diff --git a/api/v1/views/cities.py b/api/v1/views/cities.py new file mode 100644 index 00000000000..9dec1573536 --- /dev/null +++ b/api/v1/views/cities.py @@ -0,0 +1,88 @@ +#!/usr/bin/python3 +'''cities blueprint''' + +from api.v1.views import app_views +from flask import jsonify, abort, request, make_response +from models import storage +from models.state import State +from models.city import City + + +@app_views.route('/cities/', methods=['GET'], strict_slashes=False) +def getCity(city_id=None): + '''get a city with the id''' + if city_id is None: + abort(404) + ct = storage.get(City, city_id) + if ct is None: + abort(404) + return jsonify(ct.to_dict()) + + +@app_views.route('/states//cities', + methods=['GET'], + strict_slashes=False) +def getCitiesInState(state_id=None): + '''gets all cities in state with the id passed''' + if state_id is None: + abort(404) + st = storage.get(State, state_id) + if st is None: + abort(404) + cts = st.cities + return jsonify([ct.to_dict() for ct in cts]) + + +@app_views.route('/cities/', + methods=['DELETE'], + strict_slashes=False) +def deleteCity(city_id=None): + '''deletes a city''' + if city_id is not None: + res = storage.get(City, city_id) + if res is not None: + storage.delete(res) + storage.save() + return make_response(jsonify({}), 200) + abort(404) + + +@app_views.route('/states//cities', + methods=['POST'], + strict_slashes=False) +def postCity(state_id=None): + '''posts a new city to a specific state''' + if state_id is None: + abort(404) + st = storage.get(State, state_id) + if st is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + if 'name' not in body.keys(): + abort(400, 'Missing name') + body['state_id'] = st.id + obj = City(**body) + obj.save() + return make_response(jsonify(obj.to_dict()), 201) + + +@app_views.route('/cities/', methods=['PUT'], strict_slashes=False) +def updateCity(city_id=None): + '''updates a city''' + if city_id is None: + abort(404) + obj = storage.get(City, city_id) + if obj is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + for key in body.keys(): + if key not in ['id', 'created_at', 'updated_at', 'state_id']: + setattr(obj, key, body[key]) + obj.save() + return make_response(jsonify(obj.to_dict()), 200) diff --git a/api/v1/views/index.py b/api/v1/views/index.py index 59adfd09be0..2ac90029a2d 100755 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -27,7 +27,7 @@ def status(): def stats(): '''retrieves the number of each objects by type''' result = {} - for clss in classes: - counter = storage.count(classes[clss]) - result[clss] = counter + for cls in classes: + counter = storage.count(classes[cls]) + result[cls] = counter return jsonify(result) diff --git a/api/v1/views/places.py b/api/v1/views/places.py new file mode 100644 index 00000000000..99ba31c2e26 --- /dev/null +++ b/api/v1/views/places.py @@ -0,0 +1,186 @@ +#!/usr/bin/python3 +'''places blueprint''' + +from api.v1.views import app_views +from flask import jsonify, abort, request, make_response +from models import storage, storage_t +from models.place import Place +from models.state import State +from models.city import City +from models.user import User + + +@app_views.route('/cities//places', + methods=['GET'], + strict_slashes=False) +def getPlacesInCity(city_id=None): + '''get all places in a city''' + if city_id is None: + abort(404) + ct = storage.get(City, city_id) + if ct is None: + abort(404) + + places = storage.all(Place) + res = [] + for place in places.values(): + if place.city_id == ct.id: + res.append(place) + + return jsonify([place.to_dict() for place in res]) + + +@app_views.route('/places/', + methods=['GET'], + strict_slashes=False) +def getPlaceById(place_id=None): + '''gets place by id''' + if place_id is None: + abort(404) + place = storage.get(Place, place_id) + if place is None: + abort(404) + return jsonify(place.to_dict()) + + +@app_views.route('/places/', + methods=['DELETE'], + strict_slashes=False) +def deletePlace(place_id=None): + '''deletes a place''' + if place_id is not None: + res = storage.get(Place, place_id) + if res is not None: + storage.delete(res) + storage.save() + return make_response(jsonify({}), 200) + abort(404) + + +@app_views.route('/cities//places', + methods=['POST'], + strict_slashes=False) +def postPlace(city_id): + '''posts a new place''' + if city_id is None: + abort(404) + ct = storage.get(City, city_id) + if ct is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + if 'user_id' not in body.keys(): + abort(400, 'Missing user_id') + + user = storage.get(User, body['user_id']) + if user is None: + abort(404) + if 'name' not in body.keys(): + abort(400, 'Missing name') + + body['city_id'] = ct.id + place = Place(**body) + place.save() + return make_response(jsonify(place.to_dict()), 201) + + +@app_views.route('/places_search', methods=['POST'], strict_slashes=False) +def placesSearch(): + '''retrives all place objects depending on the request body''' + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + keys = body.keys() + if len(body) <= 0\ + or (('states' not in keys or len(body['states']) <= 0) and + ('cities' not in keys or len(body['cities']) <= 0)): + if 'amenities' not in keys: + places = storage.all(Place).values() + dcts = [pl.to_dict() for pl in places] + if storage_t == 'db': + for idx in range(len(dcts)): + if 'amenities' in dcts[idx].keys(): + del dcts[idx]['amenities'] + return jsonify(dcts) + else: + places = storage.all(Place).values() + unwanted = [] + for idx, place in enumerate(places): + if storage_t == 'db': + amens_ids = [m.id for m in place.amenities] + else: + amens_ids = place.amenity_ids + for amenity_id in body['amenities']: + if amenity_id not in amens_ids: + unwanted.append(idx) + break + for idx, i in enumerate(unwanted): + del places[i - idx] + dcts = [pl.to_dict() for pl in places] + if storage_t == 'db': + for idx in range(len(dcts)): + if 'amenities' in dcts[idx].keys(): + del dcts[idx]['amenities'] + return jsonify(dcts) + + places = storage.all(Place).values() + wanted_places = [] + cities = {} + + if 'cities' in keys: + for cityId in body['cities']: + cities[cityId] = cityId + + if 'states' in keys: + for state in storage.all(State).values(): + if state.id in body['states']: + for city in state.cities: + cities[city.id] = city.id + + for place in places: + if len(cities) > 0: + if place.city_id in cities: + wanted_places.append(place) + unwanted = [] + if 'amenities' in keys: + for idx, place in enumerate(wanted_places): + if storage_t == 'db': + amens_ids = [m.id for m in place.amenities] + else: + amens_ids = place.amenity_ids + for amenity_id in body['amenities']: + if amenity_id not in amens_ids: + unwanted.append(idx) + break + + for idx, i in enumerate(unwanted): + del wanted_places[i - idx] + dcts = [pl.to_dict() for pl in wanted_places] + if storage_t == 'db': + for idx in range(len(dcts)): + if 'amenities' in dcts[idx].keys(): + del dcts[idx]['amenities'] + return jsonify(dcts) + + +@app_views.route('/places/', + methods=['PUT'], + strict_slashes=False) +def updatePlace(place_id=None): + '''updates a user''' + if place_id is None: + abort(404) + obj = storage.get(Place, place_id) + if obj is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + for key in body.keys(): + if key not in ['id', 'created_at', 'updated_at', 'city_id', 'user_id']: + setattr(obj, key, body[key]) + obj.save() + return make_response(jsonify(obj.to_dict()), 200) diff --git a/api/v1/views/places_amenities.py b/api/v1/views/places_amenities.py new file mode 100644 index 00000000000..08f61c6836a --- /dev/null +++ b/api/v1/views/places_amenities.py @@ -0,0 +1,98 @@ +#!/usr/bin/python3 +'''places amenities relationship blueprint''' + +from api.v1.views import app_views +from flask import jsonify, abort, request, make_response +from models import storage, storage_t +from models.place import Place +from models.user import User +from models.amenity import Amenity + + +@app_views.route('/places//amenities', + methods=['GET'], + strict_slashes=False) +def getAmenitiesInPlace(place_id=None): + '''get all amenities in a place''' + if place_id is None: + abort(404) + pl = storage.get(Place, place_id) + if pl is None: + abort(404) + + res = [] + if storage_t != 'db': + amens = storage.all(Amenity) + for amen in amens.values(): + if amen.id in pl.amenity_ids: + res.append(amen) + else: + res = pl.amenities + + return jsonify([amen.to_dict() for amen in res]) + + +@app_views.route('/places//amenities/', + methods=['DELETE'], + strict_slashes=False) +def deleteAmenityFromPlace(place_id=None, amenity_id=None): + '''deletes an amenity from a place''' + if place_id is None or amenity_id is None: + abort(404) + place = storage.get(Place, place_id) + amenity = storage.get(Amenity, amenity_id) + if place is None or amenity is None: + abort(404) + + if storage_t != 'db': + if amenity.id not in place.amenity_ids: + abort(404) + index = None + for idx, id in enumerate(place.amenity_ids): + if amenity.id == id: + index = idx + break + del place.amenity_ids[index] + place.save() + else: + index = None + for idx, amen in enumerate(place.amenities): + if amen.id == amenity.id: + index = idx + break + if index is None: + abort(404) + del place.amenities[index] + place.save() + + return make_response(jsonify({}), 200) + + +@app_views.route('/places//amenities/', + methods=['POST'], + strict_slashes=False) +def linkAmenityToPlace(place_id=None, amenity_id=None): + '''link an amenity to a place''' + if place_id is None or amenity_id is None: + abort(404) + + place = storage.get(Place, place_id) + amenity = storage.get(Amenity, amenity_id) + + if place is None or amenity is None: + abort(404) + + if storage_t != 'db': + if amenity_id in place.amenity_ids: + return make_response(jsonify(amenity.to_dict()), 200) + else: + place.amenity_ids.append(amenity_id) + place.save() + return make_response(jsonify(amenity.to_dict()), 201) + else: + if amenity in place.amenities: + return make_response(jsonify(amenity.to_dict()), 200) + else: + place.amenities.append(amenity) + place.save() + return make_response(jsonify(amenity.to_dict()), 201) diff --git a/api/v1/views/places_reviews.py b/api/v1/views/places_reviews.py new file mode 100644 index 00000000000..9b2d7cb3074 --- /dev/null +++ b/api/v1/views/places_reviews.py @@ -0,0 +1,108 @@ +#!/usr/bin/python3 +'''reviews blueprint''' + +import re +from api.v1.views import app_views +from flask import jsonify, abort, request, make_response +from models import storage +from models.place import Place +from models.user import User +from models.review import Review + + +@app_views.route('/places//reviews', + methods=['GET'], + strict_slashes=False) +def getReviewsInPlace(place_id=None): + '''get all reviewss in a place''' + if place_id is None: + abort(404) + pl = storage.get(Place, place_id) + if pl is None: + abort(404) + + reviews = storage.all(Review) + res = [] + for rev in reviews.values(): + if rev.place_id == pl.id: + res.append(rev) + + return jsonify([rev.to_dict() for rev in res]) + + +@app_views.route('/reviews/', + methods=['GET'], + strict_slashes=False) +def getReviewById(review_id=None): + '''gets review by id''' + if review_id is None: + abort(404) + review = storage.get(Review, review_id) + if review is None: + abort(404) + return jsonify(review.to_dict()) + + +@app_views.route('/reviews/', + methods=['DELETE'], + strict_slashes=False) +def deleteReview(review_id=None): + '''deletes a review''' + if review_id is not None: + res = storage.get(Review, review_id) + if res is not None: + storage.delete(res) + storage.save() + return make_response(jsonify({}), 200) + abort(404) + + +@app_views.route('/places//reviews', + methods=['POST'], + strict_slashes=False) +def postReview(place_id): + '''posts a new Review''' + if place_id is None: + abort(404) + pl = storage.get(Place, place_id) + if pl is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + if 'user_id' not in body.keys(): + abort(400, 'Missing user_id') + + user = storage.get(User, body['user_id']) + if user is None: + abort(404) + if 'text' not in body.keys(): + abort(400, 'Missing text') + + body['place_id'] = pl.id + rev = Review(**body) + rev.save() + return make_response(jsonify(rev.to_dict()), 201) + + +@app_views.route('/reviews/', + methods=['PUT'], + strict_slashes=False) +def updateReview(review_id=None): + '''updates a review''' + if review_id is None: + abort(404) + obj = storage.get(Review, review_id) + if obj is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + for key in body.keys(): + if key not in ['id', 'created_at', + 'updated_at', 'place_id', 'user_id']: + setattr(obj, key, body[key]) + obj.save() + return make_response(jsonify(obj.to_dict()), 200) diff --git a/api/v1/views/states.py b/api/v1/views/states.py new file mode 100644 index 00000000000..4f92296abb5 --- /dev/null +++ b/api/v1/views/states.py @@ -0,0 +1,70 @@ +#!/usr/bin/python3 +'''states blueprint''' + +from api.v1.views import app_views +from flask import jsonify, abort, request, make_response +from models import storage +from models.state import State + + +@app_views.route('/states', methods=['GET'], strict_slashes=False) +@app_views.route('/states/', methods=['GET'], strict_slashes=False) +def getStates(state_id=None): + '''gets all states or state with the id passed''' + if state_id is None: + res = [] + states = storage.all(State) + for state in states.values(): + res.append(state.to_dict()) + return jsonify(res) + + res = storage.get(State, state_id) + if res is None: + abort(404) + return jsonify(res.to_dict()) + + +@app_views.route('/states/', + methods=['DELETE'], + strict_slashes=False) +def deleteState(state_id=None): + '''deletes a state''' + if state_id is not None: + res = storage.get(State, state_id) + if res is not None: + storage.delete(res) + storage.save() + return make_response(jsonify({}), 200) + abort(404) + + +@app_views.route('/states', methods=['POST'], strict_slashes=False) +def postState(): + '''posts a new state''' + body = request.get_json() + if body is None or type(body)is not dict: + abort(400, description='Not a JSON') + if 'name' not in body.keys(): + abort(400, description='Missing name') + obj = State(**body) + obj.save() + return make_response(jsonify(obj.to_dict()), 201) + + +@app_views.route('/states/', methods=['PUT'], strict_slashes=False) +def updateState(state_id=None): + '''updates a state''' + if state_id is None: + abort(404) + obj = storage.get(State, state_id) + if obj is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, 'Not a JSON') + for key in body.keys(): + if key != 'id' and key != 'created_at' and key != 'updated_at': + setattr(obj, key, body[key]) + obj.save() + return make_response(jsonify(obj.to_dict()), 200) diff --git a/api/v1/views/users.py b/api/v1/views/users.py new file mode 100644 index 00000000000..16a54474ef3 --- /dev/null +++ b/api/v1/views/users.py @@ -0,0 +1,76 @@ +#!/usr/bin/python3 +'''users blueprint''' + +from api.v1.views import app_views +from flask import jsonify, abort, request, make_response +from models import storage +from models.user import User + + +@app_views.route('/users', methods=['GET'], strict_slashes=False) +@app_views.route('/users/', + methods=['GET'], + strict_slashes=False) +def getUserById(user_id=None): + '''gets user by id''' + if user_id is None: + users = storage.all(User) + return jsonify([user.to_dict() for user in users.values()]) + + user = storage.get(User, user_id) + if user is None: + abort(404) + return jsonify(user.to_dict()) + + +@app_views.route('/users/', + methods=['DELETE'], + strict_slashes=False) +def deleteUser(user_id=None): + '''deletes an user''' + if user_id is not None: + res = storage.get(User, user_id) + if res is not None: + storage.delete(res) + storage.save() + return make_response(jsonify({}), 200) + abort(404) + + +@app_views.route('/users', + methods=['POST'], + strict_slashes=False) +def postUser(): + '''posts a new user''' + body = request.get_json() + if body is None or type(body)is not dict: + abort(400, description='Not a JSON') + if 'email' not in body.keys(): + abort(400, description='Missing email') + if 'password' not in body.keys(): + abort(400, description='Missing password') + + user = User(**body) + user.save() + return make_response(jsonify(user.to_dict()), 201) + + +@app_views.route('/users/', + methods=['PUT'], + strict_slashes=False) +def updateUser(user_id=None): + '''updates a user''' + if user_id is None: + abort(404) + obj = storage.get(User, user_id) + if obj is None: + abort(404) + + body = request.get_json() + if body is None: + abort(400, description='Not a JSON') + for key in body.keys(): + if key not in ['id', 'created_at', 'updated_at', 'email']: + setattr(obj, key, body[key]) + obj.save() + return make_response(jsonify(obj.to_dict()), 200) From afc379d9e93d3d1c5129137f99f5db27aac94065 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 5 Aug 2024 17:12:22 -0700 Subject: [PATCH 7/8] made changes --- api/v1/views/amenities.py | 0 api/v1/views/places.py | 0 api/v1/views/places_amenities.py | 0 api/v1/views/places_reviews.py | 0 api/v1/views/states.py | 0 api/v1/views/users.py | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 api/v1/views/amenities.py mode change 100644 => 100755 api/v1/views/places.py mode change 100644 => 100755 api/v1/views/places_amenities.py mode change 100644 => 100755 api/v1/views/places_reviews.py mode change 100644 => 100755 api/v1/views/states.py mode change 100644 => 100755 api/v1/views/users.py diff --git a/api/v1/views/amenities.py b/api/v1/views/amenities.py old mode 100644 new mode 100755 diff --git a/api/v1/views/places.py b/api/v1/views/places.py old mode 100644 new mode 100755 diff --git a/api/v1/views/places_amenities.py b/api/v1/views/places_amenities.py old mode 100644 new mode 100755 diff --git a/api/v1/views/places_reviews.py b/api/v1/views/places_reviews.py old mode 100644 new mode 100755 diff --git a/api/v1/views/states.py b/api/v1/views/states.py old mode 100644 new mode 100755 diff --git a/api/v1/views/users.py b/api/v1/views/users.py old mode 100644 new mode 100755 From e872ffb66ba0b3728201cea591af4870caca0341 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 5 Aug 2024 17:30:33 -0700 Subject: [PATCH 8/8] made changes --- api/v1/views/amenities.py | 10 +++++----- api/v1/views/cities.py | 0 api/v1/views/states.py | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) mode change 100644 => 100755 api/v1/views/cities.py diff --git a/api/v1/views/amenities.py b/api/v1/views/amenities.py index b44bb912891..71545ccb502 100755 --- a/api/v1/views/amenities.py +++ b/api/v1/views/amenities.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -'''amenities blueprint''' +'''amenities module''' from api.v1.views import app_views from flask import jsonify, abort, request, make_response @@ -9,7 +9,7 @@ @app_views.route('/amenities', methods=['GET'], strict_slashes=False) def getamenities(): - '''get all amenities available''' + '''get all amenities''' amens = storage.all(Amenity) return jsonify([amen.to_dict() for amen in amens.values()]) @@ -33,9 +33,9 @@ def getAmenityById(amenity_id=None): def deleteAmenity(amenity_id=None): '''deletes an amenity''' if amenity_id is not None: - res = storage.get(Amenity, amenity_id) + result = storage.get(Amenity, amenity_id) if res is not None: - storage.delete(res) + storage.delete(result) storage.save() return make_response(jsonify({}), 200) abort(404) @@ -60,7 +60,7 @@ def postAmenity(): methods=['PUT'], strict_slashes=False) def updateAmenity(amenity_id=None): - '''updates a amenity''' + '''updates amenity''' if amenity_id is None: abort(404) obj = storage.get(Amenity, amenity_id) diff --git a/api/v1/views/cities.py b/api/v1/views/cities.py old mode 100644 new mode 100755 diff --git a/api/v1/views/states.py b/api/v1/views/states.py index 4f92296abb5..8c9a34b34e3 100755 --- a/api/v1/views/states.py +++ b/api/v1/views/states.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -'''states blueprint''' +'''states module''' from api.v1.views import app_views from flask import jsonify, abort, request, make_response @@ -10,18 +10,18 @@ @app_views.route('/states', methods=['GET'], strict_slashes=False) @app_views.route('/states/', methods=['GET'], strict_slashes=False) def getStates(state_id=None): - '''gets all states or state with the id passed''' + '''gets all states or state with their id passed''' if state_id is None: - res = [] + result = [] states = storage.all(State) for state in states.values(): - res.append(state.to_dict()) - return jsonify(res) + result.append(state.to_dict()) + return jsonify(result) - res = storage.get(State, state_id) + result = storage.get(State, state_id) if res is None: abort(404) - return jsonify(res.to_dict()) + return jsonify(result.to_dict()) @app_views.route('/states/', @@ -30,9 +30,9 @@ def getStates(state_id=None): def deleteState(state_id=None): '''deletes a state''' if state_id is not None: - res = storage.get(State, state_id) - if res is not None: - storage.delete(res) + result = storage.get(State, state_id) + if result is not None: + storage.delete(result) storage.save() return make_response(jsonify({}), 200) abort(404)