ratings.Rating

Model Info

Key

Value

Model Name

Rating

Verbose Name

rating

Verbose Name Plural

ratings

Docstring

Rating(created, modified, id, addon, version, user, reply_to, rating, body, ip_address, editorreview, flag, deleted, is_latest, previous_count)

Is Abstract

False

Is Proxy

False

Is Managed

True

Ordering

(‘-created’,)

Permissions

[]

Default Permissions

(‘add’, ‘change’, ‘delete’, ‘view’)

Indexes

[<Index: fields=[‘version’] name=’version_id’>, <Index: fields=[‘user’] name=’reviews_ibfk_2’>, <Index: fields=[‘addon’] name=’reviews_addon_idx’>, <Index: fields=[‘reply_to’, ‘is_latest’, ‘addon’, ‘created’] name=’latest_reviews’>, <Index: fields=[‘ip_address’] name=’reviews_ip_address_057fddfa’>]

Constraints

[<UniqueConstraint: fields=(‘version’, ‘user’, ‘reply_to’, ‘deleted’) name=’one_review_per_user’>]

Database Table

reviews

Base Manager

unfiltered

Default Manager

None

File

/data/olympia/src/olympia/ratings/models.py

Starting Line Number

105

Method Resolution Order

(<class ‘olympia.ratings.models.Rating’>, <class ‘olympia.amo.models.ModelBase’>, <class ‘olympia.amo.models.SaveUpdateMixin’>, <class ‘django.db.models.base.Model’>, <class ‘django.db.models.utils.AltersData’>, <class ‘object’>)

Fields

Field Name

Field Type

Database Column

Database Type

Verbose Name

BannedUserContent_ratings+

ManyToOneRel

integer UNSIGNED

abuse_reports

ManyToOneRel

integer UNSIGNED

addon

ForeignKey

addon_id

integer UNSIGNED

addon

bannedusercontent

ManyToManyRel

through users.BannedUserContent_ratings

body

TextField

text_body

longtext

body

created

DateTimeField

created

datetime(6)

created

decisions_on

ManyToOneRel

integer UNSIGNED

deleted

IntegerField

deleted

integer

deleted

editorreview

BooleanField

editorreview

bool

editorreview

flag

BooleanField

flag

bool

flag

id (pk)

PositiveAutoField

id

integer UNSIGNED AUTO_INCREMENT

id

ip_address

CharField

ip_address

varchar(45)

ip address

is_latest

BooleanField

is_latest

bool

is latest

modified

DateTimeField

modified

datetime(6)

modified

previous_count

PositiveIntegerField

previous_count

integer UNSIGNED

previous count

rating

PositiveSmallIntegerField

rating

smallint UNSIGNED

rating

ratingflag

ManyToOneRel

integer UNSIGNED

ratinglog

ManyToOneRel

integer UNSIGNED

replies

ManyToOneRel

integer UNSIGNED

reply_to

ForeignKey

reply_to

integer UNSIGNED

reply to

user

ForeignKey

user_id

integer

user

version

ForeignKey

version_id

integer UNSIGNED

version

Relations

Field Name

Field Type

Database Column

Database Type

Related Model

Related Name

addon

ForeignKey

addon_id

integer UNSIGNED

addons.Addon

_ratings

reply_to

ForeignKey

reply_to

integer UNSIGNED

ratings.Rating

replies

user

ForeignKey

user_id

integer

users.UserProfile

_ratings_all

version

ForeignKey

version_id

integer UNSIGNED

versions.Version

ratings

fields_reverse_relation=[FieldReverseRelation(name=’abuse_reports’, field_type=’ManyToOneRel’, field_db_type=’integer UNSIGNED’, related_model=’abuse.AbuseReport’, field_name_on_related_model=’rating’, field_type_on_related_model=’ForeignKey’), FieldReverseRelation(name=’decisions_on’, field_type=’ManyToOneRel’, field_db_type=’integer UNSIGNED’, related_model=’abuse.ContentDecision’, field_name_on_related_model=’rating’, field_type_on_related_model=’ForeignKey’), FieldReverseRelation(name=’rating_set’, field_type=’ManyToOneRel’, field_db_type=’integer UNSIGNED’, related_model=’activity.RatingLog’, field_name_on_related_model=’rating’, field_type_on_related_model=’ForeignKey’), FieldReverseRelation(name=’replies’, field_type=’ManyToOneRel’, field_db_type=’integer UNSIGNED’, related_model=’ratings.Rating’, field_name_on_related_model=’reply_to’, field_type_on_related_model=’ForeignKey’), FieldReverseRelation(name=’rating_set’, field_type=’ManyToOneRel’, field_db_type=’integer UNSIGNED’, related_model=’ratings.RatingFlag’, field_name_on_related_model=’rating’, field_type_on_related_model=’ForeignKey’), FieldReverseRelation(name=’BannedUserContent_ratings+ (no reverse relation allowed)’, field_type=’ManyToOneRel’, field_db_type=’integer UNSIGNED’, related_model=’users.BannedUserContent_ratings’, field_name_on_related_model=’rating’, field_type_on_related_model=’ForeignKey’), FieldReverseRelation(name=’rating_set’, field_type=’ManyToManyRel’, field_db_type=’through users.BannedUserContent_ratings’, related_model=’users.BannedUserContent’, field_name_on_related_model=’ratings’, field_type_on_related_model=’ManyToManyField’)]

