Skip to content

Commit

Permalink
Merge pull request #802 from Natay/messagesfix
Browse files Browse the repository at this point in the history
fixes in messages
  • Loading branch information
ialbert committed Apr 9, 2021
2 parents 869c898 + f4b279c commit e73740d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion biostar/accounts/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def create_messages(template, user_ids, sender=None, extra_context={}):
context.update(extra_context)
body = tmpl.render(context)
html = mistune.markdown(body, escape=False)
body = MessageBody.objects.create(body=body, html=html)

for rec in rec_list:
body = MessageBody.objects.create(body=body, html=html)
Message.objects.create(sender=sender, recipient=rec, body=body)
16 changes: 6 additions & 10 deletions biostar/forum/management/commands/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime, timedelta
from django.db.models import Count
from django.core.management.base import BaseCommand
from biostar.accounts.models import Message, User
from biostar.accounts.models import Message, User, MessageBody
from biostar.forum.util import now
from biostar.forum.models import PostView, Post

Expand All @@ -19,10 +19,6 @@ def prune_data(weeks=10, days=1, delall=False):
past_days = now() - timedelta(days=days)
weeks_since = now() - timedelta(weeks=weeks)

#spam_posts = Post.objects.filter(spam=Post.SPAM)
#logger.info(f"Deleting {spam_posts.count()} spam posts")
#spam_posts.delete()

# Remove post views.
post_views = PostView.objects.filter(date__lt=past_days)
logger.info(f"Deleting {post_views.count()} post views")
Expand All @@ -37,11 +33,11 @@ def prune_data(weeks=10, days=1, delall=False):
logger.info(f"Deleting {messages.count()} messages")
messages.delete()

# Get rid of too many messages
#users = User.objects.annotate(total=Count("message__recipient")).filter(total__gt=MAX_MSG)[:100]
#for user in users:
# since = now() - timedelta(days=1)
# Message.objects.filter(user=user, sent_at__lt=since).delete()
# Get all messages bodies without a message
bodies = MessageBody.objects.filter(message=None)

logger.info(f"Deleting {bodies.count()} message bodies.")
bodies.delete()

return

Expand Down
5 changes: 5 additions & 0 deletions biostar/forum/static/forum.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ blockquote.twitter-tweet {
padding-bottom: 1ex;
}

tr.message > td{
overflow-x: auto;
max-width: 0;
}

#logo {
padding: 0px 5px 5px 5px;
/ / background-color: var(--logo-background);
Expand Down
4 changes: 2 additions & 2 deletions biostar/forum/templates/message_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<tbody>
{% for message in all_messages %}
<tr class="message">
<td class="{{ message.css }}">
<td class="{{ message.css }} ">
<div class="item">
<div class="content">
<i>
<i class="angle double right icon"></i>
{{ message.sent_date|timesince }} ago
<a href="{{ message.sender.profile.get_absolute_url }}">{{ message.sender.profile.name }}</a>
wrote:</i>
<p>{{ message.body.html|safe }}</p>
<p>{{ message.body.html|safe|truncatewords_html:180 }}</p>
</div>
</div>
</td>
Expand Down

0 comments on commit e73740d

Please sign in to comment.