Skip to content

Commit 2eaaf0e

Browse files
authored
Feature-9020: Add API docs for video interpretation / translation channels (#9063)
* fix issue user request check in not admin * feature-9020: Add API docs for video interpretation / translation channels * feature-9020: Add API docs for video interpretation / translation channels * feature-9020: Add API docs for video interpretation / translation channels * feature-9020: Add API docs for video interpretation / translation channels * fix ci
1 parent e3e3848 commit 2eaaf0e

File tree

4 files changed

+174
-1
lines changed

4 files changed

+174
-1
lines changed

app/api/translation_channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def query(self, view_kwargs):
3939
)
4040
return records
4141
else:
42-
return None
42+
return self.session.query(TranslationChannel)
4343

4444
methods = ["GET"]
4545
schema = TranslationChannelSchema
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Group Translation Channels
2+
Data related to translation channel table
3+
4+
| Parameter | Description | Type | Required | Public |
5+
|:----------|-------------|------|----------|--------|
6+
| `name` | Name of Translation channel | string | **yes** | **yes** |
7+
| `url` | URL of Translation channel | Url | **yes** | **yes** |
8+
9+
## Translation Channels [/v1/translation_channels{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
10+
+ Parameters
11+
+ page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
12+
+ page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
13+
+ sort (optional, string, `url`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
14+
+ filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.
15+
16+
17+
18+
### List all Translation Channels [GET]
19+
Get a list of all Translation Channels
20+
21+
+ Request
22+
23+
+ Headers
24+
25+
Accept: application/vnd.api+json
26+
27+
Authorization: JWT <Auth Key>
28+
29+
30+
+ Response 200 (application/vnd.api+json)
31+
32+
{
33+
"data": [
34+
{
35+
"relationships": {
36+
"channel": {
37+
"links": {
38+
"self": "/v1/translation_channel/1/relationships/channels",
39+
"related": "/v1/video-channels/1"
40+
}
41+
},
42+
"video-stream": {
43+
"links": {
44+
"self": "/v1/translation_channel/1/relationships/video-stream",
45+
"related": "/v1/video-streams/1"
46+
}
47+
}
48+
},
49+
"attributes": {
50+
"name": "example-channel",
51+
"url": "http://example-channel.com"
52+
},
53+
"type": "translation_channel",
54+
"id": 1,
55+
"links": {
56+
"self": "/v1/translation_channels/1"
57+
}
58+
}
59+
],
60+
"links": {
61+
"self": "/v1/translation_channels?page%5Bsize%5D=10&page%5Bnumber%5D=2&sort=url&filter=%5B%5D"
62+
},
63+
"meta": {
64+
"count": 1
65+
},
66+
"jsonapi": {
67+
"version": "1.0"
68+
}
69+
}
70+
71+
## Translation Channels [/v1/video-streams/{video_stream_id}/translation_channels]
72+
+ Parameters
73+
+ video_stream_id: 1 (string) - identifier or stream id.
74+
75+
76+
77+
### List all Translation Channels Of Video Stream [GET]
78+
Get a list of all Video Streams
79+
80+
+ Request
81+
82+
+ Headers
83+
84+
Accept: application/vnd.api+json
85+
86+
Authorization: JWT <Auth Key>
87+
88+
89+
+ Response 200 (application/vnd.api+json)
90+
91+
{
92+
"data": [
93+
{
94+
"relationships": {
95+
"channel": {
96+
"links": {
97+
"self": "/v1/translation_channel/1/relationships/channels",
98+
"related": "/v1/video-channels/1"
99+
}
100+
},
101+
"video-stream": {
102+
"links": {
103+
"self": "/v1/translation_channel/1/relationships/video-stream",
104+
"related": "/v1/video-streams/1"
105+
}
106+
}
107+
},
108+
"attributes": {
109+
"name": "example-channel",
110+
"url": "http://example-channel.com"
111+
},
112+
"type": "translation_channel",
113+
"id": 1,
114+
"links": {
115+
"self": "/v1/translation_channels/1"
116+
}
117+
}
118+
],
119+
"links": {
120+
"self": "/v1/translation_channels?page%5Bsize%5D=10&page%5Bnumber%5D=2&sort=url&filter=%5B%5D"
121+
},
122+
"meta": {
123+
"count": 1
124+
},
125+
"jsonapi": {
126+
"version": "1.0"
127+
}
128+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import factory
2+
3+
from app.models.translation_channels import TranslationChannel
4+
from tests.factories import common
5+
from tests.factories.base import BaseFactory
6+
from tests.factories.video_stream import VideoStreamFactoryBase
7+
8+
9+
class TranslationChannelFactory(BaseFactory):
10+
class Meta:
11+
model = TranslationChannel
12+
13+
video_stream = factory.RelatedFactory(VideoStreamFactoryBase)
14+
name = common.string_
15+
url = common.url_

tests/hook_main.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
from tests.all.integration.api.helpers.order.test_calculate_order_amount import (
8989
_create_taxed_tickets,
9090
)
91+
from tests.factories.translation_channel import TranslationChannelFactory
92+
from tests.factories.video_stream import VideoStreamFactoryBase
9193

9294
stash = {}
9395
api_username = "open_event_test_user@fossasia.org"
@@ -5237,3 +5239,31 @@ def badge_export_pdf_get(transaction):
52375239
)
52385240
AttendeeFactory(ticket_id=1)
52395241
db.session.commit()
5242+
5243+
5244+
@hooks.before(
5245+
"Translation Channels > Translation Channels > List all Translation Channels"
5246+
)
5247+
def list_all_translation(transaction):
5248+
"""
5249+
:param transaction:
5250+
:return:
5251+
"""
5252+
with stash['app'].app_context():
5253+
video_stream = VideoStreamFactoryBase()
5254+
TranslationChannelFactory(video_stream=video_stream)
5255+
db.session.commit()
5256+
5257+
5258+
@hooks.before(
5259+
"Translation Channels > Translation Channels > List all Translation Channels Of Video Stream"
5260+
)
5261+
def list_all_translation_of_video_stream(transaction):
5262+
"""
5263+
:param transaction: transaction
5264+
:return:
5265+
"""
5266+
with stash['app'].app_context():
5267+
video_stream = VideoStreamFactoryBase()
5268+
TranslationChannelFactory(video_stream=video_stream)
5269+
db.session.commit()

0 commit comments

Comments
 (0)