Reverse Relations

Field Name

Field Type

Database Type

Related Model

Field Name on Related Model

Field Type on Related Model

BannedUserContent_ratings+ (no reverse relation allowed)

ManyToOneRel

integer UNSIGNED

users.BannedUserContent_ratings

rating

ForeignKey

abuse_reports

ManyToOneRel

integer UNSIGNED

abuse.AbuseReport

rating

ForeignKey

decisions_on

ManyToOneRel

integer UNSIGNED

abuse.ContentDecision

rating

ForeignKey

rating_set

ManyToOneRel

integer UNSIGNED

activity.RatingLog

rating

ForeignKey

rating_set

ManyToOneRel

integer UNSIGNED

ratings.RatingFlag

rating

ForeignKey

rating_set

ManyToManyRel

through users.BannedUserContent_ratings

users.BannedUserContent

ratings

ManyToManyField

replies

ManyToOneRel

integer UNSIGNED

ratings.Rating

reply_to

ForeignKey

Methods

Other Methods

Method Name

Signature

approve

(self)

get_admin_absolute_url

(self)

get_admin_url_path

(self)

get_next_by_created

(self, *, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)

get_next_by_modified

(self, *, field=<django.db.models.fields.DateTimeField: modified>, is_next=True, **kwargs)

get_previous_by_created

(self, *, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)

get_previous_by_modified

(self, *, field=<django.db.models.fields.DateTimeField: modified>, is_next=False, **kwargs)

get_rating_display

(self, *, field=<django.db.models.fields.PositiveSmallIntegerField: rating>)

get_replies

(ratings)

get_unfiltered_manager

()

get_url_path

(self)

post_save

(sender, instance, created, **kwargs)

reload

(self)

send_notification_email

(self)

serializable_reference

(self)

undelete

(self, *, skip_activity_log=False)

update

(self, **kw)

update_denormalized_fields

(self)

Private Methods

Method Name

Signature

_get_field_value_map

(self, meta, exclude=None)

Custom Managers

default

Class: RatingManager

*Base for all managers in AMO.

Returns BaseQuerySets.

If a model has translated fields, they’ll be attached through a transform function.*

Custom Methods

transform(self, fn)

Custom QuerySet

Class: RatingQuerySet

A queryset modified for soft deletion.

Custom Methods
no_transforms(self)
only_translations(self)

Remove all transforms except translations.

optimized_count(self)

*Slightly optimized count() for cases where there is a DISTINCT in the queryset.

When a count() call is made on a queryset that has a distinct, that causes django to run the full SELECT (including all fields, distinct, ordering etc) in a subquery and then COUNT() on the result of that subquery, which is costly/innefficient. That’s tracked in https://code.djangoproject.com/ticket/30685. We can’t easily fix the fact that there is a subquery, but we can avoid selecting all fields and ordering in that subquery needlessly.*

pop_transforms(self)
to_moderate(self)

*Return ratings to moderate.

Ratings attached lacking an addon or attached to an addon that is no longer nominated or public are ignored, as well as ratings attached to unlisted versions.*

transform(self, fn)
undelete(self)
update_ratings_and_addons_denormalized_fields(self, pairs)

objects

Class: RatingManager

*Base for all managers in AMO.

Returns BaseQuerySets.

If a model has translated fields, they’ll be attached through a transform function.*

Custom Methods

transform(self, fn)

Custom QuerySet

Class: RatingQuerySet

A queryset modified for soft deletion.

Custom Methods
no_transforms(self)
only_translations(self)

Remove all transforms except translations.

optimized_count(self)

*Slightly optimized count() for cases where there is a DISTINCT in the queryset.

