nus-mtp/cs-modify

View on GitHub
templates/moduleModified.html

Summary

Maintainability
Test Coverage
$def with (modify_type, modifiedModulesSummary, modifiedModulesMounting, modifiedModulesQuota, modifiedModulesDetails, targetModuleCode, targetModuleModifiedInfo)

$var title:View Modified Modules

$ home = ['/', 'Home']
$ modifiedModulePage = ['#', 'Modified Modules']
$ modifiedModuleLink = ['/modifiedModules', 'Modified Modules']
$if modify_type is not None:
    $if modify_type.lower() == "mounting":
        $ modifyType = ['#', 'Modified Mounting of ' + targetModuleCode]
        $var hierarchy = [home, modifiedModuleLink, modifyType]
    $elif modify_type.lower() == "quota":
        $ modifyType = ['#', 'Modified Quota of ' + targetModuleCode]
        $var hierarchy = [home, modifiedModuleLink, modifyType]
    $elif modify_type.lower() == "moduledetails":
        $ modifyType = ['#', 'Modified Module Details of ' + targetModuleCode]
        $var hierarchy = [home, modifiedModuleLink, modifyType]
$else:
    $var hierarchy = [home, modifiedModulePage]

<script type="text/javascript" src="static/javascripts/fixedAndTentaMounting.js"></script>

