Skip to content

Commit

Permalink
Address feedback, make docstrings less imperative
Browse files Browse the repository at this point in the history
  • Loading branch information
AetherUnbound committed May 6, 2024
1 parent c57fda4 commit b93d52b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 41 deletions.
4 changes: 2 additions & 2 deletions api/api/migrations/0060_fill_out_help_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='audio',
name='removed_from_source',
field=models.BooleanField(default=False, help_text='Whether or not the media has been removed from the upstream source.'),
field=models.BooleanField(default=False, help_text='Whether the media has been removed from the upstream source.'),
),
migrations.AlterField(
model_name='audio',
Expand Down Expand Up @@ -58,7 +58,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='image',
name='removed_from_source',
field=models.BooleanField(default=False, help_text='Whether or not the media has been removed from the upstream source.'),
field=models.BooleanField(default=False, help_text='Whether the media has been removed from the upstream source.'),
),
migrations.AlterField(
model_name='image',
Expand Down
12 changes: 6 additions & 6 deletions api/api/models/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AudioAddOn(OpenLedgerModel):

class Audio(AudioFileMixin, AbstractMedia):
"""
Represents one audio media instance.
One audio media instance.
Inherited fields
================
Expand Down Expand Up @@ -254,7 +254,7 @@ class Meta(AbstractMedia.Meta):

class DeletedAudio(AbstractDeletedMedia):
"""
Represents audio tracks deleted from the upstream source.
Audio tracks deleted from the upstream source.
Do not create instances of this model manually. Create an ``AudioReport`` instance
instead.
Expand All @@ -280,7 +280,7 @@ class Meta:

class SensitiveAudio(AbstractSensitiveMedia):
"""
Represents audio tracks with verified sensitivity reports.
Audio tracks with verified sensitivity reports.
Do not create instances of this model manually. Create an ``AudioReport`` instance
instead.
Expand All @@ -307,7 +307,7 @@ class Meta:

class AudioReport(AbstractMediaReport):
"""
Represents user-submitted reports of audio tracks.
User-submitted reports of audio tracks.
``AudioDecision`` is populated only if moderators have made a decision
for this report.
Expand Down Expand Up @@ -337,7 +337,7 @@ class Meta:


class AudioDecision(AbstractMediaDecision):
"""Represents moderation decisions taken for audio tracks."""
"""Moderation decisions taken for audio tracks."""

media_class = Audio

Expand All @@ -349,7 +349,7 @@ class AudioDecision(AbstractMediaDecision):


class AudioList(AbstractMediaList):
"""Represents a list of audio files. Currently unused."""
"""A list of audio files. Currently unused."""

audios = models.ManyToManyField(
Audio,
Expand Down
10 changes: 5 additions & 5 deletions api/api/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Meta:

class Image(ImageFileMixin, AbstractMedia):
"""
Represents one image media instance.
One image media instance.
Inherited fields
================
Expand All @@ -60,7 +60,7 @@ def sensitive(self) -> bool:

class DeletedImage(AbstractDeletedMedia):
"""
Represents images deleted from the upstream source.
Images deleted from the upstream source.
Do not create instances of this model manually. Create an ``ImageReport`` instance
instead.
Expand All @@ -83,7 +83,7 @@ class DeletedImage(AbstractDeletedMedia):

class SensitiveImage(AbstractSensitiveMedia):
"""
Represents images with verified sensitivity reports.
Images with verified sensitivity reports.
Do not create instances of this model manually. Create an ``ImageReport`` instance
instead.
Expand Down Expand Up @@ -139,7 +139,7 @@ class Meta:


class ImageDecision(AbstractMediaDecision):
"""Represents moderation decisions taken for images."""
"""Moderation decisions taken for images."""

media_class = Image

Expand All @@ -151,7 +151,7 @@ class ImageDecision(AbstractMediaDecision):


class ImageList(AbstractMediaList):
"""Represents a list of images. Currently unused."""
"""A list of images. Currently unused."""

images = models.ManyToManyField(
Image,
Expand Down
14 changes: 5 additions & 9 deletions api/api/models/media.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import mimetypes
from textwrap import dedent as d
from textwrap import dedent

from django.conf import settings
from django.core.exceptions import ValidationError
Expand Down Expand Up @@ -87,8 +87,7 @@ class AbstractMedia(
tags = models.JSONField(
blank=True,
null=True,
help_text=d(
"""
help_text=dedent("""
JSON array of objects containing tags for the media. Each tag object
is expected to have:
Expand All @@ -98,8 +97,7 @@ class AbstractMedia(
for that label expressed as a value between 0 and 1.
Note that only `name` and `accuracy` are presently surfaced in API results.
"""
),
"""),
)

category = models.CharField(
Expand All @@ -113,14 +111,12 @@ class AbstractMedia(
meta_data = models.JSONField(
blank=True,
null=True,
help_text=d(
"""
help_text=dedent("""
JSON object containing extra data about the media item. No fields are expected,
but if the `license_url` field is available, it will be used for determining
the license URL for the media item. The `description` field, if available, is
also indexed into Elasticsearch and as a search field on queries.
"""
),
"""),
)

@property
Expand Down
33 changes: 14 additions & 19 deletions documentation/meta/media_properties/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ Each object is expected to contain:

#### `audio_report`

**Model docstring:** Represents audio tracks that have been reported by users.
**Model docstring:** User-submitted reports of audio tracks.

This contains an `AudioDecision` as well, if moderators have made a decision for
this report.
`AudioDecision` is populated only if moderators have made a decision for this
report.

(Audio-audio_set_foreign_identifier-notes)=

Expand All @@ -107,7 +107,7 @@ this report.

#### `audiodecision`

**Model docstring:** Represents moderation decisions taken for audio tracks.
**Model docstring:** Moderation decisions taken for audio tracks.

(Audio-audioset-notes)=

Expand Down Expand Up @@ -152,8 +152,7 @@ The FileMixin inherited by this model refers not to audio but album art.

#### `deleted_audio`

**Model docstring:** Represents audio tracks that have been deleted from the
source.
**Model docstring:** Audio tracks deleted from the upstream source.

Do not create instances of this model manually. Create an `AudioReport` instance
instead.
Expand Down Expand Up @@ -230,7 +229,7 @@ explicitly.

#### `lists`

**Model docstring:** Represents a list of audio files. Currently unused.
**Model docstring:** A list of audio files. Currently unused.

(Audio-meta_data-notes)=

Expand All @@ -251,8 +250,7 @@ available, is also indexed into Elasticsearch and as a search field on queries.

#### `removed_from_source`

**Help text:** Whether or not the media has been removed from the upstream
source.
**Help text:** Whether the media has been removed from the upstream source.

(Audio-sample_rate-notes)=

Expand All @@ -264,8 +262,7 @@ source.

#### `sensitive_audio`

**Model docstring:** Represents audio tracks that have been flagged and verified
as 'mature'.
**Model docstring:** Audio tracks with verified sensitivity reports.

Do not create instances of this model manually. Create an `AudioReport` instance
instead.
Expand Down Expand Up @@ -389,7 +386,7 @@ Note that only `name` and `accuracy` are presently surfaced in API results.

#### `deleted_image`

**Model docstring:** Represents images that have been deleted from the source.
**Model docstring:** Images deleted from the upstream source.

Do not create instances of this model manually. Create an `ImageReport` instance
instead.
Expand Down Expand Up @@ -441,7 +438,7 @@ explicitly.

#### `image_report`

**Model docstring:** Represents images that have been reported by users.
**Model docstring:** User-submitted report of an image.

This contains an `ImageDecision` as well, if moderators have made a decision for
this report.
Expand All @@ -450,7 +447,7 @@ this report.

#### `imagedecision`

**Model docstring:** Represents moderation decisions taken for images.
**Model docstring:** Moderation decisions taken for images.

(Image-last_synced_with_source-notes)=

Expand All @@ -474,7 +471,7 @@ this report.

#### `lists`

**Model docstring:** Represents a list of images. Currently unused.
**Model docstring:** A list of images. Currently unused.

(Image-meta_data-notes)=

Expand All @@ -495,15 +492,13 @@ available, is also indexed into Elasticsearch and as a search field on queries.

#### `removed_from_source`

**Help text:** Whether or not the media has been removed from the upstream
source.
**Help text:** Whether the media has been removed from the upstream source.

(Image-sensitive_image-notes)=

#### `sensitive_image`

**Model docstring:** Represents images that have been flagged and verified as
'mature'.
**Model docstring:** Images with verified sensitivity reports.

Do not create instances of this model manually. Create an `ImageReport` instance
instead.
Expand Down

0 comments on commit b93d52b

Please sign in to comment.