Permalink
Browse files

updated rankings to use season

  • Loading branch information...
1 parent d9ac628 commit 2afb698732ebf9042f79f47ec3b6cf0182616093 @dwillis committed Aug 11, 2010
Showing with 15 additions and 15 deletions.
  1. +7 −7 rankings/admin.py
  2. +3 −3 rankings/models.py
  3. +5 −5 rankings/views.py
View
@@ -5,17 +5,17 @@ class RankingTypeAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('name',)}
class RankingAdmin(admin.ModelAdmin):
- list_filter = ('year',)
+ list_filter = ('season',)
class RushingSummaryAdmin(admin.ModelAdmin):
- list_display = ('player', 'year', 'rank', 'carries', 'net', 'yards_per_game')
- list_filter = ('year', 'rank')
- ordering = ('-year', 'rank')
+ list_display = ('player', 'season', 'rank', 'carries', 'net', 'yards_per_game')
+ list_filter = ('season', 'rank')
+ ordering = ('-season', 'rank')
class PassEfficiencyAdmin(admin.ModelAdmin):
- list_display = ('player', 'year', 'rank', 'rating')
- list_filter = ('year', 'rank', 'week')
- ordering = ('-year', 'rank')
+ list_display = ('player', 'season', 'rank', 'rating')
+ list_filter = ('season', 'rank', 'week')
+ ordering = ('-season', 'rank')
admin.site.register(RankingType, RankingTypeAdmin)
admin.site.register(Ranking, RankingAdmin)
View
@@ -34,7 +34,7 @@ def year_list(self):
class Ranking(models.Model):
ranking_type = models.ForeignKey(RankingType)
collegeyear = models.ForeignKey(CollegeYear)
- year = models.IntegerField()
+ season = models.IntegerField()
week = models.ForeignKey(Week)
rank = models.PositiveIntegerField()
is_tied = models.BooleanField()
@@ -51,7 +51,7 @@ def get_week_url(self):
class RushingSummary(models.Model):
player = models.ForeignKey(Player)
- year = models.IntegerField()
+ season = models.IntegerField()
week = models.ForeignKey(Week)
rank = models.PositiveIntegerField()
is_tied = models.BooleanField()
@@ -66,7 +66,7 @@ def __unicode__(self):
class PassEfficiency(models.Model):
player = models.ForeignKey(Player)
- year = models.IntegerField()
+ season = models.IntegerField()
week = models.ForeignKey(Week)
rank = models.PositiveIntegerField()
attempts = models.PositiveIntegerField()
View
@@ -26,13 +26,13 @@ def rankings_season(request, rankingtype, season, div='B', week=None):
rt = get_object_or_404(RankingType, slug=rankingtype)
date = datetime.date.today()-datetime.timedelta(days=7)
if week:
- latest_week = Week.objects.get(year=season, week_num=week)
+ latest_week = Week.objects.get(season=season, week_num=week)
else:
try:
- latest_week = Week.objects.filter(year=season, end_date__gte=date, end_date__lte=datetime.date.today()).order_by('end_date')[0]
+ latest_week = Week.objects.filter(season=season, end_date__gte=date, end_date__lte=datetime.date.today()).order_by('end_date')[0]
except:
- latest_week = Week.objects.filter(year=season).order_by('-end_date')[0]
- other_weeks = Week.objects.filter(year=season).exclude(week_num=latest_week.week_num).exclude(end_date__gte=datetime.date.today()).order_by('end_date')
- rankings_list = Ranking.objects.filter(year=season, ranking_type=rt, week=latest_week, division=div).select_related().order_by('rank')
+ latest_week = Week.objects.filter(season=season).order_by('-end_date')[0]
+ other_weeks = Week.objects.filter(season=season).exclude(week_num=latest_week.week_num).exclude(end_date__gte=datetime.date.today()).order_by('end_date')
+ rankings_list = Ranking.objects.filter(season=season, ranking_type=rt, week=latest_week, division=div).select_related().order_by('rank')
return render_to_response('rankings/rankings_season.html', {'ranking_type': rt, 'rankings_list': rankings_list, 'season':season, 'latest_week':latest_week, 'other_weeks':other_weeks})

0 comments on commit 2afb698

Please sign in to comment.