X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/4496d7188a21ea6706e3b8a9ca5742c64767c134..133a8f939cdfa69dd6a7caeafed158aa38d20092:/forum/models/question.py diff --git a/forum/models/question.py b/forum/models/question.py index 485576d..da8083f 100644 --- a/forum/models/question.py +++ b/forum/models/question.py @@ -17,7 +17,7 @@ class Question(QandA): view_count = models.IntegerField(default=0) favourite_count = models.IntegerField(default=0) last_activity_at = models.DateTimeField(default=datetime.datetime.now) - last_activity_by = models.ForeignKey(User, related_name='last_active_in_questions') + last_activity_by = models.ForeignKey(User, related_name='last_active_in_questions', null=True) favorited_by = models.ManyToManyField(User, through='FavoriteQuestion', related_name='favorite_questions') @@ -38,12 +38,10 @@ class Question(QandA): def answer_accepted(self): return self.accepted_answer is not None - def delete(self): - super(Question, self).delete() - try: - ping_google() - except Exception: - logging.debug('problem pinging google did you register you sitemap with google?') + def save(self, *args, **kwargs): + if not self.last_activity_by: + self.last_activity_by = self.author + super(Question, self).save(*args, **kwargs) def update_last_activity(self, user): self.last_activity_by = user @@ -78,9 +76,6 @@ class Question(QandA): def get_revision_url(self): return reverse('question_revisions', args=[self.id]) - def get_latest_revision(self): - return self.revisions.all()[0] - def get_related_questions(self, count=10): cache_key = '%s.related_questions:%d:%d' % (settings.APP_URL, count, self.id) related_list = cache.get(cache_key)