Skip to content

Commit

Permalink
Ensured that the ArtistOnlyView returns the username of artist
Browse files Browse the repository at this point in the history
  • Loading branch information
warrenshiv committed Dec 3, 2023
1 parent 2f808c4 commit 8851ad5
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 74 deletions.
Binary file modified backend/artistsmgmt/__pycache__/serializers.cpython-310.pyc
Binary file not shown.
Binary file modified backend/artistsmgmt/__pycache__/views.cpython-310.pyc
Binary file not shown.
7 changes: 4 additions & 3 deletions backend/artistsmgmt/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/artistsmgmt/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified backend/backend/__pycache__/urls.cpython-310.pyc
Binary file not shown.
16 changes: 7 additions & 9 deletions frontend/src/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,8 +28,6 @@ export default function App({ Component, pageProps, router }) {
}, [router.pathname]); // Track page views on route changes

return (
<Layout includeNavbar={shouldIncludeNavbarAndFooter} includeFooter={shouldIncludeNavbarAndFooter}>
<Component {...pageProps} />
</Layout>
);
}
115 changes: 67 additions & 48 deletions frontend/src/pages/events.js
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Head>
<title>Upcoming Events</title>
</Head>
<Layout>
<Head>
<title>Upcoming Events</title>
</Head>

<section className="container py-5">
<h1 className="mb-4">Upcoming Events</h1>
<section className="container py-5">
<h1 className="mb-4">Upcoming Events</h1>

<div className="row">
{upcomingEvents.map((event) => (
<div key={event.id} className="col-md-6 mb-4">
<div className="card" style={{ backgroundImage: `url(${event.image})`, backgroundSize: 'cover', height: '300px' }}>
<div className="card-body">
<h5 className="card-title" style={{ color: 'yellow' }}>{event.title}</h5>
<p className="card-text" style={{ color: 'white' }}>
<strong>Date:</strong> {event.date}<br />
<strong>Location:</strong> {event.location}
</p>
<p className="card-text" style={{ color: 'white' }}>{event.description}</p>
<button className="btn btn-light">View Event Details</button>
<div className="row">
{upcomingEvents.map((event) => (
<div key={event.id} className="col-md-6 mb-4">
<div
className="card"
style={{
backgroundImage: `url(${event.image})`,
backgroundSize: "cover",
height: "300px",
}}
>
<div className="card-body">
<h5 className="card-title" style={{ color: "yellow" }}>
{event.title}
</h5>
<p className="card-text" style={{ color: "white" }}>
<strong>Date:</strong> {event.date}
<br />
<strong>Location:</strong> {event.location}
</p>
<p className="card-text" style={{ color: "white" }}>
{event.description}
</p>
<button className="btn btn-light">
View Event Details
</button>
</div>
</div>
</div>
</div>
))}
</div>
</section>
))}
</div>
</section>
</Layout>
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const HomePage = () => {
<div>
{userData ? (
<div>
<h1>Welcome, {userData.username}!</h1>
<h1>Welcome, {userData.artist_name}!</h1>
</div>
) : (
<p>Loading...</p>
Expand Down
26 changes: 14 additions & 12 deletions frontend/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Hero />
<Portfolio />
<Featured />
<Events />
<Layout>
<Hero />
<Portfolio />
<Featured />
<Events />
</Layout>
</>
)
}
);
};

export default Landing
export default Landing;

0 comments on commit 8851ad5

Please sign in to comment.