~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/worksheet/utils.py

  • Committer: William Grant
  • Date: 2010-02-24 12:18:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1698.
  • Revision ID: grantw@unimelb.edu.au-20100224121811-ubxxiulpli7mk5cq
Hide unpublished worksheets if edit_worksheets is not held.

Show diffs side-by-side

added added

removed removed

Lines of Context:
331
331
 
332
332
 
333
333
# XXX: This really shouldn't be needed.
334
 
def create_list_of_fake_worksheets_and_stats(store, user, offering):
 
334
def create_list_of_fake_worksheets_and_stats(config, store, user, offering):
335
335
    """Take an offering's real worksheets, converting them into stats.
336
336
 
337
337
    The worksheet listing views expect special fake worksheet objects
345
345
    problems_total = 0
346
346
 
347
347
    # Offering.worksheets is ordered by the worksheets seq_no
348
 
    for worksheet in offering.worksheets:
 
348
    worksheets = offering.worksheets
 
349
 
 
350
    # Unless we can edit worksheets, hide unpublished ones.
 
351
    if 'edit_worksheets' not in offering.get_permissions(user, config):
 
352
        worksheets = worksheets.find(published=True)
 
353
 
 
354
    for worksheet in worksheets:
349
355
        new_worksheet = FakeWorksheetForMarks(
350
356
            worksheet.identifier, worksheet.name, worksheet.assessable)
351
357
        if new_worksheet.assessable: