Beispiel #1
0
def index(request):
    if request.user.is_authenticated:
        Lecturers_list = list(Lecturers.objects.values())
        lec_details = []
        rownumber = 1
        for lec_row in Lecturers_list:
            lec_row['row'] = rownumber
            lec_row['facultyLec'] = Functions.getSingleValueByCode(
                Faculty, str(lec_row['facultyLec_id']))
            lec_row['departmentLec'] = Functions.getSingleValueByCode(
                Department, str(lec_row['departmentLec_id']))
            lec_row['cousesTaken'] = Functions.getCourseTakenCount(
                Course, str(lec_row['code']))
            lec_row['priorityNumber'] = lec_row[
                'priorityNumber_id']  #staffTypes.objects.get(id=lec_row['priorityNumber_id']).type
            lec_details.append(lec_row)
            rownumber += 1

        context = {
            'lecturers': Lecturers_list,
            'maximumpriority': Functions.getMaxPriority() - 1,
            'pagedata': {
                'pageicon': 'teach',
                'pagetitle': 'Lecturers Management',
            }
        }
        return render(request, 'admin/lecturer/index.html', context)
    else:
        return redirect('../login')
Beispiel #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        newid = Functions.getNewId(Lecturers, 'LEC', "{:04}")
        self.fields["code"].initial = newid

        PRIORITY = []
        for x in range(1, Functions.getMaxPriority()):
            PRIORITY.append((x, x))
        # self.fields["priorityNumber"] = forms.ChoiceField(label='Priority Number', choices=PRIORITY, required=True, widget=forms.Select(attrs={'class':'form-control p-input'}))
        self.fields["facultyLec"].queryset = Faculty.objects.filter()
        self.fields["departmentLec"].queryset = Department.objects.filter()