Skip to content

Commit

Permalink
add view onsite link for admin
Browse files Browse the repository at this point in the history
  • Loading branch information
smark-1 authored May 10, 2024
1 parent a01624d commit 0455eb6
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion faq/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def get_absolute_url(self):
else:
return reverse("faq:question_detail", args=(self.slug,))


class Meta:
app_label = 'faq'

Expand Down Expand Up @@ -77,6 +76,13 @@ def save(self, *args, **kwargs):
self.not_helpful = self.get_not_helpful()
super().save(*args, **kwargs)

def get_absolute_url(self):
# if using categories
if "no_category" not in settings.FAQ_SETTINGS:
return reverse("faq:question_detail", args=(self.question.category.slug, self.question.slug))
else:
return reverse("faq:question_detail", args=(self.question.slug,))


class Category(models.Model):
name = models.CharField(max_length=50, unique=True)
Expand All @@ -102,6 +108,9 @@ def save(self, *args, **kwargs):
self.slug = slugify(self.name, allow_unicode='allow_unicode' in settings.FAQ_SETTINGS)[:50]
return super().save(*args, **kwargs)

def get_absolute_url(self):
return reverse("faq:category_detail", args=(self.slug,))


class FAQComment(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True)
Expand All @@ -116,6 +125,13 @@ class Meta:
ordering = ['question', '-post_time']
app_label = 'faq'

def get_absolute_url(self):
# if using categories
if "no_category" not in settings.FAQ_SETTINGS:
return reverse("faq:question_detail", args=(self.question.category.slug, self.question.slug))
else:
return reverse("faq:question_detail", args=(self.question.slug,))


class AnswerHelpful(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
Expand All @@ -134,6 +150,14 @@ class Meta:
ordering = ['answer', 'vote']
app_label = 'faq'

def get_absolute_url(self):
# if using categories
if "no_category" not in settings.FAQ_SETTINGS:
return reverse("faq:question_detail", args=(self.answer.question.category.slug, self.answer.question.slug))
else:
return reverse("faq:question_detail", args=(self.answer.question.slug,))



class QuestionHelpful(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
Expand All @@ -151,3 +175,10 @@ def __str__(self):
class Meta:
ordering = ['question', 'vote']
app_label = 'faq'

def get_absolute_url(self):
# if using categories
if "no_category" not in settings.FAQ_SETTINGS:
return reverse("faq:question_detail", args=(self.question.category.slug, self.question.slug))
else:
return reverse("faq:question_detail", args=(self.question.slug,))

0 comments on commit 0455eb6

Please sign in to comment.