Changeset 627
- Timestamp:
- 09/22/10 10:39:26 (3 years ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
buildout.cfg (modified) (1 diff)
-
opentrials/assistance/views.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/buildout.cfg
r618 r627 33 33 django-rosetta 34 34 django-registration 35 django-reversion 35 36 36 37 [django] -
trunk/opentrials/assistance/views.py
r626 r627 9 9 10 10 def faq(request): 11 questions = Question.objects.all().order_by('category', 'order') 11 """ 12 ATTENTION: This view has a complexity of O(question * N * 2) on database load, because each 13 question does 1 or 2 calls to database to get question and category translations. 14 15 It is prepared to get questions including category fields at once SQL call and using cache 16 to get translations as far as possible. 17 18 If the questions quantity grow a lot, this logic should be replaced to something that gets 19 all translations from database at once. 20 """ 21 questions = Question.objects.select_related('category').order_by('category', 'order') 12 22 13 23 if len(questions) < 1: … … 19 29 c = Category() 20 30 try: 21 trans = question.translations.get(language__iexact=request.LANGUAGE_CODE) 31 #trans = question.translations.get(language__iexact=request.LANGUAGE_CODE) 32 trans = QuestionTranslation.objects.get_translation_for_object(request.LANGUAGE_CODE, question) 22 33 q.title = trans.title 23 34 q.answer = trans.answer … … 27 38 q = question 28 39 try: 29 trans = question.category.translations.get(language__iexact=request.LANGUAGE_CODE) 40 #trans = question.category.translations.get(language__iexact=request.LANGUAGE_CODE) 41 trans = CategoryTranslation.objects.get_translation_for_object(request.LANGUAGE_CODE, question.category) 30 42 c.label = trans.label 31 43 except CategoryTranslation.DoesNotExist:
