Example #1
0
def index(request):
    if not request.features['local']:
        return HttpResponseRedirect(reverse('sw_placeholder', kwargs=dict(slug='local')))
    template_name = 'local/index.html'
    regional_teams = teams_for_zip_code(request.user.get_profile().zip_code)
    for team in regional_teams:
        team.coordinators = team.members.filter(member__is_coordinator=True)
    #
    template_context = {
        'regional_teams': sorted(regional_teams, key=attrgetter('name')),
    }
    return render_to_response(template_name, template_context, RequestContext(request))
Example #2
0
def auto_join_user_to_teams(sender, instance, created, **kwargs):
    user = instance.user
    regional_teams = teams_for_zip_code(instance.zip_code)
    for team in regional_teams:
        if not team.user_is_member(user):
            Member(user=user, team=team).save()