django-fitlog / fitlog / templatetags /

from django.template import Library

from fitlog.models import FitLog
from django.contrib.auth.models import User

register = Library()

@register.inclusion_tag('fitlog/tags/list_logs.html', takes_context=True)
def list_recent_logs(context):
    fit_logs = FitLog.objects.latest()
    return {'fit_logs': fit_logs, "request": context.get('request')}

@register.inclusion_tag('fitlog/tags/list_logs.html', takes_context=True)
def list_user_logs(context, username):
        user = User.objects.get(username=username)
        fit_logs = FitLog.objects.by_member(user)
        return {'fit_logs': fit_logs, "request": context.get('request')}
    except User.DoesNotExist:
    return {"request": context.get('request')}

@register.inclusion_tag('fitlog/tags/stats.html', takes_context=True)
def stats(context):
    num_logs = FitLog.objects.number_of_logs()
    num_members = User.objects.filter(is_active=True).count()
    return {'num_logs': num_logs, 'num_members': num_members,
            "request": context.get('request')}

def weight_training_list(fitlog):
    return {'fitlog': fitlog}

def cardio_list(fitlog):
    return {'fitlog': fitlog}

def view_fitlog_detail(fitlog):
    return {'fitlog': fitlog}
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.