The rating of Post should be updaed if the count is greater than 10
322555
def update_post(self, postid):
        '''
        


        '''
        voted_recs = MRating.query_by_post(postid)
        if voted_recs.count() > 10:
            rating = MRating.query_average_rating(postid)
        else:
            rating = 5

        logger.info('Get post rating: {rating}'.format(rating=rating))
        # MPost.__update_rating(postid, rating)
        MPost.update_misc(postid, rating=rating)
10814
def get_last(postid, limit=10):
        '''
        
        '''
        recs = TabPostHist.select().where(
            TabPostHist.post_id == postid
        ).order_by(TabPostHist.time_update.desc()).limit(limit)
        if recs.count():
            return recs.get()
        return None
1195933
def rating(self, value):
        
        if not self.can_update():
            self._tcex.handle_error(910, [self.type])
        request_data = {'rating': value}
        return self.tc_requests.update(
            self.api_type, self.api_sub_type, self.unique_id, request_data, owner=self.owner
        )
543658
def on_post(self, req, resp, **kwargs):
        """"""
        validated = self.require_validated(req)

        return super().on_post(
            req, resp,
            handler=partial(self._create, validated=validated),
            **kwargs
        )
1315712
def __update_rating(uid, rating):
        '''
        
        '''
        entry = TabPost.update(
            rating=rating
        ).where(TabPost.uid == uid)
        entry.execute()
427863
def decrease_posts_count_after_post_unaproval(sender, instance, **kwargs):
    
    if not instance.pk:
        # Do not consider posts being created.
        return

    profile, dummy = ForumProfile.objects.get_or_create(user=instance.poster)

    try:
        old_instance = instance.__class__._default_manager.get(pk=instance.pk)
    except ObjectDoesNotExist:  # pragma: no cover
        # This should never happen (except with django loaddata command)
        return

    if old_instance and old_instance.approved is True and instance.approved is False:
        profile.posts_count = F('posts_count') - 1
        profile.save()
690367
def do_rating_by_user(parser, token):
    
    
    bits = token.contents.split()
    if len(bits) != 6:
        raise template.TemplateSyntaxError("'%s' tag takes exactly five arguments" % bits[0])
    if bits[2] != 'on':
        raise template.TemplateSyntaxError("second argument to '%s' tag must be 'on'" % bits[0])
    if bits[4] != 'as':
        raise template.TemplateSyntaxError("fourth argument to '%s' tag must be 'as'" % bits[0])
    return RatingByUserNode(bits[1], bits[3], bits[5])
594468
def update_misc(uid, **kwargs):
        '''
        
        '''
        if 'rating' in kwargs:
            MPost.__update_rating(uid, kwargs['rating'])
        elif 'kind' in kwargs:
            MPost.__update_kind(uid, kwargs['kind'])
        elif 'keywords' in kwargs:
            MPost.__update_keywords(uid, kwargs['keywords'])
        elif 'count' in kwargs:
            MPost.__update_view_count(uid)
413377
protected function validateStatusOrder()
    {
        $field = 'status';
        $value = $this->getSubmitted($field);

        if (!isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $statuses = $this->order->getStatuses();

        if (empty($statuses[$value])) {
            $this->setErrorUnavailable($field, $this->translation->text('Status'));
            return false;
        }

        return true;
    }
166980
def up_vote!(votable)
      begin
        up_vote(votable)
        success = true
      rescue Exceptions::AlreadyVotedError
        success = false
      end
      success
    end
279526
def rating(request):
    
    response = initial_validation(request, "rating")
    if isinstance(response, HttpResponse):
        return response
    obj, post_data = response
    url = add_cache_bypass(obj.get_absolute_url().split("#")[0])
    response = redirect(url + "#rating-%s" % obj.id)
    rating_form = RatingForm(request, obj, post_data)
    if rating_form.is_valid():
        rating_form.save()
        if request.is_ajax():
            # Reload the object and return the rating fields as json.
            obj = obj.__class__.objects.get(id=obj.id)
            rating_name = obj.get_ratingfield_name()
            json = {}
            for f in ("average", "count", "sum"):
                json["rating_" + f] = getattr(obj, "%s_%s" % (rating_name, f))
            response = HttpResponse(dumps(json))
        if rating_form.undoing:
            ratings = set(rating_form.previous) ^ set([rating_form.current])
        else:
            ratings = rating_form.previous + [rating_form.current]
        set_cookie(response, "yacms-rating", ",".join(ratings))
    return response
938972
def add_or_update(uid, post_data):
        '''
        
        '''
        catinfo = MCategory.get_by_uid(uid)
        if catinfo:
            MCategory.update(uid, post_data)
        else:
            TabTag.create(
                uid=uid,
                name=post_data['name'],
                slug=post_data['slug'],
                order=post_data['order'],
                kind=post_data['kind'] if 'kind' in post_data else '1',
                pid=post_data['pid'],
            )
        return uid
1277397
def raise_for_status(self):
        '''
        
        '''
        if 400 <= self.status_code < 500:
            raise BadStatus('{} Client Error: {} for url: {}'.format(self.status_code, self.reason_phrase, self.url), self.status_code)
        elif 500 <= self.status_code < 600:
            raise BadStatus('{} Server Error: {} for url: {}'.format(self.status_code, self.reason_phrase, self.url), self.status_code)
1118494
function _checkUpdate(){
  var notifier = updateNotifier({
    pkg: pkg,
    updateCheckInterval: 1000 * 60 * 60 * 24 * 7
  })
  if (notifier.update)
    notifier.notify()
}
1072820
def _raise_for_status(self, response, explanation=None):
        """"""
        try:
            response.raise_for_status()
        except requests.exceptions.HTTPError as e:
            if e.response.status_code == 404:
                raise errors.NotFound(e, response, explanation=explanation)
            raise errors.APIError(e, response, explanation=explanation)
1345043
def _update_stat(self, submission_type, increase_success, increase_fail):
    """"""
    stat = self.stats.get(submission_type, (0, 0))
    stat = (stat[0] + increase_success, stat[1] + increase_fail)
    self.stats[submission_type] = stat
1030566
def add_content_ratings(self, app_id, submission_id, security_code):
        
        url = self.url('content_ratings') % app_id
        return self.conn.fetch('POST', url,
                               {'submission_id': '%s' % submission_id,
                                'security_code': '%s' % security_code
                                })