Commit 2500fc44 authored by Robert's avatar Robert

Add activity count display since bookmarked time

parent 8be2be55
Pipeline #1805 passed with stage
in 7 minutes and 35 seconds
# Generated by Django 2.2.2 on 2019-07-29 12:29
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('gestalten', '0012_auto_20190618_1438'),
]
operations = [
migrations.AddField(
model_name='gestalt',
name='activity_bookmark_time',
field=models.DateTimeField(default=django.utils.timezone.now),
),
]
import django.contrib.contenttypes.models
from allauth.account import adapter as allauth_adapter
from django import urls
from django.conf import settings
from django.contrib import auth
from django import urls
from django.db import models
from django.utils.timezone import now
from imagekit.models import ImageSpecField
from imagekit.processors import SmartResize, Transpose
......@@ -51,6 +52,7 @@ class Gestalt(grouprise.core.models.Model):
)
score = models.IntegerField(default=0)
user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
activity_bookmark_time = models.DateTimeField(default=now)
associations = django.contrib.contenttypes.fields.GenericRelation(
'associations.Association', content_type_field='entity_type',
......
......@@ -7,7 +7,12 @@
{% include 'gestalten/_avatar.html' with gestalt=user.gestalt link=False size=24 %}
</span>
{% include 'gestalten/_avatar.html' with gestalt=user.gestalt link=False size=48 %}
<span class="nav-menu-item-label">{{ user.gestalt }}</span>
<span class="nav-menu-item-label">
{{ user.gestalt }}
{% if num_activity %}
({{ num_activity }})
{% endif %}
</span>
<i class="caret"></i>
</label>
{% else %}
......@@ -42,7 +47,12 @@
<li>
<a href="{% url 'conversations' %}" class="nav-menu-item">
<i class="sg sg-fw sg-conversations"></i>
<span class="nav-menu-item-label">Gespräche</span>
<span class="nav-menu-item-label">
Gespräche
{% if num_activity %}
({{ num_activity }})
{% endif %}
</span>
</a>
</li>
<li>
......
from grouprise.features.associations.models import Association
from grouprise.features.content.models import Content
from grouprise.features.contributions.models import Contribution
from grouprise.features.gestalten.models import Gestalt
......@@ -5,8 +6,14 @@ from grouprise.features.groups.models import Group
def page_meta(request):
num_activity = None
if request.user.is_authenticated:
num_activity = Association.objects.ordered_user_conversations(request.user) \
.filter(last_activity__gte=request.user.gestalt.activity_bookmark_time) \
.count()
return {
'num_groups': Group.objects.count(),
'num_gestalten': Gestalt.objects.count(),
'num_contributions': Contribution.objects.count() + Content.objects.count(),
'num_activity': num_activity,
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment