Skip to content

Commit

Permalink
Merge pull request #79 from EarthSchlange/make_all_player_ratings_dis…
Browse files Browse the repository at this point in the history
…tinct

Corrected Table for Players Ratings.
  • Loading branch information
Michael Hiiva authored Jun 3, 2020
2 parents fb5e06c + c2d8f25 commit 032fe8c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
10 changes: 10 additions & 0 deletions agagd/agagd_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ def winner(self):
def won_by(self, p1):
return self.winner() == p1

# Updated Rating Information Table for Players.
class Players(models.Model):
pin_player = models.ForeignKey(Member, db_column=u'Pin_Player', primary_key=True)
rating = models.FloatField(db_column=u'Rating') # x. This field type is a guess.
sigma = models.FloatField(db_column=u'Sigma') # x. This field type is a guess.
elab_date = models.DateField(db_column=u'Elab_Date')
class Meta:
managed = False
db_table = u'players'

class Rating(models.Model):
# ForeignKey for the Members
member_id = models.ForeignKey(Member, db_column=u'Pin_Player')
Expand Down
18 changes: 11 additions & 7 deletions agagd/agagd_core/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,18 @@ class AllPlayerRatingsTable(tables.Table):
}
)
type = tables.Column()
rating__rating = tables.Column()
players__rating = tables.Column()
renewal_due = tables.Column()
chapter_id = tables.Column(
verbose_name="Chapter"
)
state = tables.Column()
rating__sigma = tables.Column()
rating__elab_date = tables.Column(verbose_name="Renewal Due")
players__sigma = tables.Column(
verbose_name="Sigma"
)
players__elab_date = tables.Column(
verbose_name="Renewal Due"
)

def render_chapter_id(self, value):
try:
Expand All @@ -195,7 +199,7 @@ def render_chapter_id(self, value):
chapter_url = reverse(
viewname='chapter_detail',
kwargs={'chapter_code': members_chapter.code})
chapter_html = mark_safe("<a href='{}'>{}</a>".format(chapter_url, members_chapter.code))
chapter_html = mark_safe("<a href='{}'>{}</a>".format(chapter_url, members_chapter.name))
else:
chapter_html = u"\u2014"
except ObjectDoesNotExist:
Expand All @@ -207,9 +211,9 @@ class Meta:
fields = (
'full_name',
'member_id',
'rating__rating',
'rating__sigma',
'rating__elab_date',
'players__rating',
'players__sigma',
'players__elab_date',
'type',
'renewal_due',
'chapter_id',
Expand Down
10 changes: 5 additions & 5 deletions agagd/agagd_core/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def all_player_ratings(request):
Q(chapter_id=F('chapters__member_id')) |
Q(chapters__member_id__isnull=True)
).filter(
Q(member_id=F('rating__pin_player'))
Q(member_id=F('players__pin_player'))
).filter(
status='accepted'
).exclude(
Expand All @@ -222,13 +222,13 @@ def all_player_ratings(request):
"full_name",
"member_id",
"type",
"rating__rating",
"players__rating",
"renewal_due",
"chapter_id",
"state",
"rating__sigma",
"rating__elab_date"
).order_by('-rating__rating')
"players__sigma",
"players__elab_date"
).order_by('-players__rating')

all_player_ratings_table = AllPlayerRatingsTable(all_player_ratings_query)
RequestConfig(request, paginate={'per_page': 50}).configure(all_player_ratings_table)
Expand Down

0 comments on commit 032fe8c

Please sign in to comment.