Exemple #1
0
def dashboard(request):
    context = RequestContext(request)

    # Hack: Schedule an update checkin if it looks like it's been a while.
    # This works around sites that are not running celerybeat.
    checkin.schedule_checkin()

    email_backend = getattr(settings, 'EMAIL_BACKEND', None)
    email_configured = email_backend and email_backend != 'django.core.mail.backends.dummy.EmailBackend'
    email_configured = email_configured and bool(getattr(settings, 'EMAIL_FROM_ADDRESS', None))

    context['email_configured'] = email_configured

    if settings.BROKER_URL.startswith('redis:'):
        try:
            r = redis.StrictRedis.from_url(settings.BROKER_URL)
            r.ping()
        except redis.RedisError as e:
            context['redis_error'] = e.message if e.message else "Unknown error."

    checkin_info = checkin.get_last_checkin()
    context['last_checkin_time'] = checkin_info[0]
    context['checkin'] = checkin_info[1]

    active_users = models.User.objects.filter(is_active=True).exclude(username='******')
    context['num_users'] = len(active_users)

    recent_time = timezone.now() - datetime.timedelta(days=30)
    new_users = models.User.objects.filter(date_joined__gte=recent_time).exclude(username='******')
    context['num_new_users'] = len(new_users)

    return render_to_response('kegadmin/dashboard.html', context_instance=context)
Exemple #2
0
def dashboard(request):
    context = RequestContext(request)

    # Hack: Schedule an update checkin if it looks like it's been a while.
    # This works around sites that are not running celerybeat.
    checkin.schedule_checkin()

    email_backend = getattr(settings, 'EMAIL_BACKEND', None)
    email_configured = email_backend and email_backend != 'django.core.mail.backends.dummy.EmailBackend'
    email_configured = email_configured and bool(getattr(settings, 'EMAIL_FROM_ADDRESS', None))

    context['email_configured'] = email_configured

    if settings.BROKER_URL.startswith('redis:'):
        try:
            r = redis.StrictRedis.from_url(settings.BROKER_URL)
            r.ping()
        except redis.RedisError as e:
            context['redis_error'] = e.message if e.message else "Unknown error."

    checkin_info = checkin.get_last_checkin()
    context['last_checkin_time'] = checkin_info[0]
    context['checkin'] = checkin_info[1]

    active_users = models.User.objects.filter(is_active=True).exclude(username='******')
    context['num_users'] = len(active_users)

    recent_time = timezone.now() - datetime.timedelta(days=30)
    new_users = models.User.objects.filter(date_joined__gte=recent_time).exclude(username='******')
    context['num_new_users'] = len(new_users)

    return render_to_response('kegadmin/dashboard.html', context_instance=context)
Exemple #3
0
def dashboard(request):
    context = {}

    # Hack: Schedule an update checkin if it looks like it's been a while.
    # This works around sites that are not running celerybeat.
    checkin.schedule_checkin()

    email_backend = getattr(settings, "EMAIL_BACKEND", None)
    email_configured = (
        email_backend
        and email_backend != "django.core.mail.backends.dummy.EmailBackend")
    email_configured = email_configured and settings.DEFAULT_FROM_EMAIL

    context["email_configured"] = email_configured

    if settings.BROKER_URL.startswith("redis:"):
        try:
            r = redis.StrictRedis.from_url(settings.BROKER_URL)
            r.ping()
        except redis.RedisError as e:
            context[
                "redis_error"] = e.message if e.message else "Unknown error."

    last_checkin_time, last_checkin = checkin.get_last_checkin()
    context["last_checkin_time"] = last_checkin_time
    context["checkin"] = last_checkin

    if last_checkin:
        for news in last_checkin.get("news", []):
            try:
                news["date"] = isodate.parse_datetime(news["date"])
            except (KeyError, ValueError):
                pass

    active_users = models.User.objects.filter(is_active=True).exclude(
        username="******")
    context["num_users"] = len(active_users)

    recent_time = timezone.now() - datetime.timedelta(days=30)
    new_users = models.User.objects.filter(
        date_joined__gte=recent_time).exclude(username="******")
    context["num_new_users"] = len(new_users)

    return render(request, "kegadmin/dashboard.html", context=context)