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 |
---|---|---|---|---|
|
ManyToOneRel |
integer UNSIGNED |
||
|
ManyToOneRel |
integer UNSIGNED |
||
|
ForeignKey |
addon_id |
integer UNSIGNED |
addon |
|
ManyToManyRel |
through users.BannedUserContent_ratings |
||
|
TextField |
text_body |
longtext |
body |
|
DateTimeField |
created |
datetime(6) |
created |
|
ManyToOneRel |
integer UNSIGNED |
||
|
IntegerField |
deleted |
integer |
deleted |
|
BooleanField |
editorreview |
bool |
editorreview |
|
BooleanField |
flag |
bool |
flag |
|
PositiveAutoField |
id |
integer UNSIGNED AUTO_INCREMENT |
id |
|
CharField |
ip_address |
varchar(45) |
ip address |
|
BooleanField |
is_latest |
bool |
is latest |
|
DateTimeField |
modified |
datetime(6) |
modified |
|
PositiveIntegerField |
previous_count |
integer UNSIGNED |
previous count |
|
PositiveSmallIntegerField |
rating |
smallint UNSIGNED |
rating |
|
ManyToOneRel |
integer UNSIGNED |
||
|
ManyToOneRel |
integer UNSIGNED |
||
|
ManyToOneRel |
integer UNSIGNED |
||
|
ForeignKey |
reply_to |
integer UNSIGNED |
reply to |
|
ForeignKey |
user_id |
integer |
user |
|
ForeignKey |
version_id |
integer UNSIGNED |
version |
Relations
Field Name |
Field Type |
Database Column |
Database Type |
Related Model |
Related Name |
---|---|---|---|---|---|
|
ForeignKey |
addon_id |
integer UNSIGNED |
addons.Addon |
_ratings |
|
ForeignKey |
reply_to |
integer UNSIGNED |
ratings.Rating |
replies |
|
ForeignKey |
user_id |
integer |
users.UserProfile |
_ratings_all |
|
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 |
---|---|---|---|---|---|
|
ManyToOneRel |
integer UNSIGNED |
users.BannedUserContent_ratings |
rating |
ForeignKey |
|
ManyToOneRel |
integer UNSIGNED |
abuse.AbuseReport |
rating |
ForeignKey |
|
ManyToOneRel |
integer UNSIGNED |
abuse.ContentDecision |
rating |
ForeignKey |
|
ManyToOneRel |
integer UNSIGNED |
activity.RatingLog |
rating |
ForeignKey |
|
ManyToOneRel |
integer UNSIGNED |
ratings.RatingFlag |
rating |
ForeignKey |
|
ManyToManyRel |
through users.BannedUserContent_ratings |
users.BannedUserContent |
ratings |
ManyToManyField |
|
ManyToOneRel |
integer UNSIGNED |
ratings.Rating |
reply_to |
ForeignKey |
Methods
Other Methods
Method Name |
Signature |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Private Methods
Method Name |
Signature |
---|---|
|
|
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:
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 !!!