Skip to content

Commit

Permalink
fields pages (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
abeglova authored Mar 26, 2024
1 parent 15ade81 commit d453990
Show file tree
Hide file tree
Showing 31 changed files with 1,994 additions and 19 deletions.
13 changes: 8 additions & 5 deletions channels/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ def get_is_moderator(self, instance) -> bool:
return True
return False

def get_avatar(self, channel) -> str:
def get_avatar(self, channel) -> str | None:
"""Get the avatar image URL"""
return channel.avatar.url if channel.avatar else None

def get_avatar_small(self, channel) -> str:
def get_avatar_small(self, channel) -> str | None:
"""Get the avatar image small URL"""
return channel.avatar_small.url if channel.avatar_small else None

def get_avatar_medium(self, channel) -> str:
def get_avatar_medium(self, channel) -> str | None:
"""Get the avatar image medium URL"""
return channel.avatar_medium.url if channel.avatar_medium else None

def get_banner(self, channel) -> str:
def get_banner(self, channel) -> str | None:
"""Get the banner image URL"""
return channel.banner.url if channel.banner else None

Expand Down Expand Up @@ -110,7 +110,10 @@ class FieldChannelSerializer(ChannelAppearanceMixin, serializers.ModelSerializer

lists = serializers.SerializerMethodField()
featured_list = LearningPathPreviewSerializer(
many=False, read_only=True, help_text="Learning path featured in this field."
allow_null=True,
many=False,
read_only=True,
help_text="Learning path featured in this field.",
)
subfields = SubfieldSerializer(many=True, read_only=True)

Expand Down
9 changes: 9 additions & 0 deletions frontends/api/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
ProgramLettersApi,
LearningResourcesSearchApi,
} from "./generated/v1/api"

import { FieldsApi, WidgetListsApi } from "./generated/v0/api"

import axiosInstance from "./axios"

const BASE_PATH = ""
Expand Down Expand Up @@ -36,11 +39,17 @@ const programLettersApi = new ProgramLettersApi(
BASE_PATH,
axiosInstance,
)

const fieldsApi = new FieldsApi(undefined, BASE_PATH, axiosInstance)
const widgetListsApi = new WidgetListsApi(undefined, BASE_PATH, axiosInstance)

export {
learningResourcesApi,
learningpathsApi,
topicsApi,
articlesApi,
programLettersApi,
learningResourcesSearchApi,
fieldsApi,
widgetListsApi,
}
Loading

0 comments on commit d453990

Please sign in to comment.