);
}
+sub approx_rating {
+ my $self = shift;
+ $self->rated or return 0;
+ int($self->rating/$self->rated*10)/10;
+}
+
+sub add_rating :Exported {
+ my ($self, $r) = @_;
+ my $photo = $r->{objects}[0];
+ my $delta = $r->{params}{rating};
+ if ($delta < 0 or $delta > 5) { return; } # Scammer
+ # XXX Race
+ $photo->rating($photo->rating() + $delta);
+ $photo->rated($photo->rated() + 1);
+ $r->output(""); # Only used by ajax
+}
+
sub view :Exported {
my ($self, $r) = @_;
my $photo = $r->{objects}[0];