<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <h1 class="text-center"><b>Modified Modules</b></h1>
            <p class="text-center">Shows all modules that have been modified</p>
            <br>
            $if targetModuleCode is not None:
                $if modify_type.lower() == "mounting":
                    <h2>Modified Mounting of <b>$targetModuleCode</b></h2>
                    <p><b>*Change in module mounting is always illustrated with respect to the module mounting in the current AY.</b></p>
                    <br>
                    <table class="table display dataTable table-bordered table-hover text-center" id="specific-modified-module">
                        <thead>
                            <tr>
                                <th>Code</th>
                                <th>Name</th>
                                <th>Change in Mounting</th>
                                <th data-sortable="false">Restore</th>
                            </tr>
                        </thead>
                        <tbody>
                    $if len(targetModuleModifiedInfo) == 0:
                        $pass
                    $else:
                        $for module in targetModuleModifiedInfo:
                            $ moduleCode = module[0]
                            $ moduleName = module[1]
                            $ currentAySem = module[2]
                            $ targetAySem = module[3]
                            $ mountingChange = module[4]
                            <tr>
                                <td><a href="/viewModule?code=$moduleCode" target="_blank" data-toggle="tooltip" title="View general info for $moduleCode">$moduleCode</a></td>
                                <td>$moduleName</td>
                            $if mountingChange == 1:
                                <td>
                                    Unmounted 
                                    <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $currentAySem"></span>
                                    &#8594; 
                                    Mounted 
                                    <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $targetAySem"></span>
                                </td>
                            $elif mountingChange == 0:
                                <td>
                                    Mounted 
                                    <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $currentAySem"></span>
                                    &#8594; 
                                    Unmounted
                                    <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $targetAySem"></span>
                                </td>
                            $if True:
                                <td>
                                    <form action="/restoreModule" method="post" onsubmit="if(!confirm('Are you sure you want to restore this module\'s mounting status?')){event.preventDefault();}">
                                        <input type="hidden" name="code" value="$moduleCode">
                                        <input type="hidden" name="currentAySem" value="$currentAySem">
                                        <input type="hidden" name="aysem" value="$targetAySem">
                                        <input type="hidden" name="mountingChange" value="$mountingChange">
                                        <input type="hidden" name="restoreType" value="mounting">
                                        <button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="bottom" title="Restore Mounting"><span class="glyphicon glyphicon-refresh"></span></button>
                                    </form>
                                </td>
                            </tr>
                    </tbody>
                    </table>
                $elif modify_type.lower() == "quota":
                    <h2>Modified Quota of <b>$targetModuleCode</b></h2>
                    <p><b>*Change in module quota is always illustrated with respect to the module quota in the current AY.</b></p>
                    <br>
                    <table class="table display dataTable table-bordered table-hover text-center" id="specific-modified-module">
                        <thead>
                            <tr>
                                <th>Code</th>
                                <th>Name</th>
                                <th onclick="replaceNilQuotasWithNumbers('#specific-modified-module');">Old Quota</th>
                                <th onclick="replaceNilQuotasWithNumbers('#specific-modified-module');">New Quota</th>
                                <th>Change in Quota</th>
                                <th data-sortable="false">Restore</th>
                            </tr>
                        </thead>
                        <tbody>
                    $if len(targetModuleModifiedInfo) == 0:
                       $pass
                    $else:
                        $for module in targetModuleModifiedInfo:
                            $ moduleCode = module[0]
                            $ moduleName = module[1]
                            $ currentAySem = module[2]
                            $ targetAySem = module[3]
                            $ currentQuota = module[4]
                            $ targetQuota = module[5]
                            $ quotaChange = module[6]
                            <tr>
                                <td><a href="/viewModule?code=$moduleCode" target="_blank" data-toggle="tooltip" title="View general info for $moduleCode">$moduleCode</a></td>
                                <td>$moduleName</td>
                            $if currentQuota is None:
                                <td>
                                    ? <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $currentAySem"></span>
                                </td>
                            $else:
                                <td>
                                    $currentQuota <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $currentAySem"></span>
                                </td>
                            $if targetQuota is None:
                                <td>
                                    ? <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $targetAySem"></span>
                                </td>
                            $else:
                                <td>
                                    $targetQuota <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $targetAySem"></span>
                                </td>
                            <td>$quotaChange</td>
                            <td>
                            $if currentQuota == "Unmounted" or targetQuota == "Unmounted":
                                <form action="/modifiedModules" method="get" onsubmit="alert('To restore this module\'s quota, the module\'s mounting has to be restored.');">
                                    <input type="hidden" name="modifyType" value="mounting">
                                    <input type="hidden" name="code" value="$moduleCode">
                                    <button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="bottom" title="Restore Quota"><span class="glyphicon glyphicon-refresh"></span></button>
                                </form>                    
                            $else:
                                <form action="/restoreModule" method="post" onsubmit="if(!confirm('Are you sure you want to restore this module\'s quota?')){event.preventDefault();}">
                                    <input type="hidden" name="code" value="$moduleCode">
                                    <input type="hidden" name="aysem" value="$targetAySem">
                                    <input type="hidden" name="quota" value="$currentQuota">
                                    <input type="hidden" name="restoreType" value="quota">
                                    <button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="bottom" title="Restore Quota"><span class="glyphicon glyphicon-refresh"></span></button>
                                </form>
                            </td>
                            </tr>
                    </tbody>
                    </table>
                $elif modify_type.lower() == "moduledetails":
                    <h2>Modified Module Details of <b>$targetModuleCode</b></h2>
                    <br>
                    $if targetModuleModifiedInfo is None:
                        <div class="jumbotron text-center">
                            <h1><span class="glyphicon glyphicon-remove-circle"></span></h1>
                            <br>
                            <p>There are no changes to module details for this module.</p>
                        </div>
                    $else:
                        $ module = targetModuleModifiedInfo
                        
                        $ moduleCode = module[0][0]
                        $ moduleName = module[0][4]
                        $ isNameModified = module[1][0]
                        $ isDescModified = module[1][1]
                        $ isMcModified = module[1][2]

                        $ originalName = module[0][1]
                        $ modifiedName = module[0][4]
                        $ originalDescription = module[0][2]
                        $ modifiedDescription = module[0][5]
                        $ originalMc = module[0][3]
                        $ modifiedMc = module[0][6]
                        
                        <div class="row">
                            <div class="col-md-6">
                                <h3 class="text-center">Old Details</h3>
                                <br>
                                <div class="panel panel-primary">
                                    <div class="panel-heading"><b>Name</b></div>
                                    <div class="panel-body">
                                        $if isNameModified:
                                            <b>$originalName</b>
                                        $else:
                                            $originalName
                                    </div>
                                </div>
                                <div class="panel panel-primary">
                                    <div class="panel-heading"><b>Description</b></div>
                                    <div class="panel-body">
                                        $if isDescModified:
                                            <b>$originalDescription</b>
                                        $else:
                                            $originalDescription
                                    </div>
                                </div>
                                <div class="panel panel-primary">
                                    <div class="panel-heading"><b>MCs</b></div>
                                    <div class="panel-body">
                                        $if isMcModified:
                                            <b>$originalMc</b>
                                        $else:
                                            $originalMc
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <h3 class="text-center">New Details</h3>
                                <br>
                                $if isNameModified:
                                    <div class="panel panel-danger">
                                        <div class="panel-heading"><b>Name</b></div>
                                        <div class="panel-body">
                                            <b>$modifiedName</b>
                                        </div>
                                $else:
                                    <div class="panel panel-primary">
                                        <div class="panel-heading"><b>Name</b></div>
                                            <div class="panel-body">
                                                <i>(unchanged)</i>
                                            </div>
                                </div>
                                $if isDescModified:
                                    <div class="panel panel-danger">
                                        <div class="panel-heading"><b>Description</b></div>
                                        <div class="panel-body">
                                            <b>$modifiedDescription</b>
                                        </div>
                                $else:
                                    <div class="panel panel-primary">
                                        <div class="panel-heading"><b>Description</b></div>
                                        <div class="panel-body">
                                            <i>(unchanged)</i>
                                        </div>
                                </div>
                                $if isMcModified:
                                    <div class="panel panel-danger">
                                        <div class="panel-heading"><b>MCs</b></div>
                                        <div class="panel-body">
                                            <b>$modifiedMc</b>
                                        </div>
                                $else:
                                    <div class="panel panel-primary">
                                        <div class="panel-heading"><b>MCs</b></div>
                                        <div class="panel-body">
                                            <i>(unchanged)</i>
                                        </div>
                                </div>
                            </div>
                            <div class="col-md-12 text-center">
                                <form action="/restoreModule" method="post" onsubmit="if(!confirm('Are you sure you want to restore this module\'s details?')){event.preventDefault();}">
                                    <input type="hidden" name="code" value="$moduleCode">
                                    <input type="hidden" name="restoreType" value="moduleDetails">
                                    <input class="btn btn-lg btn-primary" type="submit" value="Restore Details">
                                </form>
                            </div>
                        </div>
            $else:
                <ul class="nav nav-tabs nav-justified">
                    <li class="active"><a data-toggle="tab" href="#all">Module Modification Summary</a></li>
                    <li><a data-toggle="tab" href="#mounting">Modules with Modified Mounting</a></li>
                    <li><a data-toggle="tab" href="#quota">Modules with Modified Quota</a></li>
                    <li><a data-toggle="tab" href="#moduleDetails">Modules with Modified Details</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="all">
                        <h2>Module Modification Summary</h2>
                        <p>Shows an overview of what changes were applied to a modified module.</p>
                        <br>
                        <table class="table display dataTable table-bordered table-hover text-center" id="modified-modules-summary-table">
                            <thead>
                                <tr>
                                    <th>Code</th>
                                    <th>Name</th>
                                    <th>Is Mounting Modified?</th>
                                    <th>Is Quota Modified?</th>
                                    <th>Is Module Details Modified?</th>
                                </tr>
                            </thead>
                            <tbody>
                                $for module in modifiedModulesSummary:
                                    $ moduleCode = module[0]
                                    $ moduleName = module[1]
                                    $ isMountingModified = module[2]
                                    $ isQuotaModified = module[3]
                                    $ isDetailsModified = module[4]
                                    <tr>
                                        <td><a href="/viewModule?code=$moduleCode" target="_blank" data-toggle="tooltip" title="View general info for $moduleCode">$moduleCode</a></td>
                                        <td>$moduleName</td>
                                        <td>
                                        $if isMountingModified is True:
                                            <a href="/modifiedModules?modifyType=mounting&amp;code=$moduleCode" target="_blank">Yes</a>
                                        $else:
                                            -
                                        </td>
                                        <td>
                                        $if isQuotaModified is True:
                                            <a href="/modifiedModules?modifyType=quota&amp;code=$moduleCode" target="_blank">Yes</a>
                                        $else:
                                            -
                                        </td>
                                        <td>
                                        $if isDetailsModified is True:
                                            <a href="/modifiedModules?modifyType=moduleDetails&amp;code=$moduleCode" target="_blank">Yes</a>
                                        $else:
                                            -
                                            </td>
                                    </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="tab-pane" id="mounting">
                        <h2>Modules with Modified Mounting</h2>
                        <p><b>*Change in module mounting is always illustrated with respect to the module mounting in the current AY.</b></p>
                        <br>
                        <table class="table display dataTable table-bordered table-hover text-center" id="modified-modules-mounting-table">
                            <thead>
                                <tr>
                                    <th>Code</th>
                                    <th>Name</th>
                                    <th>Change in Mounting</th>
                                    <th data-sortable="false">Restore</th>
                                </tr>
                            </thead>
                            <tbody>
                                $if modifiedModulesMounting is None or len(modifiedModulesMounting) == 0:
                                    $pass
                                $else:
                                    $for module in modifiedModulesMounting:
                                        $ moduleCode = module[0]
                                        $ moduleName = module[1]
                                        $ currentAySem = module[2]
                                        $ targetAySem = module[3]
                                        $ mountingChange = module[4]
                                        <tr>
                                            <td><a href="/viewModule?code=$moduleCode" target="_blank" data-toggle="tooltip" title="View general info for $moduleCode">$moduleCode</a></td>
                                            <td>$moduleName</td>
                                        $if mountingChange == 1:
                                            <td>
                                                Unmounted 
                                                <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $currentAySem"></span>
                                                &#8594; 
                                                Mounted 
                                                <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $targetAySem"></span>
                                            </td>
                                        $elif mountingChange == 0:
                                            <td>
                                                Mounted 
                                                <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $currentAySem"></span>
                                                &#8594; 
                                                Unmounted
                                                <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $targetAySem"></span>
                                            </td>
                                        $if True:
                                            <td>
                                                <form action="/restoreModule" method="post" onsubmit="if(!confirm('Are you sure you want to restore this module\'s mounting status?')){event.preventDefault();}">
                                                    <input type="hidden" name="code" value="$moduleCode">
                                                    <input type="hidden" name="currentAySem" value="$currentAySem">
                                                    <input type="hidden" name="aysem" value="$targetAySem">
                                                    <input type="hidden" name="mountingChange" value="$mountingChange">
                                                    <input type="hidden" name="restoreType" value="mounting">
                                                    <button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="bottom" title="Restore Mounting"><span class="glyphicon glyphicon-refresh"></span></button>
                                                </form>
                                            </td>
                                        </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="tab-pane" id="quota">
                        <h2>Modules with Modified Quota</h2>
                        <p><b>*Change in module quota is always illustrated with respect to the module quota in the current AY.</b></p>
                        <br>
                        <table class="table display dataTable table-bordered table-hover text-center" id="modified-modules-quota-table">
                            <thead>
                                <tr>
                                    <th>Code</th>
                                    <th>Name</th>
                                    <th onclick="replaceNilQuotasWithNumbers('#modified-modules-quota-table');">Old Quota</th>
                                    <th onclick="replaceNilQuotasWithNumbers('#modified-modules-quota-table');">New Quota</th>
                                    <th>Change in Quota</th>
                                    <th data-sortable="false">Restore</th>
                                </tr>
                            </thead>
                            <tbody>
                                $if modifiedModulesQuota is None or len(modifiedModulesQuota) == 0:
                                    $pass
                                $else:
                                    $for module in modifiedModulesQuota:
                                        $ moduleCode = module[0]
                                        $ moduleName = module[1]
                                        $ currentAySem = module[2]
                                        $ targetAySem = module[3]
                                        $ currentQuota = module[4]
                                        $ targetQuota = module[5]
                                        $ quotaChange = module[6]
                                        <tr>
                                            <td><a href="/viewModule?code=$moduleCode" target="_blank" data-toggle="tooltip" title="View general info for $moduleCode">$moduleCode</a></td>
                                            <td>$moduleName</td>
                                        $if currentQuota is None:
                                            <td>
                                                ? <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $currentAySem"></span>
                                            </td>
                                        $else:
                                            <td>
                                                $currentQuota <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $currentAySem"></span>
                                            </td>
                                        $if targetQuota is None:
                                            <td>
                                                ? <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $targetAySem"></span>
                                            </td>
                                        $else:
                                            <td>
                                                $targetQuota <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="bottom" title="in $targetAySem"></span>
                                            </td>
                                        <td>$quotaChange</td>
                                        <td>
                                        $if currentQuota == "Unmounted" or targetQuota == "Unmounted":
                                            <form action="/modifiedModules" method="get" onsubmit="alert('To restore this module\'s quota, the module\'s mounting has to be restored.');">
                                                <input type="hidden" name="modifyType" value="mounting">
                                                <input type="hidden" name="code" value="$moduleCode">
                                                <button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="bottom" title="Restore Quota"><span class="glyphicon glyphicon-refresh"></span></button>
                                            </form>                    
                                        $else:
                                            <form action="/restoreModule" method="post" onsubmit="if(!confirm('Are you sure you want to restore this module\'s quota?')){event.preventDefault();}">
                                                <input type="hidden" name="code" value="$moduleCode">
                                                <input type="hidden" name="aysem" value="$targetAySem">
                                                <input type="hidden" name="quota" value="$currentQuota">
                                                <input type="hidden" name="restoreType" value="quota">
                                                <button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="bottom" title="Restore Quota"><span class="glyphicon glyphicon-refresh"></span></button>
                                            </form>
                                        </td>
                                        </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="tab-pane" id="moduleDetails">
                        <h2>Modules with Modified Details</h2>
                        <p>Shows which details have been changed for a modified module.</p>
                        <br>
                        <table class="table display dataTable table-bordered table-hover text-center" id="modified-modules-details-table">
                            <thead>
                                <tr>
                                    <th>Code</th>
                                    <th>Name</th>
                                    <th>Change in Details</th>
                                    <th data-sortable="false">Restore</th>
                                </tr>
                            </thead>
                            <tbody>
                                $if modifiedModulesDetails is None or len(modifiedModulesDetails) == 0:
                                    $pass
                                $else:
                                    $for module in modifiedModulesDetails:
                                        $ moduleCode = module[0][0]
                                        $ moduleName = module[0][4]
                                        $ isNameModified = module[1][0]
                                        $ isDescModified = module[1][1]
                                        $ isMcModified = module[1][2]
                                        <tr>
                                            <td><a href="/viewModule?code=$moduleCode" target="_blank" data-toggle="tooltip" title="View general info for $moduleCode">$moduleCode</a></td>
                                            <td>$moduleName</td>
                                            <td class="details-control">
                                        $if isNameModified is True:
                                            $ originalName = module[0][1]
                                            $ modifiedName = module[0][4]
                                            Name Changed: <span class="detail-change-text">From <b>$originalName</b> to <b>$modifiedName</b></span>
                                            <br>
                                            <br>
                                        $if isDescModified is True:
                                            Description Changed: <a id="$moduleCode" href="javascript:void(0)">Click to show/hide</a>
                                            $ originalDesc = module[0][2]
                                            $ modifiedDesc = module[0][5]
                                            <!-- This 2 'commented-out' p elements are needed for reference
                                            in rendering these info in the child rows. -->
                                            <!--p>$:originalDesc</p-->
                                            <!--p>$:modifiedDesc</p-->
                                            <br>
                                            <br>
                                        $if isMcModified is True:
                                            $ originalMc = module[0][3]
                                            $ modifiedMc = module[0][6]
                                            MCs Changed: <span class="detail-change-text">From <b>$originalMc</b> to <b>$modifiedMc</b></span>
                                        </td>
                                        $if True:
                                            <td>
                                                <form action="/restoreModule" method="post" onsubmit="if(!confirm('Are you sure you want to restore this module\'s details?')){event.preventDefault();}">
                                                    <input type="hidden" name="code" value="$module[0][0]">
                                                    <input type="hidden" name="restoreType" value="moduleDetails">
                                                    <button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="bottom" title="Restore Details"><span class="glyphicon glyphicon-refresh"></span></button>
                                                </form>
                                            </td>
                                        </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
        </div>
    </div>
</div>
<br>
<br>