# # Our views for the Distro model. Features methods for showing the distro # list, as well as information about individual schools. # from guildbuilder.apps.builds.models import * from guildbuilder.apps.player.models import * from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext def index(request): """ The index page for the build app. """ pagevars = { "page_title": "Build Index", } context_instance = RequestContext(request) return render_to_response('builds/index.html', pagevars, context_instance) def team_index(request): """ Index for the Team builds. """ teamcat_list = TeamCategory.objects.filter(parent__isnull=True).order_by('-name') pagevars = { "page_title": "Team Build Index", } context_instance = RequestContext(request) return render_to_response('builds/1man_index.html', pagevars, context_instance) def oneman_index(request): """ Index for the one-man builds (Individuals). """ individualcat_list = IndividualCategory.objects.filter(parent__isnull=True).order_by('-name') cat_count = IndividualCategory.objects.count() build_count = Individual.objects.count() # Update build totals for each category shown. for cat in individualcat_list: cat.update_numbuilds() pagevars = { "page_title": "One-Man Build Index", "cat_list": individualcat_list, "cat_count": cat_count, "build_count": build_count, } context_instance = RequestContext(request) return render_to_response('builds/1man_index.html', pagevars, context_instance) def showcat(request, cat_id, is_teamcat): """ Show a category and the builds and sub-categories contained within. """ if not is_teamcat: disped_cat = get_object_or_404(IndividualCategory, pk=cat_id) builds = Individual.objects.filter(category=cat_id).order_by('-name') cat_subcats = IndividualCategory.objects.filter(parent=cat_id).order_by('-name') else: disped_cat = get_object_or_404(TeamCategory, pk=cat_id) builds = Team.objects.filter(category=cat_id).order_by('-name') cat_subcats = TeamCategory.objects.filter(parent=cat_id).order_by('-name') # Update build totals for each category shown. for cat in cat_subcats: cat.update_numbuilds() disped_cat.update_numbuilds() pagevars = { "page_title": "One-Man Build Category", "cat": disped_cat, "cat_id": cat_id, "builds": builds, "subcats": cat_subcats, "is_teamcat": is_teamcat, } context_instance = RequestContext(request) return render_to_response('builds/1man_showcat.html', pagevars, context_instance) def oneman_showbuild(request, build_id): """ Show an individual one-man build. """ build = Individual.objects.get(id=build_id) build_skills = build.skills.all() pagevars = { "page_title": "One-Man Build", "build": build, "build_skills": build_skills, } context_instance = RequestContext(request) return render_to_response('builds/1man_showbuild.html', pagevars, context_instance)