Commit 07e4a9bd authored by David Haynes's avatar David Haynes
Browse files

Comments in the go_extras functions

- heh, I didn't know these were actually defined somewhere
parent 0f8e773e
Pipeline #488 passed with stage
in 7 minutes
# Django Imports
from django import template from django import template
# App Imports
from go.models import RegisteredUser from go.models import RegisteredUser
register = template.Library()
# To be a valid tag library, the module must contain a module-level variable
# named register that is a template.Library instance, in which all the tags and
# filters are registered.
register = template.Library()
"""
check if a user is registered
"""
@register.filter @register.filter
def is_registered(user): def is_registered(user):
# try getting the RegisteredUser of the current user
try: try:
registered = RegisteredUser.objects.get(username=user.username) registered = RegisteredUser.objects.get(username=user.username)
# if it works then the user is registered
return True return True
except RegisteredUser.DoesNotExist: except RegisteredUser.DoesNotExist:
# if they don't exist then they are not registered
return False return False
"""
check if a user is approved
"""
@register.filter @register.filter
def is_approved(user): def is_approved(user):
# try getting the RegisteredUser of the current user
try: try:
registered = RegisteredUser.objects.get(username=user.username) registered = RegisteredUser.objects.get(username=user.username)
# if they exist, return whether or not they are approved (boolean)
return registered.approved return registered.approved
except RegisteredUser.DoesNotExist: except RegisteredUser.DoesNotExist:
# if they don't exist then they are not approved
return False return False
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