Пример #1
0
def index(request):
    if request.user.is_authenticated:
        reg_list = list(Enrolment.objects.values())
        reg_details = []
        rownumber = 1
        for reg in reg_list:
            reg['row'] = rownumber
            reg['course_code'] = Functions.getSingleValueByCode(Course, reg['course_code_id'])
            reg['department'] = Functions.getSingleValueByCode(Department, reg['department_id'])
            reg['semesterType'] = Functions.getSemesterName(reg['semesterType'])
            reg_details.append(reg)
            rownumber += 1


        context = {
            'reg_details': reg_details,
            'idnum': 0,
            'pagedata':{
                'pageicon':'table-row-plus-before',
                'pagetitle':'Student Enrolments',
            }
        }
        return render(request, 'admin/registration/index.html', context)
    else:
        return redirect('../login')
Пример #2
0
def index(request):
    if request.user.is_authenticated:
        course_list = list(Course.objects.values())

        course_details = []
        rownumber = 1

        for cos_row in course_list:
            cos_row['row'] = rownumber
            # print(cos_row['officer'])
            cos_row['semester'] = Functions.getSemesterName(
                int(cos_row['semester']))
            cos_row['departments'] = len(
                cos_row['departments']
            )  #Functions.StyleList(Functions, Department, cos_row['departments'])
            cos_row['lecturers'] = Functions.StyleList(Functions, Lecturers,
                                                       cos_row['lecturers'])
            course_details.append(cos_row)
            rownumber += 1

        context = {
            'courses_list': course_details,
            'pagedata': {
                'pageicon': 'text-subject',
                'pagetitle': 'Courses Management',
            }
        }
        return render(request, 'admin/courses/index.html', context)
    else:
        return redirect('../login')
Пример #3
0
def index(request):
    if request.user.is_authenticated:

        context = {}

        scheduler = request.GET.get("viewscheduler", None)
        if scheduler == None:
            table_groups = list(TableRegister.objects.values())
            group_list = []
            rownumber = 1
            for table in table_groups:
                table['row'] = rownumber
                table['count'] = 20
                table[
                    'status'] = '<i class="mdi mdi-alert-circle text-warning"></i>'
                table['semestertype'] = Functions.getSemesterName(
                    table['semestertype'])
                group_list.append(table)
                rownumber += 1

            context = {
                'table_groups': group_list,
                'semesterRequire': Functions.getSemesterReq(),
                'pagedata': {
                    'pageicon': 'animation',
                    'pagetitle': 'Home: Schedulers',
                }
            }
            return render(request, 'admin/generator/index.html', context)

        else:
            studentgroup = request.GET.get("studentgroup", None)
            if studentgroup == None:
                style = request.GET.get("viewstyle", None)
                if style == None:
                    dfmain = pd.DataFrame(
                        list(
                            TablesGenerated.objects.values(
                                'students', 'department_id').filter(
                                    code=scheduler).order_by('department_id')))
                    df = dfmain[['students', 'department_id'
                                 ]].groupby(['students'
                                             ]).apply(lambda x: x.tail(1))
                    df['totalstudents'] = list(
                        dfmain['students'].value_counts().sort_index())
                    # print(df)
                    groupListString = ''
                    groupList = list(
                        TablesGenerated.objects.values(
                            'students',
                            'department_id').filter(code=scheduler))
                    for grp in groupList:
                        groupListString = groupListString + ',' + grp[
                            'students']
                        # print(grp)
                    groupListString = groupListString.split(",")
                    groupListString = list(sorted(set(groupListString)))
                    groupListString = filter(None, groupListString)
                    group_list = []
                    rownumber = 1

                    for group in groupListString:
                        print(group)
                        table = {}
                        table['row'] = rownumber
                        table['scheduler'] = scheduler
                        table['students'] = group
                        table['faculty'] = getTableDepartment(
                            group.split("-")[0], 'fac')
                        table['department'] = getTableDepartment(
                            group.split("-")[0], 'name')
                        table['level'] = group.split("-")[1] + '-Level'
                        table['courses'] = countStudentsGroupCourses(
                            group)['courses']
                        table['scheduled'] = countStudentsGroupCourses(
                            group)['scheduled']
                        table[
                            'status'] = '<i class="mdi mdi-alert-circle text-danger"></i>'
                        if table['scheduled'] == table['courses']:
                            table[
                                'status'] = '<i class="mdi mdi-checkbox-marked-circle text-success"><span style="display:none">4</span></i>'
                        elif table['scheduled'] / table['courses'] > 0.6:
                            table[
                                'status'] = '<i class="mdi mdi-alert-circle text-warning"><span style="display:none">3</span></i>'
                        #
                        table[
                            'semester'] = '<i class="mdi mdi-numeric-2-circle text-info" style="font-size: 20px;"><span style="display:none">2</span></>'
                        if group.split("-")[2] == '1':
                            table[
                                'semester'] = '<i class="mdi mdi-numeric-1-circle text-primary" style="font-size: 20px;"><span style="display:none">1</span></>'

                        # table['semestertype'] = Functions.getSemesterName(table['semestertype'])
                        group_list.append(table)
                        rownumber += 1

                    context = {
                        'table_groups_dpt': group_list,
                        'semesterRequire': Functions.getSemesterReq(),
                        'pagedata': {
                            'pageicon': 'animation',
                            'pagetitle': 'Timetable Generator',
                        }
                    }
                    return render(request, 'admin/generator/index.html',
                                  context)
                else:
                    dfmain = pd.DataFrame(
                        list(
                            TablesGenerated.objects.values(
                                'groupid', 'totalenrol', 'students',
                                'starttime', 'endtime', 'lecturers',
                                'lectureday', 'venue', 'course', 'remarks',
                                'status', 'department_id').filter(
                                    code=scheduler).order_by('department_id')))
                    group_list = []
                    rownumber = 1
                    # print(dfmain)
                    for group in dfmain.itertuples():
                        # print(group.course)
                        table = {}
                        table['row'] = rownumber
                        table['scheduler'] = group.groupid
                        table['student'] = []

                        Students = filter(None, group.students.split(","))
                        for stdgrp in Students:
                            StudentList = {
                                'scheduler':
                                scheduler,
                                'stdgrp':
                                stdgrp,
                                'name':
                                str(stdgrp.split("-")[1]) + '-' +
                                getTableDepartment(
                                    stdgrp.split("-")[0], 'name'),
                            }
                            table['student'].append(StudentList)

                        table['coursecode'] = getCourseData(
                            group.course, 'title'
                        ).title(
                        ) + '[' + group.course + ']'  #.code +'-'+group.course.name
                        table[
                            'lecturer'] = '<i class="mdi mdi-alert-decagram-outline text-danger"></i>'
                        if group.lecturers != '':
                            table['lecturer'] = getCourseLecturer(
                                str(group.lecturers), 'title').title(
                                ) + ' (' + group.lecturers.upper() + ')'

                        table['day'] = getFullDay(group.lectureday)
                        table['starttime'] = formatTime(group.starttime)
                        table['endtime'] = formatTime(group.endtime)
                        table[
                            'venue'] = '<i class="mdi mdi-alert-decagram-outline text-danger"></i>'
                        if group.venue != None:
                            table['venue'] = getCourseVenue(
                                group.venue, 'title').title(
                                ) + ' (' + group.venue.upper() + ')'
                        table['remarks'] = getRemarks(group.remarks,
                                                      group.status,
                                                      group.venue)
                        table[
                            'link'] = 'scheduler=' + scheduler + '&groupid=' + group.groupid + '&studentgroup=ALL'
                        group_list.append(table)
                        rownumber += 1

                    context = {
                        'table_groups_scheduler': group_list,
                        'semesterRequire': Functions.getSemesterReq(),
                        'pagedata': {
                            'pageicon': 'animation',
                            'pagetitle': 'All Schedules',
                        }
                    }
                    return render(request, 'admin/generator/index.html',
                                  context)
            else:
                dfmain = pd.DataFrame(
                    list(
                        TablesGenerated.objects.values(
                            'groupid', 'totalenrol', 'starttime', 'endtime',
                            'lecturers', 'lectureday', 'venue', 'course',
                            'remarks', 'status', 'department_id').filter(
                                code=scheduler,
                                students__contains=studentgroup).order_by(
                                    'students')))
                group_list = []
                rownumber = 1
                # tablesession = getTableData(scheduler)
                department = dfmain[['department_id']].iloc[0].department_id
                department = Functions.getDptName(
                    studentgroup.split('-')[0]).upper()
                timetabletitle = '' + studentgroup.split("-")[
                    1] + '-LEVEL ' + department + ' <br> ' + getTableRegistry(
                        scheduler, 'session') + ' [' + getTableRegistry(
                            scheduler, 'semestername') + ' ' + getSemester(
                                studentgroup.split("-")
                                [2]) + ' SEMESTER] TIMETABLE'
                for row in dfmain.itertuples():
                    table = {}
                    table['row'] = rownumber
                    table['coursecode'] = row.course
                    table['coursetitle'] = getCourseData(row.course,
                                                         'title').title()
                    table['day'] = getFullDay(row.lectureday)
                    table['start'] = formatTime(row.starttime)
                    table['end'] = formatTime(row.endtime)
                    table[
                        'lecturer'] = '<i class="mdi mdi-alert-decagram-outline text-danger"></i>'
                    if row.lecturers != '':
                        table['lecturer'] = getCourseLecturer(
                            str(row.lecturers), 'title').title(
                            ) + ' (' + row.lecturers.upper() + ')'
                    table[
                        'venue'] = '<i class="mdi mdi-alert-decagram-outline text-danger"></i>'
                    if row.venue != None:
                        table['venue'] = getCourseVenue(
                            row.venue,
                            'title').title() + ' (' + row.venue.upper() + ')'
                    table['remark'] = getRemarks(row.remarks, row.status,
                                                 row.venue)
                    table[
                        'link'] = 'scheduler=' + scheduler + '&groupid=' + row.groupid + '&studentgroup=' + studentgroup

                    # table['semestertype'] = Functions.getSemesterName(table['semestertype'])
                    group_list.append(table)
                    rownumber += 1

                context = {
                    'table_groups_dpt_view': group_list,
                    'generationForm_1': True,
                    'viewgrouptabledata': 'True',
                    'timetabletitle': timetabletitle,
                    'semesterRequire': Functions.getSemesterReq(),
                    'pagedata': {
                        'pageicon': 'timetable',
                        'pagetitle': studentgroup,
                    },
                    'modal': {
                        'modalicon': 'timetable',
                        'title': 'TIMETABLE: ' + studentgroup,
                        'button': 'Create Scheduler',
                        'size': 'modal-lg'
                    }
                }
                return render(request, 'admin/generator/viewtimetable.html',
                              context)
    else:
        return redirect('../login')