When a count() call is made on a queryset that has a distinct, that causes django to run the full SELECT (including all fields, distinct, ordering etc) in a subquery and then COUNT() on the result of that subquery, which is costly/innefficient. That’s tracked in https://code.djangoproject.com/ticket/30685. We can’t easily fix the fact that there is a subquery, but we can avoid selecting all fields and ordering in that subquery needlessly.*

pop_transforms(self)
to_moderate(self)

*Return ratings to moderate.

Ratings attached lacking an addon or attached to an addon that is no longer nominated or public are ignored, as well as ratings attached to unlisted versions.*

transform(self, fn)
undelete(self)
update_ratings_and_addons_denormalized_fields(self, pairs)

unfiltered

Class: RatingManager

*Base for all managers in AMO.

Returns BaseQuerySets.

If a model has translated fields, they’ll be attached through a transform function.*

Custom Methods

transform(self, fn)

Custom QuerySet

Class: RatingQuerySet

A queryset modified for soft deletion.

Custom Methods
no_transforms(self)
only_translations(self)

Remove all transforms except translations.

optimized_count(self)

*Slightly optimized count() for cases where there is a DISTINCT in the queryset.

When a count() call is made on a queryset that has a distinct, that causes django to run the full SELECT (including all fields, distinct, ordering etc) in a subquery and then COUNT() on the result of that subquery, which is costly/innefficient. That’s tracked in https://code.djangoproject.com/ticket/30685. We can’t easily fix the fact that there is a subquery, but we can avoid selecting all fields and ordering in that subquery needlessly.*

pop_transforms(self)
to_moderate(self)

*Return ratings to moderate.

Ratings attached lacking an addon or attached to an addon that is no longer nominated or public are ignored, as well as ratings attached to unlisted versions.*

transform(self, fn)
undelete(self)
update_ratings_and_addons_denormalized_fields(self, pairs)

unfiltered_for_relations

Class: UnfilteredRatingManagerForRelations

*Like RatingManager, but defaults to include deleted objects.

Designed to be used in reverse relations of Ratings like this: .replies(manager=’unfiltered_for_relations’).all(), for when you want to use the related manager but need to include deleted replies.

unfiltered_for_relations = UnfilteredRatingManagerForRelations() is defined in Rating for this to work.*

Custom Methods

transform(self, fn)

Custom QuerySet

Class: RatingQuerySet

A queryset modified for soft deletion.

Custom Methods
no_transforms(self)
only_translations(self)

Remove all transforms except translations.

optimized_count(self)

*Slightly optimized count() for cases where there is a DISTINCT in the queryset.

When a count() call is made on a queryset that has a distinct, that causes django to run the full SELECT (including all fields, distinct, ordering etc) in a subquery and then COUNT() on the result of that subquery, which is costly/innefficient. That’s tracked in https://code.djangoproject.com/ticket/30685. We can’t easily fix the fact that there is a subquery, but we can avoid selecting all fields and ordering in that subquery needlessly.*

pop_transforms(self)
to_moderate(self)

*Return ratings to moderate.

Ratings attached lacking an addon or attached to an addon that is no longer nominated or public are ignored, as well as ratings attached to unlisted versions.*

transform(self, fn)
undelete(self)
update_ratings_and_addons_denormalized_fields(self, pairs)

without_replies

Class: WithoutRepliesRatingManager

Manager to fetch ratings that aren’t replies (and aren’t deleted).

Custom Methods

transform(self, fn)

Custom QuerySet

Class: RatingQuerySet

A queryset modified for soft deletion.

Custom Methods
no_transforms(self)
only_translations(self)

Remove all transforms except translations.

optimized_count(self)

*Slightly optimized count() for cases where there is a DISTINCT in the queryset.

When a count() call is made on a queryset that has a distinct, that causes django to run the full SELECT (including all fields, distinct, ordering etc) in a subquery and then COUNT() on the result of that subquery, which is costly/innefficient. That’s tracked in https://code.djangoproject.com/ticket/30685. We can’t easily fix the fact that there is a subquery, but we can avoid selecting all fields and ordering in that subquery needlessly.*

pop_transforms(self)
to_moderate(self)

*Return ratings to moderate.

Ratings attached lacking an addon or attached to an addon that is no longer nominated or public are ignored, as well as ratings attached to unlisted versions.*

transform(self, fn)
undelete(self)
update_ratings_and_addons_denormalized_fields(self, pairs)

!!! THIS DOCUMENT WAS AUTOGENERATED ON 2025-07-11 !!!