def redirect(self, instance): if not self.request.is_ajax(): redirect_url = self.data.get(self.redirect_url_name, self.success_url) if redirect_url: return redirect(redirect_url) data = { 'followers_count': get_followers_count(self.instance), 'followings_count': get_followings_count(self.request.user), '%s_followers_count' % self.identifier: get_followers_count(self.instance, self.identifier), '%s_followings_count' % self.identifier: get_followings_count(self.request.user, self.identifier), } return JSONResponse(data)
def save(self, action, dispatch=True): from sequere.models import get_followers_count origin = action.__class__ if dispatch: signals.pre_save.send(sender=origin, instance=self.instance, action=action) data = action.format_data() if action.uid is None: uid = self.storage.make_uid(data) action.uid = uid self._save(action) if action.actor == self.instance and get_followers_count( self.instance) > 0: dispatch_action.delay(action.actor_uid, data, dispatch=dispatch) if dispatch: signals.post_save.send(sender=origin, instance=self.instance, action=action)
def save(self, action, dispatch=True): from sequere.models import get_followers_count origin = action.__class__ if dispatch: signals.pre_save.send(sender=origin, instance=self.instance, action=action) data = action.format_data() if action.uid is None: uid = self.storage.make_uid(data) action.uid = uid self._save(action) if action.actor == self.instance and get_followers_count(self.instance) > 0: dispatch_action.delay(action.actor_uid, data, dispatch=dispatch) if dispatch: signals.post_save.send(sender=origin, instance=self.instance, action=action)
def redirect(self, instance): if not self.request.is_ajax(): redirect_url = self.data.get(self.redirect_url_name, self.success_url) if redirect_url: return redirect(redirect_url) data = { 'followers_count': get_followers_count(self.instance), 'followings_count': get_followings_count(self.request.user), '%s_followers_count' % self.identifier: get_followers_count(self.instance, self.identifier), '%s_followings_count' % self.identifier: get_followings_count(self.request.user, self.identifier), } return JSONResponse(data)
def save(self, action, dispatch=True): from sequere.models import get_followers_count origin = action.__class__ if dispatch: signals.pre_save.send(sender=origin, instance=self.instance, action=action) self.backend.save(self.instance, action) if action.actor == self.instance and get_followers_count(self.instance) > 0: dispatch_action.delay(action.uid, dispatch=dispatch) if dispatch: signals.post_save.send(sender=origin, instance=self.instance, action=action)
def followers_count(instance, identifier=None): return models.get_followers_count(instance, identifier)