Skip to content

Commit

Permalink
Merge pull request #307 from ccnmtl/term-counts
Browse files Browse the repository at this point in the history
Term count aggregation fix PMT#102471
  • Loading branch information
coati-00 committed Aug 24, 2015
2 parents e2bb6cb + f1cc91c commit e751aae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion mediathread/assetmgr/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ def get_context(self, request, assets, notes):
def add_metadata(self, request, assets):
# metadata for all notes associated with these assets
# is displayed in the filtered list.
# Not sure this is exactly right...will discuss with team
notes = SherdNote.objects.get_related_notes(
assets, self.record_owner or None, self.visible_authors,
self.all_items_are_visible)
Expand Down
6 changes: 2 additions & 4 deletions mediathread/taxonomy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,15 @@ def render_related(self, request, object_list):
return values

def render_for_course(self, request, object_list):
term_counts = TermRelationship.objects.none()
related = TermRelationship.objects.none()
if len(object_list) > 0:
related = TermRelationship.objects.get_for_object_list(object_list)
term_counts = related.values('term').annotate(count=Count('id'))

data = []
for vocabulary in Vocabulary.objects.get_for_object(request.course):
ctx = self.render_one(request, vocabulary)
for term in ctx['term_set']:
qs = term_counts.filter(term=term['id'])
term['count'] = qs[0]['count'] if len(qs) > 0 else 0
term['count'] = related.filter(term__id=term['id']).count()
data.append(ctx)

data.sort(lambda a, b: cmp(a['display_name'].lower(),
Expand Down
8 changes: 7 additions & 1 deletion terrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,13 @@ def there_is_a_state_name_panel(step, state, name):
name -- composition, assignment, discussion, collection
"""
selector = "td.panel-container.%s.%s" % (state.lower(), name.lower())
panel = world.browser.find_element_by_css_selector(selector)

try:
panel = world.browser.find_element_by_css_selector(selector)
except NoSuchElementException:
time.sleep(1)
panel = world.browser.find_element_by_css_selector(selector)

assert panel is not None, "Can't find panel named %s" % panel


Expand Down

0 comments on commit e751aae

Please sign in to comment.