Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoacierno committed Feb 9, 2025
1 parent be01120 commit 04ca84c
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 58 deletions.
23 changes: 20 additions & 3 deletions backend/api/participants/types.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from typing import Optional
from typing import TYPE_CHECKING, Annotated, Optional

from submissions.models import Submission as SubmissionModel
from strawberry.scalars import JSON
import strawberry
from strawberry import ID

from api.submissions.permissions import CanSeeSubmissionPrivateFields

if TYPE_CHECKING:
from api.submissions.types import Submission


@strawberry.type
class Participant:
Expand All @@ -25,6 +29,17 @@ class Participant:

_speaker_level: strawberry.Private[str]
_previous_talk_video: strawberry.Private[str]
_conference_id: strawberry.Private[int]
_user_id: strawberry.Private[int]

@strawberry.field
def proposals(
self, info
) -> list[Annotated["Submission", strawberry.lazy("api.submissions.types")]]:
return SubmissionModel.objects.for_conference(self._conference_id).filter(
speaker_id=self._user_id,
status=SubmissionModel.STATUS.accepted,
)

@strawberry.field
def speaker_level(self, info) -> Optional[str]:
Expand All @@ -50,12 +65,14 @@ def from_model(cls, instance):
bio=instance.bio,
website=instance.website,
public_profile=instance.public_profile,
_speaker_level=instance.speaker_level,
_previous_talk_video=instance.previous_talk_video,
twitter_handle=instance.twitter_handle,
instagram_handle=instance.instagram_handle,
linkedin_url=instance.linkedin_url,
facebook_url=instance.facebook_url,
mastodon_handle=instance.mastodon_handle,
speaker_availabilities=instance.speaker_availabilities or {},
_conference_id=instance.conference_id,
_user_id=instance.user_id,
_speaker_level=instance.speaker_level,
_previous_talk_video=instance.previous_talk_video,
)
7 changes: 6 additions & 1 deletion backend/api/schedule/types/slot.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from enum import Enum
from typing import TYPE_CHECKING, Annotated
from django.utils import timezone
from datetime import datetime, time, timedelta
from api.schedule.types.schedule_item import ScheduleItem


import strawberry

if TYPE_CHECKING:
from api.schedule.types.day import Day


@strawberry.enum
class ScheduleSlotType(Enum):
Expand All @@ -16,10 +20,11 @@ class ScheduleSlotType(Enum):

@strawberry.type
class ScheduleSlot:
id: strawberry.ID
hour: time
duration: int
type: ScheduleSlotType
id: strawberry.ID
day: Annotated["Day", strawberry.lazy("api.schedule.types.day")]

