Skip to content

Commit

Permalink
Update by ialbert on Thu May 23 11:37:16 EDT 2019 from yolo.local
Browse files Browse the repository at this point in the history
  • Loading branch information
ialbert committed May 23, 2019
1 parent 75d46b7 commit 4860e0a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 27 deletions.
1 change: 1 addition & 0 deletions biostar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Some of them are fully operational others in various stages of development
4. Forum (biostar Q&A platform)
5. FTPServer (FTP virtual filesystem to the engine)
6. Publisher (documentation hosting service)

24 changes: 21 additions & 3 deletions biostar/forum/static/forum.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ a:hover {
}


.post {
border-bottom: 1px solid #d3d3d3;
overflow: auto
}

.post.comment {
border-bottom: 0;
}

.post {
border-bottom: 1px solid #d3d3d3;
overflow: auto
Expand Down Expand Up @@ -134,7 +143,7 @@ a:hover {
}

.post .actions {
padding: 1rem 1em 1rem 0em;
padding: .5rem 0em 0.5rem 0em;
}

.post.Deleted {
Expand Down Expand Up @@ -168,11 +177,20 @@ a:hover {
margin: 0;
}

.comment-list {
//background: green;
}

.indent {
margin-left: 2em;
}

.comment {
padding-top: 0.5rem;
padding-top: 0.1rem;
background-color: #f5f5f5;
margin-bottom: 0.3em;
}
.comment > .votebox > .score {
.post.comment .score {
font-size: 100%;
padding-bottom: 0.5rem;
padding-top: 0.5rem;
Expand Down
9 changes: 2 additions & 7 deletions biostar/forum/templates/widgets/comment_body.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% load forum_tags %}

<div class="post {{ post.css }}">
<div class="post comment {{ post.css }}">

<div class="body comment">
<div class="body">

<div class="votebox">

Expand Down Expand Up @@ -31,8 +31,3 @@

</div>






1 change: 0 additions & 1 deletion biostar/forum/templates/widgets/post_body.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
{# Render all comments #}
{% render_comments tree=tree post=post %}


</div>


Expand Down
34 changes: 18 additions & 16 deletions biostar/forum/templatetags/forum_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
from datetime import timedelta

from django import template
from django.db.models import Q
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db.models import Q
from django.utils.safestring import mark_safe
from django.utils.timezone import utc

from biostar.forum import forms, models, const, util
from biostar.forum import const, util
from biostar.forum.models import Post, Vote, Award
from biostar.message.models import Message
from biostar.utils.shortcuts import reverse

User = get_user_model()

Expand Down Expand Up @@ -57,19 +56,23 @@ def now():
def post_user_line(post, avatar=False):
return dict(post=post, avatar=avatar)


@register.inclusion_tag('widgets/post_user_box.html')
def post_user_box(user, post):
return dict(user=user, post=post)


@register.inclusion_tag('widgets/post_actions.html')
def post_actions(post, label="ADD COMMENT"):
return dict(post=post, label=label)


@register.inclusion_tag('widgets/post_tags.html')
def post_tags(post, show_views=False):
tags = post.tag_val.split(",")
return dict(post=post, tags=tags, show_views=show_views)


@register.simple_tag
def get_all_message_count(request):
user = request.user
Expand Down Expand Up @@ -150,7 +153,6 @@ def get_award_context(award):

@register.filter
def get_user_location(user):

return user.profile.location or "location unknown"


Expand Down Expand Up @@ -180,7 +182,6 @@ def single_post_feed(post):

@register.inclusion_tag('widgets/listing.html', takes_context=True)
def list_posts(context, user):

posts = Post.objects.filter(author=user)
request = context["request"]
context = dict(posts=posts, request=request)
Expand Down Expand Up @@ -412,26 +413,27 @@ def traverse_comments(request, post, tree, template_name):

seen = set()

def traverse(node):
def traverse(node, collect=[]):

data = ['<div class="ui comment segments">']
cont = {"post": node, 'user': request.user, 'request': request}
html = body.render(cont)
data.append(html)

collect.append(f'<div class="indent"><div class="comment">{html}</div>')

for child in tree.get(node.id, []):
if child in seen:
raise Exception(f"circular tree {child.pk} {child.title}")
seen.add(child)
data.append(f'<div class="ui segment comment basic">')
data.append(traverse(child))
data.append("</div>")
traverse(child, collect=collect)

data.append("</div>")
return '\n'.join(data)
collect.append(f"</div>")

# this collects the comments for the post
coll = []
collect = ['<div class="comment-list">']
for node in tree[post.id]:
coll.append(traverse(node))
traverse(node, collect=collect)
collect.append("</div>")

html = '\n'.join(collect)

return '\n'.join(coll)
return html

0 comments on commit 4860e0a

Please sign in to comment.