Skip to content

Commit be01120

Browse files
committed
changes
1 parent 27abbd3 commit be01120

File tree

6 files changed

+34
-27
lines changed

6 files changed

+34
-27
lines changed

backend/api/conferences/types.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,13 @@ def proposal_tags(self, info: Info) -> list[SubmissionTag]:
221221
return self.proposal_tags.all()
222222

223223
@strawberry.field(permission_classes=[CanSeeSubmissions])
224-
def submissions(
225-
self, info: Info, only_accepted: bool = False
226-
) -> list[Submission] | None:
227-
qs = self.submissions
228-
if only_accepted:
229-
qs = qs.filter(status=SubmissionModel.STATUS.accepted)
230-
else:
231-
qs = qs.filter(
232-
status__in=(
233-
SubmissionModel.STATUS.proposed,
234-
SubmissionModel.STATUS.accepted,
235-
)
224+
def submissions(self, info: Info) -> list[Submission] | None:
225+
return self.submissions.filter(
226+
status__in=(
227+
SubmissionModel.STATUS.proposed,
228+
SubmissionModel.STATUS.accepted,
236229
)
237-
238-
return qs.select_related("audience_level", "duration", "type", "topic")
230+
).select_related("audience_level", "duration", "type", "topic")
239231

240232
@strawberry.field
241233
def events(self, info: Info) -> list[Event]:

backend/api/permissions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def has_permission(self, conference, info, *args, **kwargs):
4747
if not user.is_authenticated:
4848
return False
4949

50+
if info.context._user_can_vote is not None:
51+
return info.context._user_can_vote
52+
5053
return check_if_user_can_vote(user, conference)
5154

5255

backend/api/submissions/schema.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from api.context import Info
33
from api.submissions.permissions import CanSeeSubmissionRestrictedFields
44

5+
from voting.helpers import check_if_user_can_vote
56
import strawberry
67

78
from api.permissions import CanSeeSubmissions, IsAuthenticated
@@ -34,7 +35,7 @@ def submission(self, info: Info, id: strawberry.ID) -> Submission | None:
3435

3536
return submission
3637

37-
@strawberry.field(permission_classes=[IsAuthenticated])
38+
@strawberry.field()
3839
def submissions(
3940
self,
4041
info: Info,
@@ -46,9 +47,10 @@ def submissions(
4647
audience_levels: list[str] | None = None,
4748
page: int | None = 1,
4849
page_size: int | None = 50,
50+
only_accepted: bool = False,
4951
) -> Paginated[Submission] | None:
50-
if page_size > 150:
51-
raise ValueError("Page size cannot be greater than 150")
52+
if page_size > 300:
53+
raise ValueError("Page size cannot be greater than 300")
5254

5355
if page_size < 1:
5456
raise ValueError("Page size must be greater than 0")
@@ -60,10 +62,17 @@ def submissions(
6062
user = request.user
6163
conference = ConferenceModel.objects.filter(code=code).first()
6264

63-
if not conference or not CanSeeSubmissions().has_permission(conference, info):
64-
raise PermissionError("You need to have a ticket to see submissions")
65+
if not only_accepted and not IsAuthenticated().has_permission(conference, info):
66+
raise PermissionError("You need to be authenticated to see submissions")
6567

66-
info.context._user_can_vote = True
68+
info.context._user_can_vote = (
69+
check_if_user_can_vote(user, conference) if user.is_authenticated else False
70+
)
71+
72+
if not conference or not CanSeeSubmissions().has_permission(
73+
conference, info, only_accepted=only_accepted
74+
):
75+
raise PermissionError("You need to have a ticket to see submissions")
6776

6877
qs = conference.submissions.prefetch_related(
6978
"type",
@@ -72,7 +81,12 @@ def submissions(
7281
"languages",
7382
"audience_level",
7483
"tags",
75-
).filter(status=SubmissionModel.STATUS.proposed)
84+
)
85+
86+
if only_accepted:
87+
qs = qs.filter(status=SubmissionModel.STATUS.accepted)
88+
else:
89+
qs = qs.filter(status=SubmissionModel.STATUS.proposed)
7690

7791
if languages:
7892
qs = qs.filter(languages__code__in=languages)

frontend/src/components/blocks/dynamic-content-display-section/accepted-proposals-content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const AcceptedProposalsContent = () => {
1515
const language = useCurrentLanguage();
1616
const {
1717
data: {
18-
conference: { submissions },
18+
submissions: { items: submissions },
1919
},
2020
} = useAcceptedProposalsQuery({
2121
variables: {

frontend/src/components/blocks/dynamic-content-display-section/accepted-proposals.graphql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#import "../../fragments/submission-accordion.graphql"
22

33
query AcceptedProposals($code: String!, $language: String!) {
4-
conference(code: $code) {
5-
id
6-
submissions(onlyAccepted: true) {
4+
submissions(code: $code, onlyAccepted: true, pageSize: 300) {
5+
items {
76
...submissionAccordion
87
id
9-
title(language: $language)
108
speaker {
119
id
1210
fullname

frontend/src/components/blocks/dynamic-content-display-section/speakers-content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const SpeakersContent = () => {
1212
const language = useCurrentLanguage();
1313
const {
1414
data: {
15-
conference: { submissions },
15+
submissions: { items: submissions },
1616
},
1717
} = useAcceptedProposalsQuery({
1818
variables: {

0 commit comments

Comments
 (0)