mediacms-io / mediacms

MediaCMS is a modern, fully featured open source video and media CMS, written in Python/Django and React, featuring a REST API.
https://mediacms.io
GNU Affero General Public License v3.0
2.85k stars 531 forks source link

Arrangement of subtitles #845

Open cdorsat opened 1 year ago

cdorsat commented 1 year ago

Describe the issue Subtitles should be arranged in the order of the first letter of the language, which is more in line with human habits

subtitle

sonukumar7258 commented 1 year ago

Is this issue available, I want to contribute on this?

mgogoulos commented 1 year ago

Sure, feel free to open a PR if you want. A hint here, files.models.Subtitle is not having a default ordering, (eg as Media or others). So Subtitles are returned based on their id (what was created first). files.models.subtitles_info can be changed, to include the ordering, eg something like

change:

for subtitle in self.subtitles.all():

to:

for subtitle in self.subtitles.filter().order_by('language__title'):
sonukumar7258 commented 1 year ago

or we can sort language title by first letter also like as stated/ asked by [cdorsat] Like implementing the sorted function

like change:

for subtitle in self.subtitles.all():

to :

sorted_subtitles = sorted(self.subtitles.all(), key=lambda s: s.language.title[0])
for subtitle in sorted_subtitles:

Moreever i have created pull request please review and let me know if i have to make some more changes also.

Thanks for giving me this opportunity and hint.

Regards,

Sonu Kumar