<s> from __future__ import unicode_literals <EOL> from collections import OrderedDict <EOL> from django . contrib . auth import get_user_model <EOL> from mezzanine import template <EOL> from mezzanine . conf import settings <EOL> from mezzanine . accounts import ( get_profile_form , get_profile_user_fieldname , <EOL> get_profile_for_user , ProfileNotConfigured ) <EOL> from mezzanine . accounts . forms import LoginForm <EOL> register = template . Library ( ) <EOL> User = get_user_model ( ) <EOL> @ register . as_tag <EOL> def login_form ( * args ) : <EOL> """<STR_LIT>""" <EOL> return LoginForm ( ) <EOL> @ register . as_tag <EOL> def signup_form ( * args ) : <EOL> """<STR_LIT>""" <EOL> return get_profile_form ( ) ( ) <EOL> @ register . as_tag <EOL> def profile_form ( user ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( user , User ) : <EOL> return get_profile_form ( ) ( instance = user ) <EOL> return "<STR_LIT>" <EOL> @ register . filter <EOL> def profile_fields ( user ) : <EOL> """<STR_LIT>""" <EOL> fields = OrderedDict ( ) <EOL> try : <EOL> profile = get_profile_for_user ( user ) <EOL> user_fieldname = get_profile_user_fieldname ( ) <EOL> exclude = tuple ( settings . ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS ) <EOL> for field in profile . _meta . fields : <EOL> if field . name not in ( "<STR_LIT:id>" , user_fieldname ) + exclude : <EOL> value = getattr ( profile , field . name ) <EOL> fields [ field . verbose_name . title ( ) ] = value <EOL> except ProfileNotConfigured : <EOL> pass <EOL> return list ( fields . items ( ) ) <EOL> @ register . filter <EOL> def username_or ( user , attr ) : <EOL> """<STR_LIT>""" <EOL> if not settings . ACCOUNTS_NO_USERNAME : <EOL> attr = "<STR_LIT:username>" <EOL> value = getattr ( user , attr ) <EOL> if callable ( value ) : <EOL> value = value ( ) <EOL> return value </s>
