Anonymous avatar Anonymous committed 064a296

[project @ 339]
Fixed bug #11, by removing inks to posts in hidden topics, and making that /posts/[id]/ page robust against hidden topics

Comments (0)

Files changed (3)


         page = int(previous_posts/settings.FORUM_PAGINATE_POSTS_BY) + 1
         return "%s?page=%s#id%s" % (thread.get_absolute_url(), page,
+    def is_parent_visible(self):
+        if self.topic_id is not None:
+            try:
+                topic = self.topic
+                return True
+            except Topic.DoesNotExist:
+                return False
+        elif self.photo_id is not None:
+            try:
+                photo =
+                return True
+            except Photo.DoesNotExist:
+                return False
+        else:
+            # no parent?
+            return False
     def create_post(member, message, topic=None, photo=None):
         """Creates a post with the correct defaults for a member."""


         post = Post.objects.get(pk=id)
     except Post.DoesNotExist:
         raise Http404()
-    return HttpResponseRedirect(post.get_forum_url())
+    try:
+        url = post.get_forum_url()
+    except Topic.DoesNotExist:
+        return HttpResponseForbidden("<h1>Access denied</h1><p>Topic is hidden.</p>")
+    return HttpResponseRedirect(url)
 def all_topics(request):
     context = standard_extra_context(title="Recent new topics")


 		<div class="postHeader">
 		{% ifchanged %}
-			{% if post.topic_id %}In topic <a href="{{ post.topic.get_absolute_url }}">{{ post.topic.subject|escape }}</a>:{% endif %}
+			{% if post.topic_id %}{% if post.is_parent_visible %}In topic <a href="{{ post.topic.get_absolute_url }}">{{ post.topic.subject|escape }}</a>:{% else %}In a hidden topic:{% endif %}{% endif %}
 			{% if post.photo_id %}On photo <a href="{{ }}">{{ }}</a>:{% endif %}
 		{% endifchanged %}
-		From {% memberlink %}{{ post.posted_by_id }}{% endmemberlink %}, at {{ post.posted_at|date:"d M y, h:i" }} &mdash; <span class="readmore"><a href="{{ post.get_absolute_url }}">view in context</a></span>:
+		From {% memberlink %}{{ post.posted_by_id }}{% endmemberlink %}, at {{ post.posted_at|date:"d M y, h:i" }}{% if post.is_parent_visible %} &mdash; <span class="readmore"><a href="{{ post.get_absolute_url }}">view in context</a></span>{% endif %}:
 		<div class="postMessage">
 		{% if post.subject %}<div class="postSubject">{{ post.subject|bb2html }}</div>{% endif %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.