From 423d6c7a9319ebf3e5e6848a65fddb83dbcec27b Mon Sep 17 00:00:00 2001 From: warrenshiv Date: Sun, 3 Dec 2023 17:16:11 +0300 Subject: [PATCH 1/3] Error handling in the login page --- .../__pycache__/views.cpython-310.pyc | Bin 6471 -> 6443 bytes backend/artistsmgmt/views.py | 13 ++++++++++--- frontend/src/pages/homepage.js | 3 +-- frontend/src/pages/signup.js | 7 +++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/backend/artistsmgmt/__pycache__/views.cpython-310.pyc b/backend/artistsmgmt/__pycache__/views.cpython-310.pyc index 2a5568986c902b3b6eca4d710d9ab6bcc23a2ab8..0d119d6431d9410e1797518bcc85a5499e20a239 100644 GIT binary patch delta 859 zcmZ9K%WD%+6vpRHGU;s|Z8CZGku=8mm_BW~kh;<0q6jg4L9r1`wRhBn*vFl*MG;DE z7m9+)U5FbI5mdUdr2l{`H~j-7OSg9IPVhTzRdnEdIp6QzoOAD)`BK;}gqA`fzlO)R zS+~Ew2&LJ(oxU(zXSEZXp7P0YO~gfFOA`s3)lPw&21$w(ND9OP=>_Q!ogkeceIWfH zU7{PL+m68xz^6q9K6Bs);d?|DK6_Mk2;`W^f#eRW#>!`aj*C1{9%vY43XMHhZ()`i zZGEhsC%Eop)n03Aoe6zQD|6wQ(JXJXZA`jV$DLTL-0v5NB+;@x9H@*qZv$F5(sNMTFynppPDGkrmWRH=c$$GpN=>^(wN= z4{q(1Qz~MPvqx&qe8O!kTCG6)rj@x3BkLsp&B3#L*L|i&qHDO>c65~8Q5%t{QN+%d z>Sy#qC$*5hBqsT*1Y5lMd_$;)kR4(`cD=P%W?CBr0(iYo8E@gC$q8MjEl? zJc~Blr)^hO?Nxhh@)CVAcq6N+nH)_~(n%#XmDHgbDB{!lz0Jj4l1lFwG0nKiO~W+8 MZQ+R7WBL>P7iibN`Tzg` delta 809 zcmYL`&rcIU6vy{%x68EMt?l-wKxxH_EFdag{BeO3F(N<27-@(tI4fzbK&DF&h#CS1 z4KdNo!Gk9~NxWbhPbP9SUW^A12CqhM{tNmY#JI`4eed&TzVE%6*8?90>;>BnYxs(_ zx@SJMbM*2}Z;T!!Hv*+&!x~TV^rpts9@V-)j)P=)79`WpacI@~U-Vkl zTkfCpd@+uc+z6ki9$83dGZP4h)e#26G)4wRbul4#LhUjXS*J0%6=~2_`8)E(+6zOV zyf9nyZu;`8Ri+#AtX-zE5|TT%K~v4QHY2Jw-$%nli}K?ko~l51P8CocqkwL;hzjI$ z&2o%Ua2j+?*5ivzHRc*(T7HiY)4J?)w%9F&LO{EYYgQ46JMx#4p@-5;EYq~SpEyVJ zYVzO+l27F4#2{!qnJ^dC<`LCcTMh1AtcC@H1_I19gJ^?^+WwR)$w6~QZJ(99$&&e8 zxt`3Yt|SE9XIKpbhG~`|glZgb+$!It?qz)77b^ev?!ve`i-fV`|%$ {
{userData ? (
-

{userData.message}!

- {/* Display user-specific content */} +

Welcome, {userData.username}!

) : (

Loading...

diff --git a/frontend/src/pages/signup.js b/frontend/src/pages/signup.js index 90e82ab..f52a50d 100644 --- a/frontend/src/pages/signup.js +++ b/frontend/src/pages/signup.js @@ -57,8 +57,11 @@ const SignUpForm = () => { } } catch (error) { console.error("Error during signup:", error); - setErrorMessage("Error during signup. Please try again."); - setSuccessMessage(""); + if (error.response && error.response.status === 400) { + setErrorMessage("A user with that username already exists."); + } else { + setErrorMessage("Signup failed. Please try again."); + } } }; From 2f808c48e1cf366f79ad0de8cc1f5d97d8d538a4 Mon Sep 17 00:00:00 2001 From: warrenshiv Date: Sun, 3 Dec 2023 17:54:48 +0300 Subject: [PATCH 2/3] Clean coding in the backend --- .../__pycache__/serializers.cpython-310.pyc | Bin 3368 -> 3577 bytes .../__pycache__/views.cpython-310.pyc | Bin 6443 -> 6503 bytes backend/artistsmgmt/serializers.py | 4 +++ backend/artistsmgmt/views.py | 26 ++++++------------ frontend/src/pages/signup.js | 2 +- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/backend/artistsmgmt/__pycache__/serializers.cpython-310.pyc b/backend/artistsmgmt/__pycache__/serializers.cpython-310.pyc index 4d30908991ffd0c1986d8243db1df2cf2573e13f..40b91493bd90db697dedb0e6921cd3e28fc614f4 100644 GIT binary patch delta 497 zcmYjNzfZzI7`Ng0{DwmWC5`TjRrvtYD{oYOfb>7AWCB(DDfZ;#6d^rZ*U;) zV&dTFp3A!u@z2B0KQ z!LcYoeB?f0AY~{aNW?{5xcrv&LF2b!4i>9&6a0SPyL^bMjvozGaNf?z3Is+w1*EqxSI1+3YuB1&*o@*HJCQbWu zST6IHr(-#MJ1M3Jfr5NVGw>|0(k=Ls%WgJ@dnhX5n9WXdc9z3D2c83NloZ{DCuKju zmaw Y2lxjto`Bhjil`a|w;Fe=K{=xS0zVyYu>b%7 delta 341 zcmewmPJYO# z%&!Mznu54s{dyq%jK!1RvKdY`=gMW&p1hRHmeFzYV=jL=O(wrvj0&2pxA==wb5fH_ zQd8oghUx?LPd4O`Vbq-L$00qrm|K$3b#gCv$mG2o5;7uas^jw#b5n~%Kvr5zZe)@W zHvls2fVh|gNN_N4F!C|+uoM|UePYdMIJt|blg$UD!3gYRYar7b#05Lqda^ffiU24W aia>rT0vT6i4K!JN@-<#LR!$*KF1~ z75iKISu_i;-}T2}E3vH>PK+r$$x}NDPubw~AUTO7%`-?cNP3Z2NSb*Ik`^R=Ncxeq z@+^|9O)dkNxAAt&+Z*{H<{i8f^UfpJAtYTqha`98ddfs}oOdJYMsyl&&eT4`Z@;|H z0$W*}*H#L^m4eS!7oebVjr+K|0|lMKlw#@i=&10@t~aq%S-VxXSM&2KedN)j<6FbH zjN$g8c!~p#Zvz~a!yas^p0=TG!=~ox8=7Nyeur`2o)3-Hyy#LU6h&OcQ&vEj_!1UL zA4!gcey1=<+DNFexQ1fsVu03zBzcs&G20mOd9wLNV-z|R^D#B1uABeQKeS+b0{beK zA zmeBRiKYQj2`$Y-u+iJxa1APWd>$1|c3N!LY(-=II1LiKH1Nif1!zfH)Dl-fn`!nG*K5s2C zV$9O^IeCyM7%ypQ%Z}vrxWMHL443WzQ^J}MG_mXnx5y94&9sO371ddz9s~`-AiRd_ zz0^W-1@RjUF-<~Q-WskQrb-~EGdFW3qBNbLMuObxp>e#7qmx(YE{YYLKP`V|&YCg5 R88vlNk40lmW``L}vA^p2%NPIv delta 891 zcmY+CO-vI}6ouzaJJYc(rJc6Z@>9SHYWWiiN?a*%K}-lxh(yQ4qP!PuQ~utJ5{wCn zpfPb_%rkLk)VMIw1*UG?xpSc#cBVU5uH3rzTtJPJ+|zr$zMi@7ray{ri?P+Frm%*` z+^&gl*(b4f_WFHaoNcjc&vw8)KB4h6cXl-H2v$7-auOuNvmjZJ0!S}N3vUH!1?dCn z2WjK&AnhUrKLDTO9q=9deh|KscfofZrk(;h%JU%kgVdBe1aypd19bxpBc@pY%6^5^ zu48R^T^LztF5{Z3i+~6&>8>G6H^dp&cQn`HfjO-ZY{bT;U-A6umD=WfMQkiGy6WLW zJ=F!2XF=|2RjtbAG&v1Z(B%L=WS)8^`>7xPBQvsywh>+uetGpqRV@0m@SYB_*qxUD zUpn~j)KuY!9Ho%cBxgu6BnkC1oQ=>7a*U*;mYr;B2JIATe>e-tK^9d*kr!-U?M1xE zRXTZ@S-!7q3%PkQIO#RF4Xmy#n@Us(i~=NLpgDtE`zV2JQIQ! z=+TfYBP&;b7q^%}S@+b(#0D#=VS9o-RGaoAOMv1UB^6B;I&Q+q8p+??9IPg=cFTXP z=92W=FUhlPS-ngojY*t*rgEwCt&}Z$NwOrgKDkOVNfWnK&~Bl;C {

Already have an account?

- + Log In
From 8851ad55d8afb141715d36dd63880838e83a2d15 Mon Sep 17 00:00:00 2001 From: warrenshiv Date: Sun, 3 Dec 2023 19:41:18 +0300 Subject: [PATCH 3/3] Ensured that the ArtistOnlyView returns the username of artist --- .../__pycache__/serializers.cpython-310.pyc | Bin 3577 -> 3570 bytes .../__pycache__/views.cpython-310.pyc | Bin 6503 -> 6510 bytes backend/artistsmgmt/serializers.py | 7 +- backend/artistsmgmt/views.py | 2 +- .../backend/__pycache__/urls.cpython-310.pyc | Bin 1182 -> 1182 bytes frontend/src/pages/_app.js | 16 ++- frontend/src/pages/events.js | 115 ++++++++++-------- frontend/src/pages/homepage.js | 2 +- frontend/src/pages/index.js | 26 ++-- 9 files changed, 94 insertions(+), 74 deletions(-) diff --git a/backend/artistsmgmt/__pycache__/serializers.cpython-310.pyc b/backend/artistsmgmt/__pycache__/serializers.cpython-310.pyc index 40b91493bd90db697dedb0e6921cd3e28fc614f4..5b67ffd44e8b1f2b3421f8e91937253eee4452a7 100644 GIT binary patch delta 307 zcmew<{YjcPpO=@50SFA&=cI;g)`D8;58KxqG$qC##j9!y_xkDL^CqL%45H|wI{Y4Hymy1un N#w*9lC&Ven3jhTjL_Poj delta 314 zcmew){ZpDZpO=@50SKN?&Pk2h$a{&MQE&1Cb~SBgpqMid7mERj8pbS!EXLUkDU4ti z(`<&h%)tyRnfz`sDrhoKw&s?ZY{8+!Weif!1SG^J=W(Pknoe$Hl9>FOLx_=a@;{Cf zj8>D6b87Hg0Oc)#xCmr$k;UW-Y%-IjxHdDoPCm!wuUDiG6xC$C#b2D7lbT$Tni8K_ zRFYX-QUunb0@7j#B8)(U@#IKu9Y)W|ZQP-ZW|Qx5TZmf$g`I%7m;*>~FmN#PG4Zez zS%EE)$h(hIP7cURWr$)-VTfW%Wlm*DXNqD?VM$?1VQyiJ lVw?P&^NTopkqJ;yktv8U0}e>>*SZ5Uxe6- jOn?fDOhJShh!CIrh0B4BjggP3C}8qN5t+?l+!A~M(bE-R diff --git a/backend/artistsmgmt/serializers.py b/backend/artistsmgmt/serializers.py index 6a0c319..204f0c2 100644 --- a/backend/artistsmgmt/serializers.py +++ b/backend/artistsmgmt/serializers.py @@ -43,17 +43,18 @@ def create(self, validated_data): class ArtistSerializer(serializers.ModelSerializer): artist_name = serializers.SerializerMethodField() + class Meta: model = Artist fields = '__all__' extra_kwargs = {'user': {'read_only': True}} - - def get_artist_name(self, obj): - return f"{obj.user.first_name} {obj.user.last_name}" + def get_artist_name(self, obj): + return obj.user.username if obj.user.username else "" # Portfolio + class PortfolioSerializer(serializers.ModelSerializer): class Meta: model = Portfolio diff --git a/backend/artistsmgmt/views.py b/backend/artistsmgmt/views.py index dcf1103..522a34a 100644 --- a/backend/artistsmgmt/views.py +++ b/backend/artistsmgmt/views.py @@ -62,7 +62,7 @@ def post(self, request, format=None): class ArtistOnlyView(APIView): - permission_classes = [IsAuthenticated] + permission_classes = [IsAuthenticated, IsArtist] def get(self, request, format=None): # Retrieve the authenticated artist diff --git a/backend/backend/__pycache__/urls.cpython-310.pyc b/backend/backend/__pycache__/urls.cpython-310.pyc index 29ab5d36efefdbabb1ef9e2057e494c05250b029..04d3a897dc73688686d66a4179358fad8162e528 100644 GIT binary patch delta 20 acmbQoIggV&pO=@50SFpa=4|Ai%mM%}bp+J_ delta 20 acmbQoIggV&pO=@50SLsyk~eZsW&r>ycLWds diff --git a/frontend/src/pages/_app.js b/frontend/src/pages/_app.js index 13b32c1..312f110 100644 --- a/frontend/src/pages/_app.js +++ b/frontend/src/pages/_app.js @@ -7,14 +7,14 @@ import '../styles/scss/theme.scss'; import Layout from '@/layout/Layout'; export default function App({ Component, pageProps, router }) { - const isLoginPage = router.pathname === '/login'; - const isSignupPage = router.pathname === '/signup'; - const isShowcasePage = router.pathname === '/showcase'; - const isProfilePage = router.pathname === '/profile'; - const isFormPage = router.pathname === '/form'; - const is404Page = router.pathname === '/404'; + // const isLoginPage = router.pathname === '/login'; + // const isSignupPage = router.pathname === '/signup'; + // const isShowcasePage = router.pathname === '/showcase'; + // const isProfilePage = router.pathname === '/profile'; + // const isFormPage = router.pathname === '/form'; + // const is404Page = router.pathname === '/404'; - const shouldIncludeNavbarAndFooter = !(isLoginPage || isSignupPage || isShowcasePage || isProfilePage || isFormPage || is404Page); + // const shouldIncludeNavbarAndFooter = !(isLoginPage || isSignupPage || isShowcasePage || isProfilePage || isFormPage || is404Page); useEffect(() => { // Initialize Google Analytics @@ -28,8 +28,6 @@ export default function App({ Component, pageProps, router }) { }, [router.pathname]); // Track page views on route changes return ( - - ); } diff --git a/frontend/src/pages/events.js b/frontend/src/pages/events.js index 7b0414c..1bf62c7 100644 --- a/frontend/src/pages/events.js +++ b/frontend/src/pages/events.js @@ -1,82 +1,101 @@ -import Head from 'next/head'; +import Head from "next/head"; +import Layout from "../layout/Layout"; const UpcomingEventsPage = () => { // Dummy data for upcoming events const upcomingEvents = [ { id: 1, - title: 'Art Exhibition: Colors of Creativity', - date: 'November 25, 2023', - location: 'Swahilipot Hub Gallery', - description: 'Join us for an inspiring art exhibition showcasing a vibrant array of creative expressions.', - image: '/featured/bahari-brush.jpg', + title: "Art Exhibition: Colors of Creativity", + date: "November 25, 2023", + location: "Swahilipot Hub Gallery", + description: + "Join us for an inspiring art exhibition showcasing a vibrant array of creative expressions.", + image: "/featured/bahari-brush.jpg", }, { id: 2, - title: 'Music Festival: Harmony in Diversity', - date: 'December 10, 2023', - location: 'Swahilipot Hub Amphitheater', - description: 'Experience the magic of music as diverse artists come together to create a harmonious celebration of unity.', - image: '/events/music-fest.jpg', + title: "Music Festival: Harmony in Diversity", + date: "December 10, 2023", + location: "Swahilipot Hub Amphitheater", + description: + "Experience the magic of music as diverse artists come together to create a harmonious celebration of unity.", + image: "/events/music-fest.jpg", }, { id: 3, - title: 'Spoken Word & Poetry: Poetic Justice', - date: '2023-12-15', - location: 'SPH Ampitheatre', - image: '/events/spokenword.jpg', + title: "Spoken Word & Poetry: Poetic Justice", + date: "2023-12-15", + location: "SPH Ampitheatre", + image: "/events/spokenword.jpg", }, { id: 4, - title: 'Concert in the Park: Music Fusion', - date: '2023-12-20', - location: 'City Park Amphitheater', - image: '/events/concert.jpg', + title: "Concert in the Park: Music Fusion", + date: "2023-12-20", + location: "City Park Amphitheater", + image: "/events/concert.jpg", }, { id: 5, - title: 'Workshop: Digital Art Masterclass', - date: '2023-12-25', - location: 'Creative Hub Studios', - image: '/events/digital.jpg', + title: "Workshop: Digital Art Masterclass", + date: "2023-12-25", + location: "Creative Hub Studios", + image: "/events/digital.jpg", }, { id: 6, - title: 'Comedy Night: Laugh Festival', - date: '2023-12-28', - location: 'Creative Hub Studios', - image: '/events/laughfest.jpg', + title: "Comedy Night: Laugh Festival", + date: "2023-12-28", + location: "Creative Hub Studios", + image: "/events/laughfest.jpg", }, // Add more events as needed ]; return ( <> - - Upcoming Events - + + + Upcoming Events + -
-

Upcoming Events

+
+

Upcoming Events

-
- {upcomingEvents.map((event) => ( -
-
-
-
{event.title}
-

- Date: {event.date}
- Location: {event.location} -

-

{event.description}

- +
+ {upcomingEvents.map((event) => ( +
+
+
+
+ {event.title} +
+

+ Date: {event.date} +
+ Location: {event.location} +

+

+ {event.description} +

+ +
-
- ))} -
-
+ ))} +
+ + ); }; diff --git a/frontend/src/pages/homepage.js b/frontend/src/pages/homepage.js index a569503..360392d 100644 --- a/frontend/src/pages/homepage.js +++ b/frontend/src/pages/homepage.js @@ -49,7 +49,7 @@ const HomePage = () => {
{userData ? (
-

Welcome, {userData.username}!

+

Welcome, {userData.artist_name}!

) : (

Loading...

diff --git a/frontend/src/pages/index.js b/frontend/src/pages/index.js index a058206..cbbb026 100644 --- a/frontend/src/pages/index.js +++ b/frontend/src/pages/index.js @@ -1,19 +1,21 @@ -import Portfolio from "@/components/portfolio/Portfolio" -import Events from "@/components/landing/Events" -import Featured from "@/components/landing/Featured" - -const { default: Hero } = require("@/components/landing/Hero") +import Portfolio from "@/components/portfolio/Portfolio"; +import Events from "@/components/landing/Events"; +import Featured from "@/components/landing/Featured"; +import Layout from "@/layout/Layout"; +const { default: Hero } = require("@/components/landing/Hero"); const Landing = () => { return ( <> - - - - + + + + + + - ) -} + ); +}; -export default Landing \ No newline at end of file +export default Landing;