@strawberry.field
def is_live(self) -> bool:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
query ParticipantPublicProfile($id: ID!, $conference: String!) {
#import "../../fragments/schedule-item.graphql"

query ParticipantPublicProfile(
$id: ID!
$conference: String!
$language: String!
) {
participant(id: $id, conference: $conference) {
id
fullname
Expand All @@ -11,5 +17,24 @@ query ParticipantPublicProfile($id: ID!, $conference: String!) {
linkedinUrl
facebookUrl
mastodonHandle
proposals {
id
title(language: $language)
type {
id
name
}
audienceLevel {
id
name
}
duration {
id
duration
}
scheduleItems {
...ScheduleItemFragment
}
}
}
}
78 changes: 76 additions & 2 deletions frontend/src/components/public-profile-page-handler/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
import { Page, Section } from "@python-italia/pycon-styleguide";
import {
CardPart,
Heading,
Link,
MultiplePartsCard,
MultiplePartsCardCollection,
Page,
Section,
Spacer,
Text,
} from "@python-italia/pycon-styleguide";

import { useRouter } from "next/router";

import { useParticipantPublicProfileQuery } from "~/types";
import {
Participant,
type ParticipantPublicProfileQueryResult,
useParticipantPublicProfileQuery,
} from "~/types";

import { FormattedMessage } from "react-intl";
import { useCurrentLanguage } from "~/locale/context";
import { createHref } from "../link";
import { ParticipantInfoSection } from "../participant-info-section";
import { ScheduleItemList } from "../schedule-view/schedule-list";

export const PublicProfilePageHandler = () => {
const router = useRouter();
const language = useCurrentLanguage();
const {
data: { participant },
} = useParticipantPublicProfileQuery({
variables: {
id: router.query.hashid as string,
conference: process.env.conferenceCode,
language,
},
});

Expand All @@ -25,6 +45,60 @@ export const PublicProfilePageHandler = () => {
participant={participant}
/>
</Section>
{participant.proposals.length > 0 && (
<Section>
<Heading size={2}>
<FormattedMessage id="global.sessions" />
</Heading>
<Spacer size="2md" />
<MultiplePartsCardCollection>
{participant.proposals.map((proposal) => (
<ProposalCard proposal={proposal} />
))}
</MultiplePartsCardCollection>
</Section>
)}
</Page>
);
};

const ProposalCard = ({
proposal,
}: {
proposal: ParticipantPublicProfileQueryResult["data"]["participant"]["proposals"][0];
}) => {
const language = useCurrentLanguage();
return (
<MultiplePartsCard>
<CardPart contentAlign="left">
<div className="flex flex-row items-center md:gap-3 lg:gap-6">
<Text size={3} color="grey-500">
<FormattedMessage
id="voting.minutes"
values={{
type: proposal.type.name,
duration: proposal.duration.duration,
}}
/>
, {proposal.audienceLevel.name}
</Text>
</div>
<Spacer size="xs" />

<Link
href={createHref({
path:
proposal.scheduleItems.length > 0
? `/event/${proposal.scheduleItems[0].slug}`
: `/submission/${proposal.id}`,
locale: language,
})}
>
<Heading color="none" size={4}>
{proposal.title}
</Heading>
</Link>
</CardPart>
</MultiplePartsCard>
);
};
2 changes: 1 addition & 1 deletion frontend/src/components/schedule-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export const isItemVisible = (
const query = currentFilters.search[0].toLowerCase().split(" ");
const title = item.title.toLowerCase();
const speakersNames = item.speakers
.reduce((acc, speaker) => `${acc} ${speaker.fullName}`, "")
.reduce((acc, speaker) => `${acc} ${speaker.fullname}`, "")
.toLowerCase();

if (
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/schedule-view/schedule-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const ScheduleList = ({
}

return (
<ScheduleItem
<ScheduleItemList
key={item.id}
item={item}
currentDay={currentDay}
Expand All @@ -76,7 +76,7 @@ export const ScheduleList = ({
);
};

const ScheduleItem = ({
export const ScheduleItemList = ({
item,
slot,
isLive,
Expand Down Expand Up @@ -193,7 +193,7 @@ const ScheduleItem = ({
{item.speakers.length > 0 && (
<Heading size={6}>
{item.speakers
.map((speaker) => speaker.fullName)
.map((speaker) => speaker.fullname)
.join(", ")}
</Heading>
)}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/schedule-view/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type Item = {
submission?: Submission | null;
keynote?: Keynote | null;
audienceLevel?: { name: string; id: string } | null;
speakers: { fullName: string; participant?: Participant }[];
speakers: { fullname: string; participant?: Participant }[];
hasLimitedCapacity: boolean;
userHasSpot: boolean;
hasSpacesLeft: boolean;
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const messages = {
"We have groups discounts for groups with 6+ people, contact us to know more. After you have purchased your tickets, you will be able to access the {page} with our discounted codes.",
"tickets.description.page": "hotels page",

"global.sessions": "Sessions",

"input.placeholder": "Type here...",
"global.accordion.close": "Close",
"global.accordion.readMore": "Read more",
Expand Down Expand Up @@ -1935,6 +1937,8 @@ Affrettati a comprare il biglietto!`,
"scheduleEventDetail.materials.open": "Apri ({hostname})",
"scheduleEventDetail.materials.download": "Scarica ({mimeType})",

"global.sessions": "Sessioni",

"scheduleEventDetail.eventTime": "{start} - {end}",
"voting.minutes": "{type} ({duration} minuti)",
"voting.pagination":
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/profile/[hashid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const getServerSideProps: GetServerSideProps = async ({
queryParticipantPublicProfile(client, {
conference: process.env.conferenceCode,
id: params.hashid as string,
language: locale,
}),
]);

Expand Down
48 changes: 48 additions & 0 deletions frontend/src/pages/schedule/fragments/schedule-item.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
fragment ScheduleItemFragment on ScheduleItem {
id
title
slug
type

duration

hasLimitedCapacity
userHasSpot
hasSpacesLeft
spacesLeft
linkTo

audienceLevel {
id
name
}

language {
id
name
code
}

submission {
...SubmissionFragment
}

keynote {
...KeynoteFragment
}

speakers {
id
fullname
participant {
id
photo
}
}

rooms {
id
name
type
}
}
Loading

0 comments on commit 04ca84c

Please sign in to comment.