def save_activity(self): """ Save new activity, if activity exists updates it """ from film20.useractivity.models import UserActivity if not self.content_object: raise Exception("ThreadedComment.save_activity: content_object" "missing for new commment") try: # Checking if activity already exists for given note, if so update activity act = UserActivity.objects.get(activity_type = UserActivity.TYPE_COMMENT, comment = self, user = self.user) act.content = self.comment act.title = self.content_object.get_comment_title() act.username = self.user.username act.is_first_post = self.is_first_post act.status = self.status if settings.ENSURE_OLD_STYLE_PERMALINKS: act.permalink = self.content_object.get_absolute_url_old_style() + "#" + str(self.id) else: act.permalink = self.content_object.get_absolute_url() + "#" + str(self.id) act.slug = self.content_object.get_slug() + "#" + str(self.id) act.number_of_comments = self.number_of_comments act.save() except UserActivity.DoesNotExist: # Activity does not exist - create a new one act = UserActivity() act.user = self.user act.username = self.user.username act.activity_type = UserActivity.TYPE_COMMENT act.comment = self # title for object related with comment act.title = self.content_object.get_comment_title() act.content = self.comment act.is_first_post = self.is_first_post act.status = self.status if settings.ENSURE_OLD_STYLE_PERMALINKS: act.permalink = self.content_object.get_absolute_url_old_style() + "#" + str(self.id) else: act.permalink = self.content_object.get_absolute_url() + "#" + str(self.id) act.slug = self.content_object.get_slug() + "#" + str(self.id) act.number_of_comments = self.number_of_comments act.save()
def save_activity(self): """ Save new activity, if activity exists updates it """ from film20.useractivity.models import UserActivity if not self.content_object: raise Exception("ThreadedComment.save_activity: content_object" "missing for new commment") try: # Checking if activity already exists for given note, if so update activity act = UserActivity.objects.get(activity_type = UserActivity.TYPE_COMMENT, comment = self, user = self.user) act.content = self.comment act.title = self.content_object.get_comment_title() act.username = self.user.username act.is_first_post = self.is_first_post act.status = self.status if settings.ENSURE_OLD_STYLE_PERMALINKS: act.permalink = self.content_object.get_absolute_url_old_style() + "#" + str(self.id) else: act.permalink = self.content_object.get_absolute_url() + "#" + str(self.id) act.slug = self.content_object.get_slug() + "#" + str(self.id) act.save() except UserActivity.DoesNotExist: # Activity does not exist - create a new one act = UserActivity() act.user = self.user act.username = self.user.username act.activity_type = UserActivity.TYPE_COMMENT act.comment = self # title for object related with comment act.title = self.content_object.get_comment_title() act.content = self.comment act.is_first_post = self.is_first_post act.status = self.status if settings.ENSURE_OLD_STYLE_PERMALINKS: act.permalink = self.content_object.get_absolute_url_old_style() + "#" + str(self.id) else: act.permalink = self.content_object.get_absolute_url() + "#" + str(self.id) act.slug = self.content_object.get_slug() + "#" + str(self.id) act.save()