Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomasDOTwtf
hub
Commits
4e5c59f0
Commit
4e5c59f0
authored
Dec 28, 2023
by
Lucas Brandstaetter
Committed by
HeJ
Dec 29, 2023
Browse files
Options
Downloads
Patches
Plain Diff
Fix speaker list append
parent
b2362410
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/api/tests/schedule.py
+46
-4
46 additions, 4 deletions
src/api/tests/schedule.py
src/core/models/events.py
+1
-3
1 addition, 3 deletions
src/core/models/events.py
with
47 additions
and
7 deletions
src/api/tests/schedule.py
+
46
−
4
View file @
4e5c59f0
...
@@ -42,8 +42,8 @@ class ScheduleTest(TestCase):
...
@@ -42,8 +42,8 @@ class ScheduleTest(TestCase):
self
.
token
.
save
()
self
.
token
.
save
()
def
_test_schedule_export
(
self
,
url_suffix
:
str
,
expected_content_type
:
str
,
content_parser
):
def
_test_schedule_export
(
self
,
url_suffix
:
str
,
expected_content_type
:
str
,
content_parser
):
url
=
reverse
(
'
api:conference-schedule
'
)
+
url_suffix
schedule_
url
=
reverse
(
'
api:conference-schedule
'
)
+
url_suffix
resp
=
self
.
client
.
get
(
url
)
resp
=
self
.
client
.
get
(
schedule_
url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
self
.
assertEqual
(
resp
[
'
Content-Type
'
],
expected_content_type
)
self
.
assertEqual
(
resp
[
'
Content-Type
'
],
expected_content_type
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
...
@@ -68,9 +68,17 @@ class ScheduleTest(TestCase):
...
@@ -68,9 +68,17 @@ class ScheduleTest(TestCase):
schedule_duration
=
timedelta
(
minutes
=
42
),
schedule_duration
=
timedelta
(
minutes
=
42
),
)
)
ev1
.
save
()
ev1
.
save
()
event_url
=
reverse
(
'
api:event-schedule
'
,
kwargs
=
{
'
pk
'
:
ev1
.
pk
})
# check that event is in the output
# check that event is in the output
resp
=
self
.
client
.
get
(
url
)
resp
=
self
.
client
.
get
(
schedule_url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
content_parser
(
content_str
)
self
.
assertIn
(
ev1
.
name
,
content_str
)
if
url_suffix
==
'
.json
'
:
resp
=
self
.
client
.
get
(
event_url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
content_parser
(
content_str
)
content_parser
(
content_str
)
...
@@ -99,7 +107,7 @@ class ScheduleTest(TestCase):
...
@@ -99,7 +107,7 @@ class ScheduleTest(TestCase):
ev2b
.
save
()
ev2b
.
save
()
# check that none of the new events are in the output
# check that none of the new events are in the output
resp
=
self
.
client
.
get
(
url
)
resp
=
self
.
client
.
get
(
schedule_
url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
content_parser
(
content_str
)
content_parser
(
content_str
)
...
@@ -107,6 +115,40 @@ class ScheduleTest(TestCase):
...
@@ -107,6 +115,40 @@ class ScheduleTest(TestCase):
self
.
assertNotIn
(
ev2a
.
name
,
content_str
)
self
.
assertNotIn
(
ev2a
.
name
,
content_str
)
self
.
assertNotIn
(
ev2b
.
name
,
content_str
)
self
.
assertNotIn
(
ev2b
.
name
,
content_str
)
# Add addintional data to event 1 to append the persons
ev1
.
additional_data
=
{
'
id
'
:
12334
,
'
url
'
:
'
https://fahrplan.events.ccc.de/congress/2023/fahrplan/events/12334.html
'
,
'
slug
'
:
'
Vogc-12334-eroffnung
'
,
'
type
'
:
'
lecture
'
,
'
track
'
:
'
CCC
'
,
'
persons
'
:
[
{
'
id
'
:
987654
,
'
guid
'
:
'
aaaaaaaa-0000-000d-d00d-1d1d1d1d1d1d
'
,
'
name
'
:
'
arthur
'
,
'
links
'
:
[],
'
biography
'
:
'
Test speaker
'
,
'
public_name
'
:
'
arthur
'
,
}
],
}
ev1
.
save
()
# check that event is in the output
resp
=
self
.
client
.
get
(
schedule_url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
content_parser
(
content_str
)
self
.
assertIn
(
ev1
.
name
,
content_str
)
if
url_suffix
==
'
.json
'
:
resp
=
self
.
client
.
get
(
event_url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
content_str
=
resp
.
content
.
decode
(
'
utf-8
'
)
content_parser
(
content_str
)
self
.
assertIn
(
ev1
.
name
,
content_str
)
def
test_export_json
(
self
):
def
test_export_json
(
self
):
self
.
_test_schedule_export
(
'
.json
'
,
'
application/json
'
,
json
.
loads
)
self
.
_test_schedule_export
(
'
.json
'
,
'
application/json
'
,
json
.
loads
)
...
...
This diff is collapsed.
Click to expand it.
src/core/models/events.py
+
1
−
3
View file @
4e5c59f0
...
@@ -227,9 +227,7 @@ class Event(TaggedItemMixin, BackendMixin, models.Model):
...
@@ -227,9 +227,7 @@ class Event(TaggedItemMixin, BackendMixin, models.Model):
@property
@property
def
public_speakers
(
self
)
->
list
:
def
public_speakers
(
self
)
->
list
:
"""
Returns a list of all public speakers of this event.
"""
"""
Returns a list of all public speakers of this event.
"""
persons
=
(
persons
=
[
participant
.
participant
for
participant
in
self
.
participants
.
filter
(
is_public
=
True
,
role
=
EventParticipant
.
Role
.
SPEAKER
)]
self
.
participants
.
filter
(
is_public
=
True
,
role
=
EventParticipant
.
Role
.
SPEAKER
).
select_related
(
'
participant
'
).
order_by
(
'
participant__display_name
'
)
)
if
len
(
persons
)
==
0
and
self
.
kind
==
Event
.
Kind
.
SELF_ORGANIZED
and
self
.
owner
:
if
len
(
persons
)
==
0
and
self
.
kind
==
Event
.
Kind
.
SELF_ORGANIZED
and
self
.
owner
:
persons
.
add
(
self
.
owner
)
persons
.
add
(
self
.
owner
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment