Skip to content

Commit

Permalink
Bug fixing in access_split and functional_split.
Browse files Browse the repository at this point in the history
The drawback of making independent projects: the same fix has to go into
multiple places. In this case (in both projects):

- Allow rating to be omitted in reviews (the model requires None, the
  form was normalising to "").
- I was confusing review.id and review.author_id when pulling out
  authors and it was only by accident that this wasn't causing problems
  earlier.
  • Loading branch information
malcolmt committed Sep 5, 2010
1 parent 4c0ba61 commit 221a632
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions access_split/reviews/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def __init__(self, *args, **kwargs):
cache.set(self._cache_key, prod_choices)
self.fields["product"].choices = prod_choices

def clean_rating(self):
value = self.cleaned_data["rating"]
if value == u"":
return None
return value


def add_review(request, product_id=None):
"""
Expand Down Expand Up @@ -114,8 +120,8 @@ def product_reviews(request, product_id=None):
product_list = products.models.Product.objects.order_by("name")
review_qs = review_mgr.order_by("-created")
review_dict = {}
review_ids = [obj.id for obj in review_qs]
users = dict(auth_models.User.objects.filter(id__in=review_ids). \
author_ids = [obj.author_id for obj in review_qs]
users = dict(auth_models.User.objects.filter(id__in=author_ids). \
values_list("id", "username"))
users[-1] = "Anonymous"
for review in review_qs:
Expand Down
10 changes: 8 additions & 2 deletions functional_split/reviews/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def __init__(self, *args, **kwargs):
cache.set(self._cache_key, prod_choices)
self.fields["product"].choices = prod_choices

def clean_rating(self):
value = self.cleaned_data["rating"]
if value == u"":
return None
return value


def add_review(request, product_id=None):
"""
Expand Down Expand Up @@ -96,8 +102,8 @@ def product_reviews(request, product_id=None):
product_list = products.models.Product.objects.order_by("name")
review_qs = reviews.models.Review.objects.order_by("-created")
review_dict = {}
review_ids = [obj.id for obj in review_qs]
users = dict(auth_models.User.objects.filter(id__in=review_ids). \
author_ids = [obj.author_id for obj in review_qs]
users = dict(auth_models.User.objects.filter(id__in=author_ids). \
values_list("id", "username"))
users[-1] = "Anonymous"
for review in review_qs:
Expand Down

0 comments on commit 221a632

Please sign in to comment.