Пример #1
0
def update_scholarship(name):
    '''For GET requests, this method allows the administrator to edit the named
    document. For POST requests, this method saves the edits made by the
    administrator and then reloads/redisplays the document administration page.
    Non-authenticated users are redirected to the login page. documents that
    don't exist can't be edited. Because we don't show individual documents,
    all redirects go to the documents administration page.
    '''
    form = Scholarships()
    if form.is_submitted():
        if form.validate() and request.form.get('submit'):
            Scholarships.update_unit(form)
            return redirect(url_for('web.display_scholarship',
                            name=form.getName()))
    else:
        scholarship = Scholarships.read_unit(name)
        if scholarship:
            form.initialize(name=name, action='update',
                            scholarship=scholarship)
            return display_content(
                form=form,
                title='Edit: ' + name,
                breadcrumbs=get_breadcrumbs('scholarships', name, 'edit')
            )
    return redirect(url_for('web.display_admin_scholarships'))
Пример #2
0
def display_scholarships():
    '''This routine displays the administration tools for user documents. It is
    password protected because the listing page allows administrative features.
    Documents should be accessed as linked from existing pages.
    '''
    scholarships = Scholarships.read_units()
    return display_content(
        breadcrumbs=get_breadcrumbs('scholarships'),
        title='Scholarships & Awards',
        primaryList=create_scholarships_list(scholarships),
        primaryListHr=False,
        editable=True,
        editableUrl=url_for('web.display_admin_scholarships')
    )
Пример #3
0
def create_scholarship():
    '''This routine displays an editing page for creating an scholarship.'''
    form = Scholarships()
    if form.is_submitted():
        if form.validate() and request.form.get('submit'):
            Scholarships.create_unit(form)
            return redirect(url_for('web.display_scholarships',
                            name=form.getName()))
        else:
            return redirect(url_for('web.display_admin_scholarships'))
    else:
        form.initialize(action='create')
        return display_content(
            form=form,
            title='Create Scholarship',
            breadcrumbs=get_breadcrumbs('scholarship', 'create')
        )
Пример #4
0
def display_admin_scholarships():
    '''This routine displays the administration tools for user documents. It is
    password protected because the listing page allows administrative features.
    Documents should be accessed as linked from existing pages.
    '''
    scholarships = Scholarships.read_units()
    return display_content(
        breadcrumbs=get_breadcrumbs('admin', 'scholarships'),
        title='Administration: Scholarships',
        primary=create_hyperlink(url_for('web.create_scholarship'),
                                 '''Create a new scholarship
                                    (in the CS database only)'''),
        primaryList=create_admin_scholarships_list(scholarships),
        primaryListHr=True,
        editable=True
    )
Пример #5
0
 def read_units(cls):
     '''This method retrieves program data from CIT for all department
     programs and combines it in one list. It calls read_unit(), which
     actually reads more information than is required for the current
     list of academic programs (e.g., course lists and scholarships), but
     this allows us to add information to the list if we choose to do so
     later. The secondary education program is not currently stored at CIT.
     '''
     result = []
     # Read a master scholarships list to be used multiple times.
     scholarships = Scholarships.read_units()
     for programName in ['bcs', 'cs', 'is', 'ds', 'dc']:
         program = cls.read_unit(programName, scholarships=scholarships)
         if program is not None:
             result.append(program)
     return result
Пример #6
0
def display_scholarship(name):
    '''This routine displays a given scholarship.'''
    scholarship = check_unit(Scholarships.read_unit(name))
    # Add scholarship details in side bar if they exist.
    sideContent = create_scholarship_side(scholarship)
    sideTitle = None
    if sideContent:
        sideTitle = 'Details'
    return display_content(
        breadcrumbs=get_breadcrumbs('scholarships', name),
        title=scholarship.get('title'),
        primary=create_scholarship_content(scholarship),
        sideTitle=sideTitle,
        sideContent=sideContent,
        primaryListHr=False,
        editable=True,
        editableUrl=url_for('web.update_scholarship', name=name)
    )
Пример #7
0
 def read_unit(cls, name, scholarships=None):
     '''This method retrieves merges program data from the CIT
     and CS databases.
     '''
     result = Unit.merge_records(
         cls.get_cit_data(name),
         g.mongo.db.programs.find_one({'name': name})
     )
     if result:
         # Modify the course hyperlinks to link to our own pages.
         if 'majorCourses' in result:
             result['majorCourses'] = \
                 cls.fix_courses(result['majorCourses'])
         if 'minorCourses' in result:
             result['minorCourses'] = \
                 cls.fix_courses(result['minorCourses'])
         # Add scholarships regardless of where the program comes from.
         # Use the scholarships parameter if given, otherwise read them.
         if scholarships is None:
             scholarships = Scholarships.read_units()
         result['scholarships'] = \
             cls.get_scholarships(name, scholarships)
     return result
Пример #8
0
def delete_scholarship(name):
    '''This routine deletes the given document entry, but it leaves the
    actual document in place.
    '''
    Scholarships.delete_unit(name)
    return redirect(url_for('web.display_admin_scholarships'))