Beispiel #1
0
    def save_model(self, request, obj, form, change):
        if change:
            dt = datetime.datetime.now()
            obj.ApprovalDate = dt.date()
            if obj.Status == 2:
                prevatt = Attendance.objects.filter(
                    Date=obj.LeaveDate
                ).filter(Barcode=obj.Barcode)
                if prevatt:
                    attendance = prevatt[0]
                else:
                    attendance = LeaveAttendance()
                    attendance.Barcode = obj.Barcode
                    attendance.Date = obj.LeaveDate

                if obj.Type == 4 or obj.Type == 7:
                    attendance.Remark = 'D'
                elif obj.Type == 5 or obj.Type == 6:
                    attendance.Remark = 'F'
                else:
                    attendance.Remark = 'O'
                attendance.save()
                pno = [obj.Barcode.Phone[-10:]]
                psms = "Leave application for " + unicode(obj.Barcode.Name) + \
                " for " + unicode(obj.LeaveDate.day) + '/' + \
                unicode(obj.LeaveDate.month) + '/' + \
                unicode(obj.LeaveDate.year) + \
                " has been approved."
                misc.sms_send(nos=pno,msg=psms)
            else:
                att = LeaveAttendance.objects.filter(
                    Date=obj.LeaveDate
                ).filter(Barcode=obj.Barcode)
                if att:
                    att[0].delete()
                if obj.Status == 3:
                    pno = [obj.Barcode.Phone[-10:]]
                    psms = "Leave application for " + unicode(obj.Barcode.Name) + \
                    " for " + unicode(obj.LeaveDate.day) + '/' + \
                    unicode(obj.LeaveDate.month) + '/' + \
                    unicode(obj.LeaveDate.year) + \
                    " has been denied."
                    misc.sms_send(nos=pno, msg=psms)
        obj.save()
Beispiel #2
0
def add(request):
    if not request.POST:
        applicationform = ApplicationForm()
        return render_to_response(
            'pravesh/add.html',
            {
                'form': applicationform,
                'button_name': 'Add'
            }
        )
    else:
        applicationform = ApplicationForm(request.POST)
        if not applicationform.is_valid():
            return render_to_response(
                'pravesh/add.html',
                {
                    'form': applicationform,
                    'button_name': 'Add'
                }
            )
        if request.POST['PayMode'] == 'DD' and not request.POST['DDNo']:
            return render_to_response(
                'pravesh/add.html',
                {
                    'form': applicationform,
                    'message': 'DD Number is mandatory',
                    'button_name': 'Add'
                }
            )
        if 'edit' in request.POST:
            student_obj = Student(pk=request.POST['edit'])
        else:
            student_obj = Student()
        student_obj.FirstName = request.POST['FirstName']
        student_obj.MiddleName = request.POST['MiddleName']
        student_obj.LastName = request.POST['LastName']
        student_obj.FatherName = request.POST['FatherName']
        student_obj.MotherName = request.POST['MotherName']
        student_obj.Address = request.POST['Address']
        student_obj.Pincode = int(request.POST['Pincode'])
        student_obj.PhoneHome = request.POST['PhoneHome']
        student_obj.PhoneMobile = request.POST['PhoneMobile']
        student_obj.Email = request.POST['Email']
        student_obj.Medium = request.POST['Medium']
        student_obj.Gender = request.POST['Gender']
        student_obj.DateOfBirth = request.POST['DateOfBirth']
        student_obj.CurrentSchool = request.POST['CurrentSchool']
        student_obj.CurrentStd = 0
        if request.POST['CurrentStd']:
            student_obj.CurrentStd = int(request.POST['CurrentStd'])
        student_obj.PayMode = request.POST['PayMode']
        student_obj.DDNo = request.POST['DDNo']
        student_obj.save()
        x = get_seatnumber(medium=student_obj.Medium)
        if 'edit' not in request.POST:
            hallticket_obj = HallTicket()
            hallticket_obj.Student = student_obj
            hallticket_obj.ClassRoom = ClassRoom.objects.get(pk=x['classroom'])
            hallticket_obj.SeatNumber = x['seatnumber']
            hallticket_obj.save()
            msg = 'Name: %s %s %s. Number: %s%s-%s Classroom: %s Medium: %s Date: %s Session: %s Time of test: %s to %s' %(student_obj.FirstName, student_obj.MiddleName, student_obj.LastName, hallticket_obj.ClassRoom.Medium, hallticket_obj.ClassRoom.Number, hallticket_obj.SeatNumber, hallticket_obj.ClassRoom.Name, student_obj.Medium, hallticket_obj.ClassRoom.Session.Start.strftime('%d-%b-%Y'), hallticket_obj.ClassRoom.Session.Name, hallticket_obj.ClassRoom.Session.Start.strftime('%H:%M'), hallticket_obj.ClassRoom.Session.End.strftime('%H:%M'))
            misc.sms_send(nos=[student_obj.PhoneMobile], msg=msg)
            return redirect('/pravesh/hallticket/%s'%(hallticket_obj.pk))
        else:
            hallticket_obj = HallTicket.objects.get(Student = student_obj)
            msg = 'Name: %s %s %s. Number: %s%s-%s Classroom: %s Medium: %s Date: %s Session: %s Time of test: %s to %s' %(student_obj.FirstName, student_obj.MiddleName, student_obj.LastName, hallticket_obj.ClassRoom.Medium, hallticket_obj.ClassRoom.Number, hallticket_obj.SeatNumber, hallticket_obj.ClassRoom.Name, student_obj.Medium, hallticket_obj.ClassRoom.Session.Start.strftime('%d-%b-%Y'), hallticket_obj.ClassRoom.Session.Name, hallticket_obj.ClassRoom.Session.Start.strftime('%H:%M'), hallticket_obj.ClassRoom.Session.End.strftime('%H:%M'))
            misc.sms_send(nos=[student_obj.PhoneMobile], msg=msg)
        return redirect('/pravesh')